Go to the documentation of this file.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 CahnHillWResid<EvalT, Traits>::
00017 CahnHillWResid(const Teuchos::ParameterList& p) :
00018 wBF (p.get<std::string> ("Weighted BF Name"),
00019 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Scalar Data Layout") ),
00020 BF (p.get<std::string> ("BF Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Scalar Data Layout") ),
00022 rhoDot (p.get<std::string> ("Rho QP Time Derivative Variable Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00024 rhoDotNode (p.get<std::string> ("Rho QP Time Derivative Variable Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Scalar Data Layout") ),
00026 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout") ),
00028 wGrad (p.get<std::string> ("Gradient QP Variable Name"),
00029 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00030 wResidual (p.get<std::string> ("Residual Name"),
00031 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Scalar Data Layout") )
00032 {
00033
00034 lump = p.get<bool>("Lump Mass");
00035
00036 this->addDependentField(wBF);
00037 this->addDependentField(BF);
00038 this->addDependentField(rhoDot);
00039 this->addDependentField(rhoDotNode);
00040 this->addDependentField(wGrad);
00041 this->addDependentField(wGradBF);
00042 this->addEvaluatedField(wResidual);
00043
00044 Teuchos::RCP<PHX::DataLayout> vector_dl =
00045 p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00046 std::vector<PHX::DataLayout::size_type> dims;
00047 vector_dl->dimensions(dims);
00048 worksetSize = dims[0];
00049 numNodes = dims[1];
00050 numQPs = dims[2];
00051 numDims = dims[3];
00052
00053 this->setName("CahnHillWResid"+PHX::TypeString<EvalT>::value);
00054
00055 }
00056
00057
00058 template<typename EvalT, typename Traits>
00059 void CahnHillWResid<EvalT, Traits>::
00060 postRegistrationSetup(typename Traits::SetupData d,
00061 PHX::FieldManager<Traits>& fm)
00062 {
00063 this->utils.setFieldData(wBF,fm);
00064 this->utils.setFieldData(BF,fm);
00065 this->utils.setFieldData(wGrad,fm);
00066 this->utils.setFieldData(wGradBF,fm);
00067 this->utils.setFieldData(rhoDot,fm);
00068 this->utils.setFieldData(rhoDotNode,fm);
00069
00070 this->utils.setFieldData(wResidual,fm);
00071 }
00072
00073 template<typename EvalT, typename Traits>
00074 void CahnHillWResid<EvalT, Traits>::
00075 evaluateFields(typename Traits::EvalData workset)
00076 {
00077 typedef Intrepid::FunctionSpaceTools FST;
00078
00079 FST::integrate<ScalarT>(wResidual, wGrad, wGradBF, Intrepid::COMP_CPP, false);
00080
00081 if(!lump){
00082
00083 FST::integrate<ScalarT>(wResidual, rhoDot, wBF, Intrepid::COMP_CPP, true);
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 }
00094 else {
00095
00096 ScalarT diag;
00097
00098
00099 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00100 for (std::size_t qp=0; qp < numQPs; ++qp) {
00101
00102 diag = 0;
00103 for (std::size_t node=0; node < numNodes; ++node)
00104
00105 diag += BF(cell, node, qp);
00106
00107 for (std::size_t node=0; node < numNodes; ++node)
00108
00109 wResidual(cell, node) += diag * rhoDotNode(cell, node) * wBF(cell, node, qp);
00110
00111 }
00112
00113 }
00114
00115 }
00116
00117
00118 }
00119