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

FirstPK_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 <Phalanx_DataLayout.hpp>
00009 #include <Sacado_ParameterRegistration.hpp>
00010 #include <Teuchos_TestForException.hpp>
00011 
00012 namespace LCM
00013 {
00014 
00015 //------------------------------------------------------------------------------
00016 template<typename EvalT, typename Traits>
00017 FirstPK<EvalT, Traits>::
00018 FirstPK(Teuchos::ParameterList& p,
00019         const Teuchos::RCP<Albany::Layouts>& dl) :
00020   stress_(p.get<std::string>("Stress Name"), dl->qp_tensor),
00021   def_grad_(p.get<std::string>("DefGrad Name"), dl->qp_tensor),
00022   first_pk_stress_(p.get<std::string>("First PK Stress Name"), dl->qp_tensor),
00023   have_pore_pressure_(p.get<bool>("Have Pore Pressure", false)),
00024   small_strain_(p.get<bool>("Small Strain", false))
00025 {
00026   this->addDependentField(stress_);
00027   this->addDependentField(def_grad_);
00028 
00029   this->addEvaluatedField(first_pk_stress_);
00030 
00031   this->setName("FirstPK" + PHX::TypeString<EvalT>::value);
00032 
00033   // logic to modify stress in the presence of a pore pressure
00034   if (have_pore_pressure_) {
00035     // grab the pore pressure
00036     PHX::MDField<ScalarT, Cell, QuadPoint>
00037     tmp(p.get<std::string>("Pore Pressure Name"), dl->qp_scalar);
00038     pore_pressure_ = tmp;
00039     // grab Biot's coefficient
00040     PHX::MDField<ScalarT, Cell, QuadPoint>
00041     tmp2(p.get<std::string>("Biot Coefficient Name"), dl->qp_scalar);
00042     biot_coeff_ = tmp2;
00043     this->addDependentField(pore_pressure_);
00044     this->addDependentField(biot_coeff_);
00045   }
00046 
00047   std::vector<PHX::DataLayout::size_type> dims;
00048   stress_.fieldTag().dataLayout().dimensions(dims);
00049   num_pts_ = dims[1];
00050   num_dims_ = dims[2];
00051 
00052   Teuchos::RCP<ParamLib> paramLib =
00053       p.get<Teuchos::RCP<ParamLib> >("Parameter Library");
00054 }
00055 
00056 //------------------------------------------------------------------------------
00057 template<typename EvalT, typename Traits>
00058 void FirstPK<EvalT, Traits>::
00059 postRegistrationSetup(typename Traits::SetupData d,
00060     PHX::FieldManager<Traits>& fm)
00061 {
00062   this->utils.setFieldData(stress_, fm);
00063   this->utils.setFieldData(def_grad_, fm);
00064   this->utils.setFieldData(first_pk_stress_, fm);
00065   if (have_pore_pressure_) {
00066     this->utils.setFieldData(pore_pressure_, fm);
00067     this->utils.setFieldData(biot_coeff_, fm);
00068   }
00069 }
00070 
00071 //------------------------------------------------------------------------------
00072 template<typename EvalT, typename Traits>
00073 void FirstPK<EvalT, Traits>::
00074 evaluateFields(typename Traits::EvalData workset)
00075 {
00076   //std::cout.precision(15);
00077   // initilize Tensors
00078   Intrepid::Tensor<ScalarT> F(num_dims_), P(num_dims_), sig(num_dims_);
00079   Intrepid::Tensor<ScalarT> I(Intrepid::eye<ScalarT>(num_dims_));
00080 
00081   if (have_pore_pressure_) {
00082     for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00083       for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00084 
00085         // Effective Stress theory
00086         sig.fill(&stress_(cell, pt, 0, 0));
00087         sig -= biot_coeff_(cell, pt) * pore_pressure_(cell, pt) * I;
00088 
00089         for (std::size_t i = 0; i < num_dims_; i++) {
00090           for (std::size_t j = 0; j < num_dims_; j++) {
00091             stress_(cell, pt, i, j) = sig(i, j);
00092           }
00093         }
00094       }
00095     }
00096   }
00097 
00098   // for small deformation, trivially copy Cauchy stress into first PK
00099   if (small_strain_) { 
00100     for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00101       for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00102         sig.fill(&stress_(cell,pt,0,0));
00103         for (std::size_t dim0 = 0; dim0 < num_dims_; ++dim0) {
00104           for (std::size_t dim1 = 0; dim1 < num_dims_; ++dim1) {
00105             first_pk_stress_(cell,pt,dim0,dim1) = stress_(cell,pt,dim0,dim1);
00106           }
00107         }
00108       }
00109     }
00110   } else {
00111     // for large deformation, map Cauchy stress to 1st PK stress
00112     for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00113       for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00114         F.fill(&def_grad_(cell, pt, 0, 0));
00115         sig.fill(&stress_(cell, pt, 0, 0));
00116 
00117         // map Cauchy stress to 1st PK
00118         P = Intrepid::piola(F, sig);
00119 
00120         for (std::size_t i = 0; i < num_dims_; ++i) {
00121           for (std::size_t j = 0; j < num_dims_; ++j) {
00122             first_pk_stress_(cell,pt,i,j) = P(i, j);
00123           }
00124         }
00125       }
00126     }
00127   }
00128 }
00129 //------------------------------------------------------------------------------
00130 }
00131 

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