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 namespace PHAL {
00011
00012
00013 template<typename EvalT, typename Traits>
00014 TPSALaplaceResid<EvalT, Traits>::
00015 TPSALaplaceResid(const Teuchos::ParameterList& p, const Teuchos::RCP<Albany::Layouts>& dl) :
00016 GradBF (p.get<std::string> ("Gradient BF Name"), dl->node_qp_gradient),
00017 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"), dl->node_qp_gradient),
00018 solnVec(p.get<std::string> ("Solution Vector Name"), dl->node_vector),
00019 solnResidual(p.get<std::string> ("Residual Name"), dl->node_vector) {
00020
00021
00022 this->addDependentField(GradBF);
00023 this->addDependentField(wGradBF);
00024 this->addDependentField(solnVec);
00025 this->addEvaluatedField(solnResidual);
00026
00027 std::vector<PHX::DataLayout::size_type> dims;
00028 dl->node_qp_vector->dimensions(dims);
00029 worksetSize = dims[0];
00030 numNodes = dims[1];
00031 numQPs = dims[2];
00032 numDims = dims[3];
00033
00034 this->setName("LaplaceResid" + PHX::TypeString<EvalT>::value);
00035
00036 }
00037
00038
00039 template<typename EvalT, typename Traits>
00040 void TPSALaplaceResid<EvalT, Traits>::
00041 postRegistrationSetup(typename Traits::SetupData d,
00042 PHX::FieldManager<Traits>& fm) {
00043 this->utils.setFieldData(GradBF, fm);
00044 this->utils.setFieldData(wGradBF, fm);
00045 this->utils.setFieldData(solnVec, fm);
00046 this->utils.setFieldData(solnResidual, fm);
00047 }
00048
00049
00050 template<typename EvalT, typename Traits>
00051 void TPSALaplaceResid<EvalT, Traits>::
00052 evaluateFields(typename Traits::EvalData workset) {
00053
00054
00055
00056 for(std::size_t cell = 0; cell < workset.numCells; ++cell) {
00057 for(std::size_t node_a = 0; node_a < numNodes; ++node_a) {
00058
00059 for(std::size_t eq = 0; eq < numDims; eq++) {
00060 solnResidual(cell, node_a, eq) = 0.0;
00061 }
00062
00063 for(std::size_t qp = 0; qp < numQPs; ++qp) {
00064 for(std::size_t node_b = 0; node_b < numNodes; ++node_b) {
00065
00066 ScalarT kk = 0.0;
00067
00068 for(std::size_t i = 0; i < numDims; i++) {
00069
00070 kk += GradBF(cell, node_a, qp, i) * wGradBF(cell, node_b, qp, i);
00071
00072 }
00073
00074 for(std::size_t eq = 0; eq < numDims; eq++) {
00075
00076 solnResidual(cell, node_a, eq) += kk * solnVec(cell, node_b, eq);
00077
00078 }
00079 }
00080 }
00081 }
00082 }
00083 }
00084
00085
00086 }
00087