• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Neohookean_Def.hpp

Go to the documentation of this file.
00001 //*****************************************************************//
00002 //    Albany 2.0:  Copyright 2012 Sandia Corporation               //
00003 //    This Software is released under the BSD license detailed     //
00004 //    in the file "license.txt" in the top-level Albany directory  //
00005 //*****************************************************************//
00006 
00007 #include <Intrepid_MiniTensor.h>
00008 #include "Teuchos_TestForException.hpp"
00009 #include "Phalanx_DataLayout.hpp"
00010 #include <typeinfo>
00011 
00012 namespace LCM {
00013 
00014   //----------------------------------------------------------------------------
00015   template<typename EvalT, typename Traits>
00016   Neohookean<EvalT, Traits>::
00017   Neohookean(const Teuchos::ParameterList& p,
00018              const Teuchos::RCP<Albany::Layouts>& dl) :
00019     defGrad          (p.get<std::string>("DefGrad Name"), dl->qp_tensor),
00020     J                (p.get<std::string>("DetDefGrad Name"), dl->qp_scalar),
00021     elasticModulus   (p.get<std::string>("Elastic Modulus Name"), dl->qp_scalar),
00022     poissonsRatio    (p.get<std::string>("Poissons Ratio Name"), dl->qp_scalar),
00023     stress           (p.get<std::string>("Stress Name"), dl->qp_tensor)
00024   {
00025     // Pull out numQPs and numDims from a Layout
00026     std::vector<PHX::DataLayout::size_type> dims;
00027     dl->qp_tensor->dimensions(dims);
00028     numQPs  = dims[1];
00029     numDims = dims[2];
00030     worksetSize = dims[0];
00031 
00032     this->addDependentField(defGrad);
00033     this->addDependentField(J);
00034     this->addDependentField(elasticModulus);
00035     this->addDependentField(poissonsRatio);
00036 
00037     this->addEvaluatedField(stress);
00038 
00039     this->setName("Neohookean Stress"+PHX::TypeString<EvalT>::value);
00040 
00041     // initilize Tensors
00042     F = Intrepid::Tensor<ScalarT>(numDims);
00043     b = Intrepid::Tensor<ScalarT>(numDims);
00044     sigma = Intrepid::Tensor<ScalarT>(numDims);
00045     I = Intrepid::eye<ScalarT>(numDims);
00046   }
00047 
00048   //----------------------------------------------------------------------------
00049   template<typename EvalT, typename Traits>
00050   void Neohookean<EvalT, Traits>::
00051   postRegistrationSetup(typename Traits::SetupData d,
00052                         PHX::FieldManager<Traits>& fm)
00053   {
00054     this->utils.setFieldData(stress,fm);
00055     this->utils.setFieldData(defGrad,fm);
00056     this->utils.setFieldData(J,fm);
00057     this->utils.setFieldData(elasticModulus,fm);
00058     this->utils.setFieldData(poissonsRatio,fm);
00059   }
00060 
00061   //----------------------------------------------------------------------------
00062   template<typename EvalT, typename Traits>
00063   void Neohookean<EvalT, Traits>::
00064   evaluateFields(typename Traits::EvalData workset)
00065   {
00066     //bool print = false;
00067     //if (typeid(ScalarT) == typeid(RealType)) print = true;
00068     //cout.precision(15);
00069 
00070     ScalarT kappa;
00071     ScalarT mu;
00072     ScalarT Jm53;
00073 
00074     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00075       for (std::size_t qp=0; qp < numQPs; ++qp) {
00076         kappa = 
00077           elasticModulus(cell,qp) / ( 3. * ( 1. - 2. * poissonsRatio(cell,qp) ) );
00078         mu = 
00079           elasticModulus(cell,qp) / ( 2. * ( 1. + poissonsRatio(cell,qp) ) );
00080         Jm53 = std::pow(J(cell,qp), -5./3.);
00081 
00082         F.fill(&defGrad(cell,qp,0,0));
00083         b = F*transpose(F);
00084         sigma = 0.5 * kappa * ( J(cell,qp) - 1. / J(cell,qp) ) * I
00085           + mu * Jm53 * Intrepid::dev(b);
00086 
00087         for (std::size_t i=0; i < numDims; ++i)
00088           for (std::size_t j=0; j < numDims; ++j)
00089             stress(cell,qp,i,j) = sigma(i,j);
00090       }
00091     }
00092   }
00093   //----------------------------------------------------------------------------
00094 }
00095 

Generated on Wed Mar 26 2014 18:36:40 for Albany: a Trilinos-based PDE code by  doxygen 1.7.1