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

HydFractionResid_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 "Teuchos_TestForException.hpp"
00008 #include "Phalanx_DataLayout.hpp"
00009 
00010 #include "Sacado_ParameterRegistration.hpp"
00011 #include "Albany_Utils.hpp"
00012 
00013 #include "Intrepid_FunctionSpaceTools.hpp"
00014 
00015 namespace PHAL {
00016 
00017 //**********************************************************************
00018 template<typename EvalT, typename Traits>
00019 HydFractionResid<EvalT, Traits>::
00020 HydFractionResid(Teuchos::ParameterList& p,
00021                  const Teuchos::RCP<Albany::Layouts>& dl) :
00022   dl_(dl),
00023 
00024   wBF         (p.get<std::string>                   ("Weighted BF Name"), dl->node_qp_scalar),
00025   Temperature (p.get<std::string>                   ("Temperature Name"), dl->qp_scalar),
00026   Tdot        (p.get<std::string>                   ("Temp Time Derivative Name"), dl->qp_scalar),
00027   Fh          (p.get<std::string>                   ("QP Variable Name"), dl->qp_scalar),
00028   Fhdot       (p.get<std::string>                   ("QP Time Derivative Variable Name"), dl->qp_scalar),
00029   JThermCond  (p.get<std::string>                   ("J Conductivity Name"), dl->qp_scalar),
00030   wGradBF     (p.get<std::string>                   ("Weighted Gradient BF Name"), dl->node_qp_vector),
00031   TGrad       (p.get<std::string>                   ("Temp Gradient Variable Name"), dl->qp_vector),
00032   FhResidual  (p.get<std::string>                   ("Residual Name"), dl->node_scalar)
00033 {
00034 
00035   Teuchos::ParameterList* hyd_list = 
00036     p.get<Teuchos::ParameterList*>("Parameter List");
00037 
00038   Teuchos::RCP<const Teuchos::ParameterList> reflist = 
00039                this->getValidHydFractionParameters();
00040 
00041   hyd_list->validateParameters(*reflist, 0, 
00042     Teuchos::VALIDATE_USED_ENABLED, Teuchos::VALIDATE_DEFAULTS_DISABLED);
00043 
00044   std::string ebName = 
00045     p.get<std::string>("Element Block Name", "Missing");
00046 
00047   type = hyd_list->get("Material Parameters Type", "Block Dependent");
00048 
00049   if (type == "Block Dependent") 
00050   {
00051     // We have a multiple material problem and need to map element blocks to material data
00052 
00053     if(p.isType<Teuchos::RCP<QCAD::MaterialDatabase> >("MaterialDB")){
00054        materialDB = p.get< Teuchos::RCP<QCAD::MaterialDatabase> >("MaterialDB");
00055     }
00056     else {
00057        TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00058          std::endl <<
00059          "Error! Must specify a material database if using block dependent " << 
00060          "material properties" << std::endl);
00061     }
00062 
00063     // Get the sublist for thermal conductivity for the element block in the mat DB (the material in the
00064     // elem block ebName.
00065 
00066     {
00067 
00068     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "C_HHyd");
00069 
00070     std::string typ = subList.get("C_HHyd Type", "Constant");
00071 
00072     if (typ == "Constant") {
00073 
00074        C_HHyd = subList.get("Value", 0.0);
00075 
00076     }
00077     }
00078     {
00079 
00080     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "R");
00081 
00082     std::string typ = subList.get("R Type", "Constant");
00083 
00084     if (typ == "Constant") {
00085 
00086        R = subList.get("Value", 0.0);
00087 
00088     }
00089     }
00090     {
00091 
00092     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "CTSo");
00093 
00094     std::string typ = subList.get("CTSo Type", "Constant");
00095 
00096     if (typ == "Constant") {
00097 
00098        CTSo = subList.get("Value", 0.0);
00099 
00100     }
00101     }
00102     {
00103 
00104     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "delQ");
00105 
00106     std::string typ = subList.get("delQ Type", "Constant");
00107 
00108     if (typ == "Constant") {
00109 
00110        delQ = subList.get("Value", 0.0);
00111 
00112     }
00113     }
00114     {
00115 
00116     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "delWm");
00117 
00118     std::string typ = subList.get("delWm Type", "Constant");
00119 
00120     if (typ == "Constant") {
00121 
00122        delWm = subList.get("Value", 0.0);
00123 
00124     }
00125     }
00126     {
00127 
00128     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "stoi");
00129 
00130     std::string typ = subList.get("stoi Type", "Constant");
00131 
00132     if (typ == "Constant") {
00133 
00134        stoi = subList.get("Value", 0.0);
00135 
00136     }
00137     }
00138     {
00139 
00140     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "Vh");
00141 
00142     std::string typ = subList.get("Vh Type", "Constant");
00143 
00144     if (typ == "Constant") {
00145 
00146        Vh = subList.get("Value", 0.0);
00147 
00148     }
00149     }
00150     {
00151 
00152     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "delG");
00153 
00154     std::string typ = subList.get("delG Type", "Constant");
00155 
00156     if (typ == "Constant") {
00157 
00158        delG = subList.get("Value", 0.0);
00159 
00160     }
00161     }
00162   } // Block dependent
00163 
00164   else {
00165     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00166            "Must specify material parameters in the material database" << type);
00167   } 
00168 
00169 
00170   this->addDependentField(wBF);
00171   this->addDependentField(Temperature);
00172   this->addDependentField(Tdot);
00173   this->addDependentField(Fhdot);
00174   this->addDependentField(Fh);
00175   this->addDependentField(JThermCond);
00176   this->addDependentField(TGrad);
00177   this->addDependentField(wGradBF);
00178   this->addEvaluatedField(FhResidual);
00179 
00180   std::vector<PHX::DataLayout::size_type> dims;
00181   dl_->node_qp_vector->dimensions(dims);
00182   worksetSize = dims[0];
00183   numNodes = dims[1];
00184   numQPs  = dims[2];
00185   numDims = dims[3];
00186 
00187 
00188   // Allocate workspace
00189   JGrad.resize(dims[0], numQPs, numDims);
00190   fh_coef.resize(dims[0], numQPs, numDims);
00191   fh_time_term.resize(dims[0], numQPs, numDims);
00192   CHZr_coef.resize(dims[0], numQPs, numDims);
00193   CH_time_term.resize(dims[0], numQPs, numDims);
00194 
00195   this->setName("HydFractionResid"+PHX::TypeString<EvalT>::value);
00196 }
00197 
00198 //**********************************************************************
00199 template<typename EvalT, typename Traits>
00200 void HydFractionResid<EvalT, Traits>::
00201 postRegistrationSetup(typename Traits::SetupData d,
00202                       PHX::FieldManager<Traits>& fm)
00203 {
00204 
00205   this->utils.setFieldData(wBF,fm);
00206   this->utils.setFieldData(Temperature,fm);
00207   this->utils.setFieldData(Tdot,fm);
00208   this->utils.setFieldData(Fhdot,fm);
00209   this->utils.setFieldData(Fh,fm);
00210   this->utils.setFieldData(JThermCond,fm);
00211   this->utils.setFieldData(wGradBF,fm);
00212   this->utils.setFieldData(TGrad,fm);
00213 
00214   this->utils.setFieldData(FhResidual,fm);
00215 }
00216 
00217 //**********************************************************************
00218 template<typename EvalT, typename Traits>
00219 void HydFractionResid<EvalT, Traits>::
00220 evaluateFields(typename Traits::EvalData workset)
00221 {
00222 
00223   typedef Intrepid::FunctionSpaceTools FST;
00224 
00225   // First, multiply the coefficient (JThermConductivity) by the temperature gradient to get the JGrad field
00226 
00227   FST::scalarMultiplyDataData<ScalarT> (JGrad, JThermCond, TGrad);
00228 
00229   /* Now, integrate this JGrad term into the residual statement, which gives us the RHS term:
00230 
00231    JGrad = 0
00232 
00233   */
00234 
00235   FST::integrate<ScalarT>(FhResidual, JGrad, wGradBF, Intrepid::COMP_CPP, false); // "false" overwrites
00236 
00237   /*
00238      Now, build the coefficient for \partial f_H / \partial t
00239   */
00240 
00241     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00242       for (std::size_t qp=0; qp < numQPs; ++qp) {
00243          fh_coef(cell, qp) = C_HHyd - CTSo * std::exp(- delQ / (R * Temperature(cell, qp))) *
00244               std::exp(delWm / (stoi * R * Temperature(cell, qp))) * 
00245               std::exp(Vh * delG / (R * Temperature(cell, qp)));
00246       }
00247     }
00248 
00249     // multiply by Fhdot
00250 
00251     FST::scalarMultiplyDataData<ScalarT> (fh_time_term, fh_coef, Fhdot);
00252 
00253     // integrate and sum into residual
00254 
00255     FST::integrate<ScalarT>(FhResidual, fh_time_term, wBF, Intrepid::COMP_CPP, true); // "true" sums into
00256 
00257   /*
00258      Finally, build the coefficient for \partial C_H,Zr / \partial t
00259   */
00260 
00261     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00262       for (std::size_t qp=0; qp < numQPs; ++qp) {
00263          CHZr_coef(cell, qp) = -(delWm + stoi * Vh * delG) / (stoi * R * Temperature(cell, qp) * Temperature(cell, qp));
00264          CHZr_coef(cell, qp) *= CTSo * std::exp(- delQ / (R * Temperature(cell, qp))) *
00265               std::exp(delWm / (stoi * R * Temperature(cell, qp))) * 
00266               std::exp(Vh * delG / (R * Temperature(cell, qp)));
00267          CHZr_coef(cell, qp) *= (1.0 - Fh(cell, qp));
00268       }
00269     }
00270 
00271     // multiply by Tdot
00272 
00273     FST::scalarMultiplyDataData<ScalarT> (CH_time_term, CHZr_coef, Tdot);
00274 
00275     // integrate and sum into residual
00276 
00277     FST::integrate<ScalarT>(FhResidual, CH_time_term, wBF, Intrepid::COMP_CPP, true); // "true" sums into
00278 
00279 }
00280 
00281 // **********************************************************************
00282 template<typename EvalT,typename Traits>
00283 Teuchos::RCP<const Teuchos::ParameterList>
00284 HydFractionResid<EvalT, Traits>::
00285 getValidHydFractionParameters() const
00286 {
00287   Teuchos::RCP<Teuchos::ParameterList> validPL =
00288        rcp(new Teuchos::ParameterList("Valid Hyd Fraction Params"));;
00289 
00290   validPL->set<std::string>("C_HHyd Type", "Constant", 
00291                "Constant C_HHyd across the entire domain");
00292   validPL->set<std::string>("R Type", "Constant", 
00293                "Constant R across the entire domain");
00294   validPL->set<std::string>("CTSo Type", "Constant", 
00295                "Constant CTSo across the entire domain");
00296   validPL->set<std::string>("delQ Type", "Constant", 
00297                "Constant delQ across the entire domain");
00298   validPL->set<std::string>("delWm Type", "Constant", 
00299                "Constant delWm across the entire domain");
00300   validPL->set<std::string>("stoi Type", "Constant", 
00301                "Constant stoi across the entire domain");
00302   validPL->set<std::string>("Vh Type", "Constant", 
00303                "Constant Vh across the entire domain");
00304   validPL->set<std::string>("delG Type", "Constant", 
00305                "Constant delG across the entire domain");
00306   validPL->set<double>("Value", 1.0, "Constant material parameter value");
00307 
00308   return validPL;
00309 }
00310 
00311 
00312 //**********************************************************************
00313 }
00314 

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