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
00016 template<typename EvalT, typename Traits>
00017 StokesContinuityResid<EvalT, Traits>::
00018 StokesContinuityResid(const Teuchos::ParameterList& p,
00019 const Teuchos::RCP<Albany::Layouts>& dl) :
00020 wBF (p.get<std::string> ("Weighted BF Name"), dl->node_qp_scalar),
00021 VGrad (p.get<std::string> ("Gradient QP Variable Name"), dl->qp_tensor),
00022 CResidual (p.get<std::string> ("Residual Name"), dl->node_scalar),
00023 havePSPG(p.get<bool>("Have PSPG"))
00024 {
00025 this->addDependentField(wBF);
00026 this->addDependentField(VGrad);
00027 if (havePSPG) {
00028 wGradBF = PHX::MDField<MeshScalarT,Cell,Node,QuadPoint,Dim>(
00029 p.get<std::string>("Weighted Gradient BF Name"), dl->node_qp_vector);
00030 TauM = PHX::MDField<ScalarT,Cell,QuadPoint>(
00031 p.get<std::string>("Tau M Name"), dl->qp_scalar);
00032 Rm = PHX::MDField<ScalarT,Cell,QuadPoint,Dim>(
00033 p.get<std::string>("Rm Name"), dl->qp_vector);
00034 this->addDependentField(wGradBF);
00035 this->addDependentField(TauM);
00036 this->addDependentField(Rm);
00037 }
00038
00039 this->addEvaluatedField(CResidual);
00040
00041 std::vector<PHX::DataLayout::size_type> dims;
00042 dl->node_qp_vector->dimensions(dims);
00043 numNodes = dims[1];
00044 numQPs = dims[2];
00045 numDims = dims[3];
00046
00047
00048 divergence.resize(dims[0], numQPs);
00049
00050 this->setName("StokesContinuityResid"+PHX::TypeString<EvalT>::value);
00051 }
00052
00053
00054 template<typename EvalT, typename Traits>
00055 void StokesContinuityResid<EvalT, Traits>::
00056 postRegistrationSetup(typename Traits::SetupData d,
00057 PHX::FieldManager<Traits>& fm)
00058 {
00059 this->utils.setFieldData(wBF,fm);
00060 this->utils.setFieldData(VGrad,fm);
00061 if (havePSPG) {
00062 this->utils.setFieldData(wGradBF,fm);
00063 this->utils.setFieldData(TauM,fm);
00064 this->utils.setFieldData(Rm,fm);
00065 }
00066
00067 this->utils.setFieldData(CResidual,fm);
00068 }
00069
00070
00071 template<typename EvalT, typename Traits>
00072 void StokesContinuityResid<EvalT, Traits>::
00073 evaluateFields(typename Traits::EvalData workset)
00074 {
00075 typedef Intrepid::FunctionSpaceTools FST;
00076
00077 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00078 for (std::size_t qp=0; qp < numQPs; ++qp) {
00079 divergence(cell,qp) = 0.0;
00080 for (std::size_t i=0; i < numDims; ++i) {
00081 divergence(cell,qp) += VGrad(cell,qp,i,i);
00082 }
00083 }
00084 }
00085
00086 FST::integrate<ScalarT>(CResidual, divergence, wBF, Intrepid::COMP_CPP,
00087 false);
00088
00089 if (havePSPG) {
00090 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00091 for (std::size_t node=0; node < numNodes; ++node) {
00092 for (std::size_t qp=0; qp < numQPs; ++qp) {
00093 for (std::size_t j=0; j < numDims; ++j) {
00094 CResidual(cell,node) +=
00095 TauM(cell,qp)*Rm(cell,qp,j)*wGradBF(cell,node,qp,j);
00096 }
00097 }
00098 }
00099 }
00100 }
00101
00102 }
00103
00104
00105 }
00106