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 GPAMResid<EvalT, Traits>::
00017 GPAMResid(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_gradient),
00021 C (p.get<std::string> ("QP Variable Name"), dl->qp_vector),
00022 Cgrad (p.get<std::string> ("Gradient QP Variable Name"), dl->qp_vecgradient),
00023 CDot (p.get<std::string> ("QP Time Derivative Variable Name"), dl->qp_vector),
00024 Residual (p.get<std::string> ("Residual Name"), dl->node_vector )
00025 {
00026 this->addDependentField(C);
00027 this->addDependentField(Cgrad);
00028 this->addDependentField(CDot);
00029 this->addDependentField(wBF);
00030 this->addDependentField(wGradBF);
00031
00032 this->addEvaluatedField(Residual);
00033
00034
00035 this->setName("GPAMResid"+PHX::TypeString<EvalT>::value);
00036
00037 std::vector<PHX::DataLayout::size_type> dims;
00038 wGradBF.fieldTag().dataLayout().dimensions(dims);
00039 numNodes = dims[1];
00040 numQPs = dims[2];
00041 numDims = dims[3];
00042
00043 C.fieldTag().dataLayout().dimensions(dims);
00044 vecDim = dims[2];
00045
00046
00047
00048 convectionTerm = true;
00049 u.resize(numDims,0.0);
00050 u[0] = 1.0;
00051
00052 std::cout << "GPAM Constructor vecDim = " << vecDim << " numDims = " << numDims << std::endl;
00053 }
00054
00055
00056 template<typename EvalT, typename Traits>
00057 void GPAMResid<EvalT, Traits>::
00058 postRegistrationSetup(typename Traits::SetupData d,
00059 PHX::FieldManager<Traits>& fm)
00060 {
00061 this->utils.setFieldData(C,fm);
00062 this->utils.setFieldData(Cgrad,fm);
00063 this->utils.setFieldData(CDot,fm);
00064 this->utils.setFieldData(wBF,fm);
00065 this->utils.setFieldData(wGradBF,fm);
00066
00067 this->utils.setFieldData(Residual,fm);
00068 }
00069
00070
00071 template<typename EvalT, typename Traits>
00072 void GPAMResid<EvalT, Traits>::
00073 evaluateFields(typename Traits::EvalData workset)
00074 {
00075 typedef Intrepid::FunctionSpaceTools FST;
00076
00077
00078 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00079 for (std::size_t node=0; node < numNodes; ++node) {
00080 for (std::size_t i=0; i<vecDim; i++) Residual(cell,node,i)=0.0;
00081 for (std::size_t qp=0; qp < numQPs; ++qp) {
00082 for (std::size_t i=0; i<vecDim; i++) {
00083 for (std::size_t dim=0; dim<numDims; dim++) {
00084 Residual(cell,node,i) += Cgrad(cell, qp, i, dim) * wGradBF(cell, node, qp, dim);
00085 } } } } }
00086
00087 if (workset.transientTerms) {
00088 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00089 for (std::size_t node=0; node < numNodes; ++node) {
00090 for (std::size_t qp=0; qp < numQPs; ++qp) {
00091 for (std::size_t i=0; i<vecDim; i++) {
00092 Residual(cell,node,i) += CDot(cell, qp, i) * wBF(cell, node, qp);
00093 } } } } }
00094
00095 if (convectionTerm) {
00096 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00097 for (std::size_t node=0; node < numNodes; ++node) {
00098 for (std::size_t qp=0; qp < numQPs; ++qp) {
00099 for (std::size_t i=0; i<vecDim; i++) {
00100 for (std::size_t dim=0; dim<numDims; dim++) {
00101 Residual(cell,node,i) += u[dim]*Cgrad(cell, qp, i, dim) * wBF(cell, node, qp);
00102 } } } } } }
00103
00104 }
00105
00106
00107 }
00108