00001
00002
00003
00004
00005
00006
00007 #include "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009
00010 #include "Intrepid_FunctionSpaceTools.hpp"
00011
00012 namespace HYD {
00013
00014
00015 template<typename EvalT, typename Traits>
00016 HydrideCResid<EvalT, Traits>::
00017 HydrideCResid(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 cGrad (p.get<std::string> ("Gradient QP Variable Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout") ),
00024 chemTerm (p.get<std::string> ("Chemical Energy Term"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00026 stressTerm (p.get<std::string> ("Stress Term"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00028 cResidual (p.get<std::string> ("Residual Name"),
00029 p.get<Teuchos::RCP<PHX::DataLayout> >("Node Scalar Data Layout") )
00030 {
00031
00032 haveNoise = p.get<bool>("Have Noise");
00033
00034 this->addDependentField(wBF);
00035 this->addDependentField(cGrad);
00036 this->addDependentField(wGradBF);
00037 this->addDependentField(chemTerm);
00038 this->addDependentField(stressTerm);
00039 this->addEvaluatedField(cResidual);
00040
00041 if(haveNoise){
00042 noiseTerm = PHX::MDField<ScalarT, Cell, QuadPoint> (p.get<std::string>("Langevin Noise Term"),
00043 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00044 this->addDependentField(noiseTerm);
00045 }
00046
00047 gamma = p.get<double>("gamma Value");
00048
00049 Teuchos::RCP<PHX::DataLayout> vector_dl =
00050 p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00051 std::vector<PHX::DataLayout::size_type> dims;
00052 vector_dl->dimensions(dims);
00053 worksetSize = dims[0];
00054 numNodes = dims[1];
00055 numQPs = dims[2];
00056 numDims = dims[3];
00057
00058 gamma_term.resize(worksetSize, numQPs, numDims);
00059
00060 this->setName("HydrideCResid"+PHX::TypeString<EvalT>::value);
00061
00062 }
00063
00064
00065 template<typename EvalT, typename Traits>
00066 void HydrideCResid<EvalT, Traits>::
00067 postRegistrationSetup(typename Traits::SetupData d,
00068 PHX::FieldManager<Traits>& fm)
00069 {
00070 this->utils.setFieldData(wBF,fm);
00071 this->utils.setFieldData(cGrad,fm);
00072 this->utils.setFieldData(wGradBF,fm);
00073 this->utils.setFieldData(chemTerm,fm);
00074 this->utils.setFieldData(stressTerm,fm);
00075 if(haveNoise)
00076 this->utils.setFieldData(noiseTerm,fm);
00077
00078 this->utils.setFieldData(cResidual,fm);
00079 }
00080
00081
00082 template<typename EvalT, typename Traits>
00083 void HydrideCResid<EvalT, Traits>::
00084 evaluateFields(typename Traits::EvalData workset)
00085 {
00086
00087
00088
00089 typedef Intrepid::FunctionSpaceTools FST;
00090
00091 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00092 for (std::size_t qp=0; qp < numQPs; ++qp)
00093 for (std::size_t i=0; i < numDims; ++i)
00094
00095 gamma_term(cell, qp, i) = cGrad(cell,qp,i) * gamma;
00096
00097 FST::integrate<ScalarT>(cResidual, gamma_term, wGradBF, Intrepid::COMP_CPP, false);
00098
00099 FST::integrate<ScalarT>(cResidual, chemTerm, wBF, Intrepid::COMP_CPP, true);
00100
00101 FST::integrate<ScalarT>(cResidual, stressTerm, wBF, Intrepid::COMP_CPP, true);
00102
00103 if(haveNoise)
00104
00105 FST::integrate<ScalarT>(cResidual, noiseTerm, wBF, Intrepid::COMP_CPP, true);
00106
00107
00108 }
00109
00110 template<typename EvalT, typename Traits>
00111 typename HydrideCResid<EvalT, Traits>::ScalarT&
00112 HydrideCResid<EvalT, Traits>::getValue(const std::string &n) {
00113
00114 if (n == "gamma")
00115
00116 return gamma;
00117
00118 else
00119 {
00120 TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter, std::endl <<
00121 "Error! Logic error in getting parameter " << n <<
00122 " in HydrideCResid::getValue()" << std::endl);
00123 return gamma;
00124 }
00125
00126 }
00127
00128
00129 }
00130