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

StabParameter_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 <fstream>
00008 #include "Teuchos_TestForException.hpp"
00009 #include "Phalanx_DataLayout.hpp"
00010 #include "Sacado_ParameterRegistration.hpp"
00011 #include "Albany_Utils.hpp"
00012 
00013 #include <iostream>
00014 #include <boost/tuple/tuple.hpp>
00015 
00016 namespace LCM {
00017 
00018 
00019 template<typename EvalT, typename Traits>
00020 StabParameter<EvalT, Traits>::
00021 StabParameter(Teuchos::ParameterList& p) :
00022    stabParameter            (p.get<std::string>("Stabilization Parameter Name"),
00023      p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout"))
00024 {
00025   Teuchos::ParameterList* elmd_list = 
00026     p.get<Teuchos::ParameterList*>("Parameter List");
00027 
00028 
00029   Teuchos::RCP<PHX::DataLayout> vector_dl =
00030   p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00031   std::vector<PHX::DataLayout::size_type> dims;
00032   vector_dl->dimensions(dims);
00033 
00034   worksetSize = dims[0];
00035   numNodes = dims[1];
00036   numQPs  = dims[2];
00037   numDims = dims[3];
00038 
00039   Teuchos::RCP<ParamLib> paramLib = 
00040     p.get< Teuchos::RCP<ParamLib> >("Parameter Library", Teuchos::null);
00041 
00042   std::string type = elmd_list->get("Stabilization Parameter Type", "Constant");
00043   if (type == "Constant") {
00044     is_constant = true;
00045     constant_value = elmd_list->get("Value", 1.0);
00046 
00047     // Add StabParameter as a Sacado-ized parameter
00048     new Sacado::ParameterRegistration<EvalT, SPL_Traits>(
00049   "Stabilization Parameter", this, paramLib);
00050   }
00051   else if (type == "Gradient Dependent") {
00052     is_constant = false;
00053     constant_value = elmd_list->get("Value", 1.0);
00054 
00055   }
00056   else {
00057     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00058            "Invalid stabilization parameter type " << type);
00059   } 
00060 
00061 
00062   // Get additional input to construct adaptive stabilization
00063 
00064   if ( p.isType<std::string>("Gradient QP Variable Name") ) {
00065   //  is_constant = false;
00066 
00067  //   Teuchos::RCP<PHX::DataLayout> scalar_dl =
00068  //     p.get< Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout");
00069  //   PHX::MDField<ScalarT,Cell,QuadPoint>
00070  //     tmp(p.get<std::string>("QP Pore Pressure Name"), scalar_dl);
00071  //   porePressure = tmp;
00072   //  this->addDependentField(porePressure);
00073 
00074     Teuchos::RCP<PHX::DataLayout> vector_dl =
00075           p.get< Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout");
00076     PHX::MDField<ScalarT,Cell,QuadPoint,Dim>
00077           ts(p.get<std::string>("Gradient QP Variable Name"), vector_dl);
00078          TGrad = ts;
00079     this->addDependentField(TGrad);
00080 
00081 
00082   }
00083 
00084   if ( p.isType<std::string>("Gradient BF Name") ) {
00085   //  is_constant = false;
00086 
00087    //   Teuchos::RCP<PHX::DataLayout> scalar_dl =
00088    //     p.get< Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout");
00089    //   PHX::MDField<ScalarT,Cell,QuadPoint>
00090    //     tmp(p.get<std::string>("QP Pore Pressure Name"), scalar_dl);
00091    //   porePressure = tmp;
00092     //  this->addDependentField(porePressure);
00093 
00094       Teuchos::RCP<PHX::DataLayout> node_vector_dl =
00095             p.get< Teuchos::RCP<PHX::DataLayout> >("Node QP Vector Data Layout");
00096       PHX::MDField<MeshScalarT,Cell,Node, QuadPoint,Dim>
00097             ts(p.get<std::string>("Gradient BF Name"), node_vector_dl);
00098            GradBF = ts;
00099       this->addDependentField(GradBF);
00100 
00101 
00102     }
00103 
00104   if ( p.isType<std::string>("Diffusive Parameter Name") ) {
00105     is_constant = false;
00106        Teuchos::RCP<PHX::DataLayout> scalar_dl =
00107          p.get< Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout");
00108        PHX::MDField<ScalarT,Cell,QuadPoint>
00109          btp(p.get<std::string>("Diffusive Parameter Name"), scalar_dl);
00110        diffusionParameter = btp;
00111        this->addDependentField(diffusionParameter);
00112     }
00113 
00114 
00115 
00116   this->addEvaluatedField(stabParameter);
00117   this->setName("Stabilization Parameter"+PHX::TypeString<EvalT>::value);
00118 }
00119 
00120 // **********************************************************************
00121 template<typename EvalT, typename Traits>
00122 void StabParameter<EvalT, Traits>::
00123 postRegistrationSetup(typename Traits::SetupData d,
00124                       PHX::FieldManager<Traits>& fm)
00125 {
00126   this->utils.setFieldData(stabParameter,fm);
00127   if (!is_constant) {
00128     this->utils.setFieldData(TGrad,fm);
00129     this->utils.setFieldData(GradBF,fm);
00130     this->utils.setFieldData(diffusionParameter,fm);
00131   }
00132 
00133 
00134 }
00135 
00136 // **********************************************************************
00137 template<typename EvalT, typename Traits>
00138 void StabParameter<EvalT, Traits>::
00139 evaluateFields(typename Traits::EvalData workset)
00140 {
00141   std::size_t numCells = workset.numCells;
00142 
00143   ScalarT L2GradT;
00144   ScalarT UGNparameter;
00145 
00146 //  std::cout <<  "Constant? " << is_constant << endl;
00147 
00148   if (is_constant) {
00149     for (std::size_t cell=0; cell < numCells; ++cell) {
00150       for (std::size_t qp=0; qp < numQPs; ++qp) {
00151         stabParameter(cell,qp) = constant_value;
00152       }
00153     }
00154   } else {
00155 
00156 
00157 
00158 
00159     for (std::size_t cell=0; cell < numCells; ++cell) {
00160       for (std::size_t qp=0; qp < numQPs; ++qp) {
00161 
00162         L2GradT = 0.0;
00163         UGNparameter = 0.0;
00164 
00165 
00166 
00167              // calculate L2 norm of gradient T
00168              for (std::size_t dim=0; dim <numDims; ++dim){
00169                       L2GradT += TGrad(cell,qp,dim)*TGrad(cell,qp,dim);
00170              }
00171              L2GradT = std::sqrt(L2GradT);
00172 
00173             if (L2GradT != 0.0){
00174 
00175               for (std::size_t node=0; node < numNodes; ++node) {
00176                 for (std::size_t dim=0; dim <numDims; ++dim){
00177                   UGNparameter += std::abs(GradBF(cell, node, qp,dim)*TGrad(cell,qp,dim)/L2GradT);
00178 
00179                 }
00180               }
00181             }
00182             if ((UGNparameter !=0.0) && (diffusionParameter(cell,qp) != 0.0)){
00183               UGNparameter = 1.0/UGNparameter;
00184             }
00185             //stabParameter(cell,qp) = constant_value*UGNparameter*UGNparameter*diffusionParameter(cell,qp);
00186             stabParameter(cell,qp) = constant_value;
00187             // std::cout <<  "stabilization parameter value " << UGNparameter << endl;
00188 
00189 
00190 
00191 
00192                  /* biotCoefficient(cell,qp)*strain(cell,qp,i,i)
00193                              + porePressure(cell,qp)
00194                              *(biotCoefficient(cell,qp)-initialPorosity_value)/GrainBulkModulus; */
00195 
00196 
00197 //          // for debug
00198 //          std::cout << "initial Porosity: " << initialPorosity_value << endl;
00199 //          std::cout << "Pore Pressure: " << porePressure << endl;
00200 //          std::cout << "Biot Coefficient: " << biotCoefficient << endl;
00201 //          std::cout << "Grain Bulk Modulus " << GrainBulkModulus << endl;
00202 
00203 //      porosity(cell,qp) += (1.0 - initialPorosity_value)
00204 //                  /GrainBulkModulus*porePressure(cell,qp);
00205         // for large deformation, \phi = J \dot \phi_{o}
00206       }
00207     }
00208 
00209   }
00210 }
00211 
00212 
00213 
00214 
00215 // **********************************************************************
00216 template<typename EvalT,typename Traits>
00217 typename StabParameter<EvalT,Traits>::ScalarT&
00218 StabParameter<EvalT,Traits>::getValue(const std::string &n)
00219 {
00220   if (n == "Stabilization Parameter")
00221     return constant_value;
00222 
00223 
00224   TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00225          std::endl <<
00226          "Error! Logic error in getting parameter " << n
00227          << " in Porosity::getValue()" << std::endl);
00228   return constant_value;
00229 }
00230 
00231 // **********************************************************************
00232 // **********************************************************************
00233 }
00234 

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