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_MiniTensor.h>
00011
00012
00013 #include "Intrepid_RealSpaceTools.hpp"
00014
00015 #include <typeinfo>
00016
00017 namespace LCM {
00018
00019
00020 template<typename EvalT, typename Traits>
00021 ScalarL2ProjectionResidual<EvalT, Traits>::
00022 ScalarL2ProjectionResidual(const Teuchos::ParameterList& p) :
00023 wBF (p.get<std::string> ("Weighted BF Name"),
00024 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Scalar Data Layout") ),
00025 wGradBF (p.get<std::string> ("Weighted Gradient BF Name"),
00026 p.get<Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout") ),
00027 projectedStress (p.get<std::string> ("QP Variable Name"),
00028 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00029 DefGrad (p.get<std::string> ("Deformation Gradient Name"),
00030 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00031 Pstress (p.get<std::string> ("Stress Name"),
00032 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00033 TResidual (p.get<std::string> ("Residual Name"),
00034 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Scalar Data Layout") )
00035 {
00036 if (p.isType<bool>("Disable Transient"))
00037 enableTransient = !p.get<bool>("Disable Transient");
00038 else enableTransient = true;
00039
00040 this->addDependentField(wBF);
00041 this->addDependentField(wGradBF);
00042 this->addDependentField(projectedStress);
00043 this->addDependentField(DefGrad);
00044 this->addDependentField(Pstress);
00045
00046
00047
00048 this->addEvaluatedField(TResidual);
00049
00050 Teuchos::RCP<PHX::DataLayout> vector_dl =
00051 p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00052 std::vector<PHX::DataLayout::size_type> dims;
00053 vector_dl->dimensions(dims);
00054
00055 worksetSize = dims[0];
00056 numNodes = dims[1];
00057 numQPs = dims[2];
00058 numDims = dims[3];
00059
00060
00061
00062 tauH.resize(dims[0], numQPs);
00063
00064 this->setName("ScalarL2ProjectionResidual"+PHX::TypeString<EvalT>::value);
00065
00066 }
00067
00068
00069 template<typename EvalT, typename Traits>
00070 void ScalarL2ProjectionResidual<EvalT, Traits>::
00071 postRegistrationSetup(typename Traits::SetupData d,
00072 PHX::FieldManager<Traits>& fm)
00073 {
00074 this->utils.setFieldData(wBF,fm);
00075 this->utils.setFieldData(wGradBF,fm);
00076 this->utils.setFieldData(projectedStress,fm);
00077 this->utils.setFieldData(DefGrad,fm);
00078 this->utils.setFieldData(Pstress,fm);
00079
00080 this->utils.setFieldData(TResidual,fm);
00081 }
00082
00083
00084 template<typename EvalT, typename Traits>
00085 void ScalarL2ProjectionResidual<EvalT, Traits>::
00086 evaluateFields(typename Traits::EvalData workset)
00087 {
00088
00089 ScalarT J(1);
00090
00091 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00092 {
00093 for (std::size_t qp=0; qp < numQPs; ++qp)
00094 {
00095 Intrepid::Tensor<ScalarT> F(numDims, &DefGrad(cell, qp, 0, 0));
00096 J = Intrepid::det(F);
00097 tauH(cell,qp) = 0.0;
00098 for (std::size_t i=0; i<numDims; i++){
00099 tauH(cell,qp) += J*Pstress(cell, qp, i,i)/numDims;
00100 }
00101 }
00102 }
00103
00104 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00105 {
00106 for (std::size_t node=0; node < numNodes; ++node)
00107 {
00108 TResidual(cell,node)=0.0;
00109 }
00110 }
00111
00112 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00113 for (std::size_t node=0; node < numNodes; ++node) {
00114 for (std::size_t qp=0; qp < numQPs; ++qp) {
00115 TResidual(cell,node) += ( projectedStress(cell,qp)-
00116 tauH(cell, qp))*wBF(cell,node,qp);
00117 }
00118 }
00119 }
00120
00121
00122 }
00123
00124 }
00125
00126