00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009
00010 #include "Intrepid_FunctionSpaceTools.hpp"
00011 #include "Intrepid_RealSpaceTools.hpp"
00012
00013 namespace LCM {
00014
00015
00016 template<typename EvalT, typename Traits>
00017 LatticeDefGrad<EvalT, Traits>::
00018 LatticeDefGrad(const Teuchos::ParameterList& p) :
00019 weights (p.get<std::string> ("Weights Name"),
00020 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00021 defgrad (p.get<std::string> ("DefGrad Name"),
00022 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00023 J (p.get<std::string> ("DetDefGrad Name"),
00024 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00025 JH (p.get<std::string> ("DetDefGradH Name"),
00026 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00027 CtotalRef (p.get<std::string> ("Stress Free Total Concentration Name"),
00028 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00029 Ctotal (p.get<std::string> ("Total Concentration Name"),
00030 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00031 VH (p.get<std::string> ("Partial Molar Volume Name"),
00032 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00033 VM (p.get<std::string> ("Molar Volume Name"),
00034 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00035 latticeDefGrad (p.get<std::string> ("Lattice Deformation Gradient Name"),
00036 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00037 weightedAverage(false),
00038 alpha(0.05)
00039 {
00040 if ( p.isType<std::string>("Weighted Volume Average J Name") )
00041 weightedAverage = p.get<bool>("Weighted Volume Average J");
00042 if ( p.isType<double>("Average J Stabilization Parameter Name") )
00043 alpha = p.get<double>("Average J Stabilization Parameter");
00044
00045 Teuchos::RCP<PHX::DataLayout> tensor_dl =
00046 p.get< Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout");
00047
00048 std::vector<PHX::DataLayout::size_type> dims;
00049 tensor_dl->dimensions(dims);
00050 worksetSize = dims[0];
00051 numQPs = dims[1];
00052 numDims = dims[2];
00053
00054
00055 this->addDependentField(weights);
00056 this->addDependentField(CtotalRef);
00057 this->addDependentField(Ctotal);
00058 this->addDependentField(VH);
00059 this->addDependentField(VM);
00060 this->addDependentField(defgrad);
00061 this->addDependentField(J);
00062
00063
00064 this->addEvaluatedField(latticeDefGrad);
00065 this->addEvaluatedField(JH);
00066
00067
00068 this->setName("Lattice Deformation Gradient"+PHX::TypeString<EvalT>::value);
00069
00070 }
00071
00072
00073 template<typename EvalT, typename Traits>
00074 void LatticeDefGrad<EvalT, Traits>::
00075 postRegistrationSetup(typename Traits::SetupData d,
00076 PHX::FieldManager<Traits>& fm)
00077 {
00078 this->utils.setFieldData(weights,fm);
00079 this->utils.setFieldData(defgrad,fm);
00080 this->utils.setFieldData(J,fm);
00081 this->utils.setFieldData(JH,fm);
00082 this->utils.setFieldData(CtotalRef,fm);
00083 this->utils.setFieldData(Ctotal,fm);
00084 this->utils.setFieldData(VH,fm);
00085 this->utils.setFieldData(VM,fm);
00086 this->utils.setFieldData(latticeDefGrad,fm);
00087
00088 }
00089
00090
00091 template<typename EvalT, typename Traits>
00092 void LatticeDefGrad<EvalT, Traits>::
00093 evaluateFields(typename Traits::EvalData workset)
00094 {
00095
00096 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00097 {
00098 for (std::size_t qp=0; qp < numQPs; ++qp)
00099 {
00100 for (std::size_t i=0; i < numDims; ++i)
00101 {
00102 for (std::size_t j=0; j < numDims; ++j)
00103 {
00104 latticeDefGrad(cell,qp,i,j) = defgrad(cell,qp,i,j);
00105 }
00106 }
00107 JH(cell,qp) = J(cell,qp);
00108 }
00109 }
00110
00111
00112
00113 for (std::size_t cell=workset.numCells; cell < worksetSize; ++cell)
00114 for (std::size_t qp=0; qp < numQPs; ++qp)
00115 for (std::size_t i=0; i < numDims; ++i)
00116 latticeDefGrad(cell,qp,i,i) = 1.0;
00117
00118 if (weightedAverage)
00119 {
00120 ScalarT Jbar, wJbar, vol;
00121 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00122 {
00123 Jbar = 0.0;
00124 vol = 0.0;
00125 for (std::size_t qp=0; qp < numQPs; ++qp)
00126 {
00127 Jbar += weights(cell,qp) * std::log( 1 + VH(cell,qp)*(Ctotal(cell,qp) - CtotalRef(cell,qp)) );
00128 vol += weights(cell,qp);
00129 }
00130 Jbar /= vol;
00131
00132 for (std::size_t qp=0; qp < numQPs; ++qp)
00133 {
00134 for (std::size_t i=0; i < numDims; ++i)
00135 {
00136 for (std::size_t j=0; j < numDims; ++j)
00137 {
00138 wJbar = std::exp( (1-alpha) * Jbar +
00139 alpha * std::log( 1 + VH(cell,qp)*(Ctotal(cell,qp) - CtotalRef(cell,qp))));
00140 latticeDefGrad(cell,qp,i,j) *= std::pow( wJbar ,-1./3. );
00141 }
00142 }
00143 JH(cell,qp) *= wJbar;
00144 }
00145 }
00146 } else {
00147 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00148 {
00149 for (std::size_t qp=0; qp < numQPs; ++qp)
00150 {
00151 JH(cell,qp) *= (1 + VH(cell,qp)*(Ctotal(cell,qp) - CtotalRef(cell,qp)));
00152 for (std::size_t i=0; i < numDims; ++i)
00153 {
00154 for (std::size_t j=0; j < numDims; ++j)
00155 {
00156 latticeDefGrad(cell,qp,i,j) *= std::pow(JH(cell,qp) ,-1./3. );
00157 }
00158 }
00159 }
00160 }
00161 }
00162 }
00163
00164 }