00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Teuchos_VerboseObject.hpp"
00009 #include "Teuchos_RCP.hpp"
00010 #include "Phalanx_DataLayout.hpp"
00011 #include "Sacado_ParameterRegistration.hpp"
00012
00013 #include "Intrepid_FunctionSpaceTools.hpp"
00014
00015 namespace Aeras {
00016
00017
00018 template<typename EvalT, typename Traits>
00019 XZScalarAdvectionResid<EvalT, Traits>::
00020 XZScalarAdvectionResid(const Teuchos::ParameterList& p,
00021 const Teuchos::RCP<Albany::Layouts>& dl) :
00022 wBF (p.get<std::string> ("Weighted BF Name"), dl->node_qp_scalar),
00023 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"),dl->node_qp_gradient),
00024 rho (p.get<std::string> ("QP Variable Name"), dl->qp_scalar),
00025 rhoGrad (p.get<std::string> ("Gradient QP Variable Name"), dl->qp_gradient),
00026 rhoDot (p.get<std::string> ("QP Time Derivative Variable Name"), dl->qp_scalar),
00027 coordVec (p.get<std::string> ("QP Coordinate Vector Name"), dl->qp_gradient),
00028 Residual (p.get<std::string> ("Residual Name"), dl->node_scalar)
00029 {
00030
00031 Teuchos::ParameterList* eulerList = p.get<Teuchos::ParameterList*>("XZScalarAdvection Problem");
00032 Re = eulerList->get<double>("Reynolds Number", 1.0);
00033
00034 this->addDependentField(rho);
00035 this->addDependentField(rhoGrad);
00036 this->addDependentField(rhoDot);
00037 this->addDependentField(wBF);
00038 this->addDependentField(wGradBF);
00039 this->addDependentField(coordVec);
00040
00041 this->addEvaluatedField(Residual);
00042
00043
00044 this->setName("Aeras::XZScalarAdvectionResid"+PHX::TypeString<EvalT>::value);
00045
00046 std::vector<PHX::DataLayout::size_type> dims;
00047 wGradBF.fieldTag().dataLayout().dimensions(dims);
00048 numNodes = dims[1];
00049 numQPs = dims[2];
00050 numDims = dims[3];
00051
00052
00053 Teuchos::RCP<ParamLib> paramLib = p.get<Teuchos::RCP<ParamLib> >("Parameter Library");
00054 new Sacado::ParameterRegistration<EvalT, SPL_Traits>("Reynolds Number", this, paramLib);
00055 }
00056
00057
00058 template<typename EvalT, typename Traits>
00059 void XZScalarAdvectionResid<EvalT, Traits>::
00060 postRegistrationSetup(typename Traits::SetupData d,
00061 PHX::FieldManager<Traits>& fm)
00062 {
00063 this->utils.setFieldData(rho,fm);
00064 this->utils.setFieldData(rhoGrad,fm);
00065 this->utils.setFieldData(rhoDot,fm);
00066 this->utils.setFieldData(wBF,fm);
00067 this->utils.setFieldData(wGradBF,fm);
00068 this->utils.setFieldData(coordVec,fm);
00069
00070 this->utils.setFieldData(Residual,fm);
00071 }
00072
00073
00074 template<typename EvalT, typename Traits>
00075 void XZScalarAdvectionResid<EvalT, Traits>::
00076 evaluateFields(typename Traits::EvalData workset)
00077 {
00078 std::vector<ScalarT> vel(2);
00079 for (std::size_t i=0; i < Residual.size(); ++i) Residual(i)=0.0;
00080
00081 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00082 for (std::size_t qp=0; qp < numQPs; ++qp) {
00083
00084 if (coordVec(cell,qp,1) > 5.0) vel[0] = Re;
00085 else vel[0] = 0.0;
00086 vel[1] = 0.0;
00087
00088 for (std::size_t node=0; node < numNodes; ++node) {
00089
00090 Residual(cell,node) += rhoDot(cell,qp)*wBF(cell,node,qp);
00091
00092 for (std::size_t j=0; j < numDims; ++j) {
00093 Residual(cell,node) += vel[j]*rhoGrad(cell,qp,j)*wBF(cell,node,qp);
00094 }
00095 }
00096 }
00097 }
00098 }
00099
00100
00101
00102 template<typename EvalT,typename Traits>
00103 typename XZScalarAdvectionResid<EvalT,Traits>::ScalarT&
00104 XZScalarAdvectionResid<EvalT,Traits>::getValue(const std::string &n)
00105 {
00106 return Re;
00107 }
00108
00109 }