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
00013
00014 template<typename EvalT, typename Traits>
00015 PNP::PotentialResid<EvalT, Traits>::
00016 PotentialResid(const Teuchos::ParameterList& p,
00017 const Teuchos::RCP<Albany::Layouts>& dl) :
00018 wBF (p.get<std::string> ("Weighted BF Name"), dl->node_qp_scalar),
00019 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"), dl->node_qp_gradient),
00020
00021 Concentration ("Concentration", dl->qp_vector),
00022 PotentialGrad ("Potential Gradient", dl->qp_gradient),
00023 PotentialResidual ("Potential Residual", dl->node_scalar )
00024 {
00025 this->addDependentField(wBF);
00026 this->addDependentField(wGradBF);
00027
00028 this->addDependentField(Concentration);
00029 this->addDependentField(PotentialGrad);
00030
00031 this->addEvaluatedField(PotentialResidual);
00032
00033 std::vector<PHX::DataLayout::size_type> dims;
00034 wBF.fieldTag().dataLayout().dimensions(dims);
00035 numNodes = dims[1];
00036 numQPs = dims[2];
00037 Concentration.fieldTag().dataLayout().dimensions(dims);
00038 numSpecies = dims[2];
00039
00040
00041 q.resize(numSpecies);
00042 q[0] = 5.0;
00043 q[1] = -5.0;
00044
00045 this->setName("PotentialResid"+PHX::TypeString<EvalT>::value);
00046 }
00047
00048
00049 template<typename EvalT, typename Traits>
00050 void PNP::PotentialResid<EvalT, Traits>::
00051 postRegistrationSetup(typename Traits::SetupData d,
00052 PHX::FieldManager<Traits>& fm)
00053 {
00054 this->utils.setFieldData(wBF,fm);
00055 this->utils.setFieldData(wGradBF,fm);
00056
00057 this->utils.setFieldData(Concentration,fm);
00058 this->utils.setFieldData(PotentialGrad,fm);
00059
00060 this->utils.setFieldData(PotentialResidual,fm);
00061 }
00062
00063
00064 template<typename EvalT, typename Traits>
00065 void PNP::PotentialResid<EvalT, Traits>::
00066 evaluateFields(typename Traits::EvalData workset)
00067 {
00068 typedef Intrepid::FunctionSpaceTools FST;
00069
00070
00071
00072
00073
00074 FST::integrate<ScalarT>(PotentialResidual, PotentialGrad, wGradBF, Intrepid::COMP_CPP, false);
00075
00076
00077 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00078 for (std::size_t node=0; node < numNodes; ++node) {
00079 for (std::size_t qp=0; qp < numQPs; ++qp) {
00080 for (std::size_t j=0; j < numSpecies; ++j) {
00081 PotentialResidual(cell,node) -=
00082 q[j]*Concentration(cell,qp,j)*wBF(cell,node,qp);
00083
00084 }
00085 }
00086 }
00087 }
00088
00089 }
00090
00091