00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009
00010 #include "Intrepid_FunctionSpaceTools.hpp"
00011
00012 namespace PHAL {
00013
00014
00015 template<typename EvalT, typename Traits>
00016 NSMomentumResid<EvalT, Traits>::
00017 NSMomentumResid(const Teuchos::ParameterList& p) :
00018 wBF (p.get<std::string> ("Weighted BF Name"),
00019 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Scalar Data Layout") ),
00020 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout") ),
00022 pGrad (p.get<std::string> ("Pressure Gradient QP Variable Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00024 VGrad (p.get<std::string> ("Velocity Gradient QP Variable Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00026 P (p.get<std::string> ("Pressure QP Variable Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00028 Rm (p.get<std::string> ("Rm Name"),
00029 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00030 mu (p.get<std::string> ("Viscosity QP Variable Name"),
00031 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00032 MResidual (p.get<std::string> ("Residual Name"),
00033 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Vector Data Layout") ),
00034 haveSUPG(p.get<bool>("Have SUPG"))
00035 {
00036
00037 if (p.isType<bool>("Disable Transient"))
00038 enableTransient = !p.get<bool>("Disable Transient");
00039 else enableTransient = true;
00040
00041 this->addDependentField(wBF);
00042 this->addDependentField(pGrad);
00043 this->addDependentField(VGrad);
00044 this->addDependentField(wGradBF);
00045 this->addDependentField(P);
00046 this->addDependentField(Rm);
00047 this->addDependentField(mu);
00048 if (haveSUPG) {
00049 V = PHX::MDField<ScalarT,Cell,QuadPoint,Dim>(
00050 p.get<std::string>("Velocity QP Variable Name"),
00051 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") );
00052 rho = PHX::MDField<ScalarT,Cell,QuadPoint>(
00053 p.get<std::string>("Density QP Variable Name"),
00054 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") );
00055 TauM = PHX::MDField<ScalarT,Cell,QuadPoint>(
00056 p.get<std::string>("Tau M Name"),
00057 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") );
00058 this->addDependentField(V);
00059 this->addDependentField(rho);
00060 this->addDependentField(TauM);
00061 }
00062
00063 this->addEvaluatedField(MResidual);
00064
00065 Teuchos::RCP<PHX::DataLayout> vector_dl =
00066 p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00067 std::vector<PHX::DataLayout::size_type> dims;
00068 vector_dl->dimensions(dims);
00069 numNodes = dims[1];
00070 numQPs = dims[2];
00071 numDims = dims[3];
00072
00073 this->setName("NSMomentumResid"+PHX::TypeString<EvalT>::value);
00074 }
00075
00076
00077 template<typename EvalT, typename Traits>
00078 void NSMomentumResid<EvalT, Traits>::
00079 postRegistrationSetup(typename Traits::SetupData d,
00080 PHX::FieldManager<Traits>& fm)
00081 {
00082 this->utils.setFieldData(wBF,fm);
00083 this->utils.setFieldData(pGrad,fm);
00084 this->utils.setFieldData(VGrad,fm);
00085 this->utils.setFieldData(wGradBF,fm);
00086 this->utils.setFieldData(P,fm);
00087 this->utils.setFieldData(Rm,fm);
00088 this->utils.setFieldData(mu,fm);
00089 if (haveSUPG) {
00090 this->utils.setFieldData(V,fm);
00091 this->utils.setFieldData(rho,fm);
00092 this->utils.setFieldData(TauM,fm);
00093 }
00094
00095 this->utils.setFieldData(MResidual,fm);
00096 }
00097
00098
00099 template<typename EvalT, typename Traits>
00100 void NSMomentumResid<EvalT, Traits>::
00101 evaluateFields(typename Traits::EvalData workset)
00102 {
00103
00104 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00105 for (std::size_t node=0; node < numNodes; ++node) {
00106 for (std::size_t i=0; i<numDims; i++) {
00107 MResidual(cell,node,i) = 0.0;
00108 for (std::size_t qp=0; qp < numQPs; ++qp) {
00109 MResidual(cell,node,i) +=
00110 (Rm(cell, qp, i)-pGrad(cell,qp,i))*wBF(cell,node,qp) -
00111 P(cell,qp)*wGradBF(cell,node,qp,i);
00112 for (std::size_t j=0; j < numDims; ++j) {
00113 MResidual(cell,node,i) +=
00114 mu(cell,qp)*(VGrad(cell,qp,i,j)+VGrad(cell,qp,j,i))*wGradBF(cell,node,qp,j);
00115
00116 }
00117 }
00118 }
00119 }
00120 }
00121
00122 if (haveSUPG) {
00123 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00124 for (std::size_t node=0; node < numNodes; ++node) {
00125 for (std::size_t i=0; i<numDims; i++) {
00126 for (std::size_t qp=0; qp < numQPs; ++qp) {
00127 for (std::size_t j=0; j < numDims; ++j) {
00128 MResidual(cell,node,i) +=
00129 rho(cell,qp)*TauM(cell,qp)*Rm(cell,qp,j)*V(cell,qp,j)*wGradBF(cell,node,qp,j);
00130 }
00131 }
00132 }
00133 }
00134 }
00135 }
00136
00137 }
00138
00139 }
00140