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 <typeinfo>
00011
00012 namespace LCM {
00013
00014
00015 template<typename EvalT, typename Traits>
00016 L2ProjectionResidual<EvalT, Traits>::
00017 L2ProjectionResidual(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 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout") ),
00022 projectedField (p.get<std::string> ("Projected Field Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00024 Pfield (p.get<std::string> ("Projection Field Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00026 TResidual (p.get<std::string> ("Residual Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Vector Data Layout") ),
00028 haveMechSource(false),
00029 haveSource(false)
00030 {
00031 if (p.isType<bool>("Disable Transient"))
00032 enableTransient = !p.get<bool>("Disable Transient");
00033 else enableTransient = true;
00034
00035 this->addDependentField(wBF);
00036 this->addDependentField(wGradBF);
00037 this->addDependentField(projectedField);
00038 this->addDependentField(Pfield);
00039
00040
00041
00042 this->addEvaluatedField(TResidual);
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
00049 worksetSize = dims[0];
00050 numNodes = dims[1];
00051 numQPs = dims[2];
00052 numDims = dims[3];
00053
00054 this->setName("L2ProjectionResidual"+PHX::TypeString<EvalT>::value);
00055
00056 }
00057
00058
00059 template<typename EvalT, typename Traits>
00060 void L2ProjectionResidual<EvalT, Traits>::
00061 postRegistrationSetup(typename Traits::SetupData d,
00062 PHX::FieldManager<Traits>& fm)
00063 {
00064 this->utils.setFieldData(wBF,fm);
00065 this->utils.setFieldData(wGradBF,fm);
00066 this->utils.setFieldData(projectedField,fm);
00067 this->utils.setFieldData(Pfield,fm);
00068 this->utils.setFieldData(TResidual,fm);
00069 }
00070
00071
00072 template<typename EvalT, typename Traits>
00073 void L2ProjectionResidual<EvalT, Traits>::
00074 evaluateFields(typename Traits::EvalData workset)
00075 {
00076 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00077 {
00078 for (std::size_t node=0; node < numNodes; ++node)
00079 {
00080
00081
00082
00083
00084
00085
00086 for (std::size_t k=0; k<numDims*numDims; ++k){
00087 TResidual(cell,node,k)=0.0;
00088
00089 for (std::size_t qp=0; qp < numQPs; ++qp){
00090
00091 TResidual(cell,node,k) += (projectedField(cell,qp,k) -
00092 Pfield(cell,qp,k/numDims,k%numDims))*wBF(cell,node,qp);
00093
00094
00095
00096 }
00097 }
00098 }
00099 }
00100 }
00101
00102 }
00103
00104