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 NSTauM<EvalT, Traits>::
00017 NSTauM(const Teuchos::ParameterList& p) :
00018 V (p.get<std::string> ("Velocity QP Variable Name"),
00019 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00020 Gc (p.get<std::string> ("Contravarient Metric Tensor Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00022 rho (p.get<std::string> ("Density QP Variable Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00024 mu (p.get<std::string> ("Viscosity QP Variable Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00026 TauM (p.get<std::string> ("Tau M Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") )
00028
00029 {
00030 this->addDependentField(V);
00031 this->addDependentField(Gc);
00032 this->addDependentField(rho);
00033 this->addDependentField(mu);
00034
00035 this->addEvaluatedField(TauM);
00036
00037 Teuchos::RCP<PHX::DataLayout> vector_dl =
00038 p.get< Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout");
00039 std::vector<PHX::DataLayout::size_type> dims;
00040 vector_dl->dimensions(dims);
00041 numQPs = dims[1];
00042 numDims = dims[2];
00043
00044
00045 normGc.resize(dims[0], numQPs);
00046
00047 this->setName("NSTauM"+PHX::TypeString<EvalT>::value);
00048 }
00049
00050
00051 template<typename EvalT, typename Traits>
00052 void NSTauM<EvalT, Traits>::
00053 postRegistrationSetup(typename Traits::SetupData d,
00054 PHX::FieldManager<Traits>& fm)
00055 {
00056 this->utils.setFieldData(V,fm);
00057 this->utils.setFieldData(Gc,fm);
00058 this->utils.setFieldData(rho,fm);
00059 this->utils.setFieldData(mu,fm);
00060
00061 this->utils.setFieldData(TauM,fm);
00062 }
00063
00064
00065 template<typename EvalT, typename Traits>
00066 void NSTauM<EvalT, Traits>::
00067 evaluateFields(typename Traits::EvalData workset)
00068 {
00069 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00070 for (std::size_t qp=0; qp < numQPs; ++qp) {
00071 TauM(cell,qp) = 0.0;
00072 normGc(cell,qp) = 0.0;
00073 for (std::size_t i=0; i < numDims; ++i) {
00074 for (std::size_t j=0; j < numDims; ++j) {
00075 TauM(cell,qp) += rho(cell,qp)*rho(cell,qp)*V(cell,qp,i)*Gc(cell,qp,i,j)*V(cell,qp,j);
00076 normGc(cell,qp) += Gc(cell,qp,i,j)*Gc(cell,qp,i,j);
00077 }
00078 }
00079 TauM(cell,qp) += 12.*mu(cell,qp)*mu(cell,qp)*std::sqrt(normGc(cell,qp));
00080 TauM(cell,qp) = 1./std::sqrt(TauM(cell,qp));
00081 }
00082 }
00083
00084
00085 }
00086
00087
00088 }
00089