00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "Teuchos_TestForException.hpp"
00019 #include "Teuchos_VerboseObject.hpp"
00020 #include "Phalanx_DataLayout.hpp"
00021
00022 #include "Intrepid_FunctionSpaceTools.hpp"
00023
00024 namespace FELIX {
00025
00026
00027 template<typename EvalT, typename Traits>
00028 StokesL1L2Resid<EvalT, Traits>::
00029 StokesL1L2Resid(const Teuchos::ParameterList& p,
00030 const Teuchos::RCP<Albany::Layouts>& dl) :
00031 wBF (p.get<std::string> ("Weighted BF Name"), dl->node_qp_scalar),
00032 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"), dl->node_qp_gradient),
00033 U (p.get<std::string> ("QP Variable Name"), dl->qp_vector),
00034 Ugrad (p.get<std::string> ("Gradient QP Variable Name"), dl->qp_vecgradient),
00035 UDot (p.get<std::string> ("QP Time Derivative Variable Name"), dl->qp_vector),
00036 force (p.get<std::string> ("Body Force Name"), dl->qp_vector),
00037 muFELIX (p.get<std::string> ("FELIX Viscosity QP Variable Name"), dl->qp_scalar),
00038 epsilonXX (p.get<std::string> ("FELIX EpsilonXX QP Variable Name"), dl->qp_scalar),
00039 epsilonYY (p.get<std::string> ("FELIX EpsilonYY QP Variable Name"), dl->qp_scalar),
00040 epsilonXY (p.get<std::string> ("FELIX EpsilonXY QP Variable Name"), dl->qp_scalar),
00041 Residual (p.get<std::string> ("Residual Name"), dl->node_vector)
00042 {
00043 this->addDependentField(U);
00044 this->addDependentField(Ugrad);
00045 this->addDependentField(force);
00046
00047 this->addDependentField(wBF);
00048 this->addDependentField(wGradBF);
00049 this->addDependentField(muFELIX);
00050 this->addDependentField(epsilonXX);
00051 this->addDependentField(epsilonYY);
00052 this->addDependentField(epsilonXY);
00053
00054 this->addEvaluatedField(Residual);
00055
00056
00057 this->setName("StokesL1L2Resid"+PHX::TypeString<EvalT>::value);
00058
00059 std::vector<PHX::DataLayout::size_type> dims;
00060 wGradBF.fieldTag().dataLayout().dimensions(dims);
00061 numNodes = dims[1];
00062 numQPs = dims[2];
00063 numDims = dims[3];
00064
00065 U.fieldTag().dataLayout().dimensions(dims);
00066 vecDim = dims[2];
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 if (vecDim != 2) {TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00077 std::endl << "Error in FELIX::StokesL1L2Resid constructor: " <<
00078 "Invalid Parameter vecDim. Problem implemented for 2 dofs per node only (u and v). " << std::endl);}
00079
00080 }
00081
00082
00083 template<typename EvalT, typename Traits>
00084 void StokesL1L2Resid<EvalT, Traits>::
00085 postRegistrationSetup(typename Traits::SetupData d,
00086 PHX::FieldManager<Traits>& fm)
00087 {
00088 this->utils.setFieldData(U,fm);
00089 this->utils.setFieldData(Ugrad,fm);
00090 this->utils.setFieldData(force,fm);
00091
00092 this->utils.setFieldData(wBF,fm);
00093 this->utils.setFieldData(wGradBF,fm);
00094 this->utils.setFieldData(muFELIX,fm);
00095 this->utils.setFieldData(epsilonXX,fm);
00096 this->utils.setFieldData(epsilonYY,fm);
00097 this->utils.setFieldData(epsilonXY,fm);
00098
00099 this->utils.setFieldData(Residual,fm);
00100 }
00101
00102
00103 template<typename EvalT, typename Traits>
00104 void StokesL1L2Resid<EvalT, Traits>::
00105 evaluateFields(typename Traits::EvalData workset)
00106 {
00107 typedef Intrepid::FunctionSpaceTools FST;
00108 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00109 for (std::size_t node=0; node < numNodes; ++node) {
00110 for (std::size_t i=0; i<vecDim; i++) Residual(cell,node,i)=0.0;
00111 for (std::size_t qp=0; qp < numQPs; ++qp) {
00112 Residual(cell,node,0) += 2.0*muFELIX(cell,qp)*((2.0*epsilonXX(cell,qp) + epsilonYY(cell,qp))*wGradBF(cell,node,qp,0) +
00113 epsilonXY(cell,qp)*wGradBF(cell,node,qp,1)) +
00114 force(cell,qp,0)*wBF(cell,node,qp);
00115 Residual(cell,node,1) += 2.0*muFELIX(cell,qp)*(epsilonXY(cell,qp)*wGradBF(cell,node,qp,0) +
00116 (epsilonXX(cell,qp) + 2.0*epsilonYY(cell,qp))*wGradBF(cell,node,qp,1))
00117 + force(cell,qp,1)*wBF(cell,node,qp);
00118 }
00119 }
00120 }
00121 }
00122
00123
00124 }
00125