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 #include "Sacado_ParameterRegistration.hpp"
00013
00014 namespace LCM {
00015
00016
00017 template<typename EvalT, typename Traits>
00018 TLElasResid<EvalT, Traits>::
00019 TLElasResid(const Teuchos::ParameterList& p) :
00020 stress (p.get<std::string> ("Stress Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00022 J (p.get<std::string> ("DetDefGrad Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00024 defgrad (p.get<std::string> ("DefGrad Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00026 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout") ),
00028 wBF (p.get<std::string> ("Weighted BF Name"),
00029 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Scalar Data Layout") ),
00030 Residual (p.get<std::string> ("Residual Name"),
00031 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Vector Data Layout") )
00032 {
00033 this->addDependentField(stress);
00034 this->addDependentField(J);
00035 this->addDependentField(defgrad);
00036 this->addDependentField(wGradBF);
00037 this->addDependentField(wBF);
00038
00039 this->addEvaluatedField(Residual);
00040
00041 this->setName("TLElasResid"+PHX::TypeString<EvalT>::value);
00042
00043 std::vector<PHX::DataLayout::size_type> dims;
00044 wGradBF.fieldTag().dataLayout().dimensions(dims);
00045 numNodes = dims[1];
00046 numQPs = dims[2];
00047 numDims = dims[3];
00048 int worksetSize = dims[0];
00049
00050
00051 F_inv.resize(worksetSize, numQPs, numDims, numDims);
00052 F_invT.resize(worksetSize, numQPs, numDims, numDims);
00053 JF_invT.resize(worksetSize, numQPs, numDims, numDims);
00054 P.resize(worksetSize, numQPs, numDims, numDims);
00055
00056 Teuchos::RCP<ParamLib> paramLib = p.get< Teuchos::RCP<ParamLib> >("Parameter Library");
00057
00058 matModel = p.get<std::string>("Stress Name");
00059
00060 zGrav=0.0;
00061 new Sacado::ParameterRegistration<EvalT, SPL_Traits>("zGrav", this, paramLib);
00062
00063 }
00064
00065
00066 template<typename EvalT, typename Traits>
00067 void TLElasResid<EvalT, Traits>::
00068 postRegistrationSetup(typename Traits::SetupData d,
00069 PHX::FieldManager<Traits>& fm)
00070 {
00071 this->utils.setFieldData(stress,fm);
00072 this->utils.setFieldData(J,fm);
00073 this->utils.setFieldData(defgrad,fm);
00074 this->utils.setFieldData(wGradBF,fm);
00075 this->utils.setFieldData(wBF,fm);
00076
00077 this->utils.setFieldData(Residual,fm);
00078 }
00079
00080
00081 template<typename EvalT, typename Traits>
00082 void TLElasResid<EvalT, Traits>::
00083 evaluateFields(typename Traits::EvalData workset)
00084 {
00085 std::cout.precision(15);
00086 typedef Intrepid::FunctionSpaceTools FST;
00087 typedef Intrepid::RealSpaceTools<ScalarT> RST;
00088
00089
00090 if (matModel == "Neohookean AD")
00091 {
00092 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00093 for (std::size_t node=0; node < numNodes; ++node) {
00094 for (std::size_t dim=0; dim<numDims; dim++) Residual(cell,node,dim)=0.0;
00095 for (std::size_t qp=0; qp < numQPs; ++qp) {
00096 for (std::size_t i=0; i<numDims; i++) {
00097 for (std::size_t j=0; j<numDims; j++) {
00098 Residual(cell,node,i) += stress(cell, qp, i, j) * wGradBF(cell, node, qp, j);
00099 }
00100 }
00101 }
00102 }
00103 }
00104 }
00105 else
00106 {
00107 RST::inverse(F_inv, defgrad);
00108 RST::transpose(F_invT, F_inv);
00109 FST::scalarMultiplyDataData<ScalarT>(JF_invT, J, F_invT);
00110 FST::tensorMultiplyDataData<ScalarT>(P, stress, JF_invT);
00111 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00112 for (std::size_t node=0; node < numNodes; ++node) {
00113 for (std::size_t dim=0; dim<numDims; dim++) Residual(cell,node,dim)=0.0;
00114 for (std::size_t qp=0; qp < numQPs; ++qp) {
00115 for (std::size_t i=0; i<numDims; i++) {
00116 for (std::size_t j=0; j<numDims; j++) {
00117 Residual(cell,node,i) += P(cell, qp, i, j) * wGradBF(cell, node, qp, j);
00118 }
00119 }
00120 }
00121 }
00122 }
00123 }
00133 }
00134
00135 template<typename EvalT,typename Traits>
00136 typename TLElasResid<EvalT,Traits>::ScalarT&
00137 TLElasResid<EvalT,Traits>::getValue(const std::string &n)
00138 {
00139 return zGrav;
00140 }
00141
00142
00143
00144 }
00145