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::ConcentrationResid<EvalT, Traits>::
00016 ConcentrationResid(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 Concentration ("Concentration", dl->qp_vector),
00021 Concentration_dot ("Concentration_dot", dl->qp_vector),
00022 ConcentrationGrad ("Concentration Gradient", dl->qp_vecgradient),
00023 PotentialGrad ("Potential Gradient", dl->qp_gradient),
00024 ConcentrationResidual ("Concentration Residual", dl->node_vector )
00025 {
00026 this->addDependentField(wBF);
00027 this->addDependentField(wGradBF);
00028 this->addDependentField(Concentration);
00029 this->addDependentField(Concentration_dot);
00030 this->addDependentField(ConcentrationGrad);
00031 this->addDependentField(PotentialGrad);
00032
00033 this->addEvaluatedField(ConcentrationResidual);
00034
00035 std::vector<PHX::DataLayout::size_type> dims;
00036 wGradBF.fieldTag().dataLayout().dimensions(dims);
00037 numNodes = dims[1];
00038 numQPs = dims[2];
00039 numDims = dims[3];
00040 ConcentrationGrad.fieldTag().dataLayout().dimensions(dims);
00041 numSpecies = dims[2];
00042
00043
00044 beta.resize(numSpecies);
00045 beta[0] = 1.0;
00046 beta[1] = -1.0;
00047 D.resize(numSpecies);
00048 D[0] = 1.0;
00049 D[1] = 2.0;
00050
00051 this->setName("ConcentrationResid"+PHX::TypeString<EvalT>::value);
00052 }
00053
00054
00055 template<typename EvalT, typename Traits>
00056 void PNP::ConcentrationResid<EvalT, Traits>::
00057 postRegistrationSetup(typename Traits::SetupData d,
00058 PHX::FieldManager<Traits>& fm)
00059 {
00060 this->utils.setFieldData(wBF,fm);
00061 this->utils.setFieldData(wGradBF,fm);
00062 this->utils.setFieldData(Concentration,fm);
00063 this->utils.setFieldData(Concentration_dot,fm);
00064 this->utils.setFieldData(ConcentrationGrad,fm);
00065 this->utils.setFieldData(PotentialGrad,fm);
00066
00067 this->utils.setFieldData(ConcentrationResidual,fm);
00068 }
00069
00070
00071 template<typename EvalT, typename Traits>
00072 void PNP::ConcentrationResid<EvalT, Traits>::
00073 evaluateFields(typename Traits::EvalData workset)
00074 {
00075 typedef Intrepid::FunctionSpaceTools FST;
00076
00077
00078
00079
00080 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00081 for (std::size_t node=0; node < numNodes; ++node) {
00082 for (std::size_t j=0; j < numSpecies; ++j) {
00083 ConcentrationResidual(cell,node,j) = 0.0;
00084 } } }
00085
00086 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00087 for (std::size_t node=0; node < numNodes; ++node) {
00088 for (std::size_t qp=0; qp < numQPs; ++qp) {
00089 for (std::size_t j=0; j < numSpecies; ++j) {
00090 for (std::size_t dim=0; dim < numDims; ++dim) {
00091 ConcentrationResidual(cell,node,j) +=
00092 D[j]*(ConcentrationGrad(cell,qp,j,dim)
00093 + beta[j]*Concentration(cell,qp,j)*PotentialGrad(cell,qp,dim))
00094 *wGradBF(cell,node,qp,dim);
00095 }
00096 }
00097 }
00098 }
00099 }
00100
00101 }
00102
00103