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 NSRm<EvalT, Traits>::
00017 NSRm(const Teuchos::ParameterList& p) :
00018 pGrad (p.get<std::string> ("Pressure Gradient QP Variable Name"),
00019 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00020 VGrad (p.get<std::string> ("Velocity Gradient QP Variable Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00022 V (p.get<std::string> ("Velocity QP Variable Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00024 V_Dot (p.get<std::string> ("Velocity Dot QP Variable Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00026 rho (p.get<std::string> ("Density QP Variable Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00028 phi (p.get<std::string> ("Porosity QP Variable Name"),
00029 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00030 force (p.get<std::string> ("Body Force QP Variable Name"),
00031 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00032 permTerm (p.get<std::string> ("Permeability Term"),
00033 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00034 ForchTerm (p.get<std::string> ("Forchheimer Term"),
00035 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00036 Rm (p.get<std::string> ("Rm Name"),
00037 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00038 porousMedia (p.get<bool>("Porous Media"))
00039
00040 {
00041 if (p.isType<bool>("Disable Transient"))
00042 enableTransient = !p.get<bool>("Disable Transient");
00043 else enableTransient = true;
00044
00045 this->addDependentField(pGrad);
00046 this->addDependentField(VGrad);
00047 this->addDependentField(V);
00048 if (enableTransient) this->addDependentField(V_Dot);
00049 this->addDependentField(force);
00050 this->addDependentField(rho);
00051 if (porousMedia) {
00052 this->addDependentField(phi);
00053 this->addDependentField(permTerm);
00054 this->addDependentField(ForchTerm);
00055 }
00056 this->addEvaluatedField(Rm);
00057
00058 Teuchos::RCP<PHX::DataLayout> vector_dl =
00059 p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00060 std::vector<PHX::DataLayout::size_type> dims;
00061 vector_dl->dimensions(dims);
00062 numNodes = dims[1];
00063 numQPs = dims[2];
00064 numDims = dims[3];
00065
00066 this->setName("NSRm"+PHX::TypeString<EvalT>::value);
00067 }
00068
00069
00070 template<typename EvalT, typename Traits>
00071 void NSRm<EvalT, Traits>::
00072 postRegistrationSetup(typename Traits::SetupData d,
00073 PHX::FieldManager<Traits>& fm)
00074 {
00075 this->utils.setFieldData(pGrad,fm);
00076 this->utils.setFieldData(VGrad,fm);
00077 this->utils.setFieldData(V,fm);
00078 if (enableTransient) this->utils.setFieldData(V_Dot,fm);
00079 this->utils.setFieldData(force,fm);
00080 this->utils.setFieldData(rho,fm);
00081 if (porousMedia) {
00082 this->utils.setFieldData(phi,fm);
00083 this->utils.setFieldData(permTerm,fm);
00084 this->utils.setFieldData(ForchTerm,fm);
00085 }
00086
00087 this->utils.setFieldData(Rm,fm);
00088 }
00089
00090
00091 template<typename EvalT, typename Traits>
00092 void NSRm<EvalT, Traits>::
00093 evaluateFields(typename Traits::EvalData workset)
00094 {
00095 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00096 for (std::size_t qp=0; qp < numQPs; ++qp) {
00097 for (std::size_t i=0; i < numDims; ++i) {
00098 if (workset.transientTerms && enableTransient)
00099 Rm(cell,qp,i) = rho(cell,qp)*V_Dot(cell,qp,i);
00100 else
00101 Rm(cell,qp,i) = 0;
00102 if (!porousMedia)
00103 Rm(cell,qp,i) += pGrad(cell,qp,i)+force(cell,qp,i);
00104 else
00105 Rm(cell,qp,i) += phi(cell,qp)*pGrad(cell,qp,i)+phi(cell,qp)*force(cell,qp,i);
00106 if (porousMedia) {
00107 Rm(cell,qp,i) += -permTerm(cell,qp,i)+ForchTerm(cell,qp,i);
00108 }
00109 for (std::size_t j=0; j < numDims; ++j) {
00110 if (!porousMedia)
00111 Rm(cell,qp,i) += rho(cell,qp)*V(cell,qp,j)*VGrad(cell,qp,i,j);
00112 else
00113 Rm(cell,qp,i) += rho(cell,qp)*V(cell,qp,j)*VGrad(cell,qp,i,j)/phi(cell,qp);
00114 }
00115 }
00116 }
00117 }
00118 }
00119
00120 }
00121