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 LCM {
00013
00014
00015 template<typename EvalT, typename Traits>
00016 Stress<EvalT, Traits>::
00017 Stress(const Teuchos::ParameterList& p) :
00018 strain (p.get<std::string> ("Strain Name"),
00019 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") ),
00020 elasticModulus (p.get<std::string> ("Elastic Modulus Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00022 poissonsRatio (p.get<std::string> ("Poissons Ratio Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00024 stress (p.get<std::string> ("Stress Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout") )
00026 {
00027
00028 Teuchos::RCP<PHX::DataLayout> tensor_dl =
00029 p.get< Teuchos::RCP<PHX::DataLayout> >("QP Tensor Data Layout");
00030 std::vector<PHX::DataLayout::size_type> dims;
00031 tensor_dl->dimensions(dims);
00032 numQPs = dims[1];
00033 numDims = dims[2];
00034
00035 this->addDependentField(strain);
00036 this->addDependentField(elasticModulus);
00037
00038 if (numDims>1) this->addDependentField(poissonsRatio);
00039
00040 this->addEvaluatedField(stress);
00041
00042 this->setName("Stress"+PHX::TypeString<EvalT>::value);
00043
00044 }
00045
00046
00047 template<typename EvalT, typename Traits>
00048 void Stress<EvalT, Traits>::
00049 postRegistrationSetup(typename Traits::SetupData d,
00050 PHX::FieldManager<Traits>& fm)
00051 {
00052 this->utils.setFieldData(stress,fm);
00053 this->utils.setFieldData(strain,fm);
00054 this->utils.setFieldData(elasticModulus,fm);
00055 if (numDims>1) this->utils.setFieldData(poissonsRatio,fm);
00056 }
00057
00058
00059 template<typename EvalT, typename Traits>
00060 void Stress<EvalT, Traits>::
00061 evaluateFields(typename Traits::EvalData workset)
00062 {
00063 ScalarT lambda, mu;
00064
00065 switch (numDims) {
00066 case 1:
00067 Intrepid::FunctionSpaceTools::tensorMultiplyDataData<ScalarT>(stress, elasticModulus, strain);
00068 break;
00069 case 2:
00070
00071 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00072 for (std::size_t qp=0; qp < numQPs; ++qp) {
00073 lambda = ( elasticModulus(cell,qp) * poissonsRatio(cell,qp) ) / ( ( 1 + poissonsRatio(cell,qp) ) * ( 1 - 2 * poissonsRatio(cell,qp) ) );
00074 mu = elasticModulus(cell,qp) / ( 2 * ( 1 + poissonsRatio(cell,qp) ) );
00075 stress(cell,qp,0,0) = 2.0 * mu * ( strain(cell,qp,0,0) ) + lambda * ( strain(cell,qp,0,0) + strain(cell,qp,1,1) );
00076 stress(cell,qp,1,1) = 2.0 * mu * ( strain(cell,qp,1,1) ) + lambda * ( strain(cell,qp,0,0) + strain(cell,qp,1,1) );
00077 stress(cell,qp,0,1) = 2.0 * mu * ( strain(cell,qp,0,1) );
00078 stress(cell,qp,1,0) = stress(cell,qp,0,1);
00079 }
00080 }
00081 break;
00082 case 3:
00083
00084 for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00085 for (std::size_t qp=0; qp < numQPs; ++qp) {
00086 lambda = ( elasticModulus(cell,qp) * poissonsRatio(cell,qp) ) / ( ( 1 + poissonsRatio(cell,qp) ) * ( 1 - 2 * poissonsRatio(cell,qp) ) );
00087 mu = elasticModulus(cell,qp) / ( 2 * ( 1 + poissonsRatio(cell,qp) ) );
00088 stress(cell,qp,0,0) = 2.0 * mu * ( strain(cell,qp,0,0) ) + lambda * ( strain(cell,qp,0,0) + strain(cell,qp,1,1) + strain(cell,qp,2,2) );
00089 stress(cell,qp,1,1) = 2.0 * mu * ( strain(cell,qp,1,1) ) + lambda * ( strain(cell,qp,0,0) + strain(cell,qp,1,1) + strain(cell,qp,2,2) );
00090 stress(cell,qp,2,2) = 2.0 * mu * ( strain(cell,qp,2,2) ) + lambda * ( strain(cell,qp,0,0) + strain(cell,qp,1,1) + strain(cell,qp,2,2) );
00091 stress(cell,qp,0,1) = 2.0 * mu * ( strain(cell,qp,0,1) );
00092 stress(cell,qp,1,2) = 2.0 * mu * ( strain(cell,qp,1,2) );
00093 stress(cell,qp,2,0) = 2.0 * mu * ( strain(cell,qp,2,0) );
00094 stress(cell,qp,1,0) = stress(cell,qp,0,1);
00095 stress(cell,qp,2,1) = stress(cell,qp,1,2);
00096 stress(cell,qp,0,2) = stress(cell,qp,2,0);
00097 }
00098 }
00099 break;
00100 }
00101 }
00102
00103
00104 }
00105