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 FELIX {
00013
00014
00015 template<typename EvalT, typename Traits>
00016 StokesMomentumResid<EvalT, Traits>::
00017 StokesMomentumResid(const Teuchos::ParameterList& p,
00018 const Teuchos::RCP<Albany::Layouts>& dl) :
00019 wBF (p.get<std::string> ("Weighted BF Name"), dl->node_qp_scalar),
00020 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"), dl->node_qp_vector),
00021 VGrad (p.get<std::string> ("Velocity Gradient QP Variable Name"), dl->qp_tensor),
00022 P (p.get<std::string> ("Pressure QP Variable Name"), dl->qp_scalar),
00023 force (p.get<std::string> ("Body Force Name"), dl->qp_vector),
00024 muFELIX (p.get<std::string> ("FELIX Viscosity QP Variable Name"), dl->qp_scalar),
00025 MResidual (p.get<std::string> ("Residual Name"),dl->node_vector)
00026 {
00027
00028 this->addDependentField(wBF);
00029 this->addDependentField(VGrad);
00030 this->addDependentField(wGradBF);
00031 this->addDependentField(P);
00032 this->addDependentField(force);
00033 this->addDependentField(muFELIX);
00034
00035 this->addEvaluatedField(MResidual);
00036
00037 std::vector<PHX::DataLayout::size_type> dims;
00038 dl->node_qp_vector->dimensions(dims);
00039 numNodes = dims[1];
00040 numQPs = dims[2];
00041 numDims = dims[3];
00042
00043 this->setName("StokesMomentumResid"+PHX::TypeString<EvalT>::value);
00044 }
00045
00046
00047 template<typename EvalT, typename Traits>
00048 void StokesMomentumResid<EvalT, Traits>::
00049 postRegistrationSetup(typename Traits::SetupData d,
00050 PHX::FieldManager<Traits>& fm)
00051 {
00052 this->utils.setFieldData(wBF,fm);
00053 this->utils.setFieldData(VGrad,fm);
00054 this->utils.setFieldData(wGradBF,fm);
00055 this->utils.setFieldData(P,fm);
00056 this->utils.setFieldData(force,fm);
00057 this->utils.setFieldData(muFELIX,fm);
00058
00059 this->utils.setFieldData(MResidual,fm);
00060 }
00061
00062
00063 template<typename EvalT, typename Traits>
00064 void StokesMomentumResid<EvalT, Traits>::
00065 evaluateFields(typename Traits::EvalData workset)
00066 {
00067 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00068 for (std::size_t node=0; node < numNodes; ++node) {
00069 for (std::size_t i=0; i<numDims; i++) {
00070 MResidual(cell,node,i) = 0.0;
00071 for (std::size_t qp=0; qp < numQPs; ++qp) {
00072 MResidual(cell,node,i) +=
00073 force(cell,qp,i)*wBF(cell,node,qp) -
00074 P(cell,qp)*wGradBF(cell,node,qp,i);
00075 for (std::size_t j=0; j < numDims; ++j) {
00076 MResidual(cell,node,i) +=
00077 muFELIX(cell,qp)*(VGrad(cell,qp,i,j)+VGrad(cell,qp,j,i))*wGradBF(cell,node,qp,j);
00078
00079 }
00080 }
00081 }
00082 }
00083 }
00084
00085
00086 }
00087
00088 }
00089