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

JThermConductivity_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 namespace PHAL {
00014 
00015 template<typename EvalT, typename Traits>
00016 JThermConductivity<EvalT, Traits>::
00017 JThermConductivity(Teuchos::ParameterList& p,
00018       const Teuchos::RCP<Albany::Layouts>& dl) :
00019   dl_(dl),
00020 
00021   Temperature (p.get<std::string>                   ("Temperature Name"), dl->qp_scalar),
00022   thermalCond(p.get<std::string>("QP Variable Name"), dl->qp_scalar)
00023 
00024 {
00025 
00026   Teuchos::ParameterList* cond_list = 
00027     p.get<Teuchos::ParameterList*>("Parameter List");
00028 
00029   Teuchos::RCP<const Teuchos::ParameterList> reflist = 
00030                this->getValidJThermCondParameters();
00031 
00032   // Check the parameters contained in the input file. Do not check the defaults
00033   // set programmatically
00034   cond_list->validateParameters(*reflist, 0, 
00035     Teuchos::VALIDATE_USED_ENABLED, Teuchos::VALIDATE_DEFAULTS_DISABLED);
00036 
00037   std::vector<PHX::DataLayout::size_type> dims;
00038   dl_->qp_vector->dimensions(dims);
00039   numQPs  = dims[1];
00040   numDims = dims[2];
00041 
00042   std::string ebName = 
00043     p.get<std::string>("Element Block Name", "Missing");
00044 
00045   type = cond_list->get("Material Parameters Type", "Block Dependent");
00046 
00047   if (type == "Block Dependent") 
00048   {
00049     // We have a multiple material problem and need to map element blocks to material data
00050 
00051     if(p.isType<Teuchos::RCP<QCAD::MaterialDatabase> >("MaterialDB")){
00052        materialDB = p.get< Teuchos::RCP<QCAD::MaterialDatabase> >("MaterialDB");
00053     }
00054     else {
00055        TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00056          std::endl <<
00057          "Error! Must specify a material database if using block dependent " << 
00058          "material properties" << std::endl);
00059     }
00060 
00061     // Get the sublist for thermal conductivity for the element block in the mat DB (the material in the
00062     // elem block ebName.
00063     {
00064 
00065     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "Q_h");
00066 
00067     std::string typ = subList.get("Q_h Type", "Constant");
00068 
00069     if (typ == "Constant") {
00070 
00071        Qh = subList.get("Value", 0.0);
00072 
00073     }
00074     }
00075     {
00076 
00077     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "R");
00078 
00079     std::string typ = subList.get("R Type", "Constant");
00080 
00081     if (typ == "Constant") {
00082 
00083        R = subList.get("Value", 0.0);
00084 
00085     }
00086     }
00087     {
00088 
00089     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "C_{H,Tot}");
00090 
00091     std::string typ = subList.get("C_{H,Tot} Type", "Constant");
00092 
00093     if (typ == "Constant") {
00094 
00095        Cht = subList.get("Value", 0.0);
00096 
00097     }
00098     }
00099     {
00100 
00101     Teuchos::ParameterList& subList = materialDB->getElementBlockSublist(ebName, "Vbar");
00102 
00103     std::string typ = subList.get("Vbar Type", "Constant");
00104 
00105     if (typ == "Constant") {
00106 
00107        Vbar = subList.get("Value", 0.0);
00108 
00109     }
00110     }
00111   } // Block dependent
00112 
00113   else {
00114     TEUCHOS_TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00115            "Must specify material parameters in the material database" << type);
00116   } 
00117 
00118   this->addEvaluatedField(thermalCond);
00119   this->addDependentField(Temperature);
00120   this->setName("JTherm Conductivity"+PHX::TypeString<EvalT>::value);
00121 }
00122 
00123 // **********************************************************************
00124 template<typename EvalT, typename Traits>
00125 void JThermConductivity<EvalT, Traits>::
00126 postRegistrationSetup(typename Traits::SetupData d,
00127                       PHX::FieldManager<Traits>& fm)
00128 {
00129   this->utils.setFieldData(thermalCond,fm);
00130   this->utils.setFieldData(Temperature,fm);
00131 }
00132 
00133 // **********************************************************************
00134 template<typename EvalT, typename Traits>
00135 void JThermConductivity<EvalT, Traits>::
00136 evaluateFields(typename Traits::EvalData workset)
00137 {
00138 
00139 /*
00140   Here we calculate the qp values for the multiplier to the Grad T term, i.e.
00141 
00142   [ R \log{(C_{H, Tot} \bar{V})} - Q_H / T ]
00143 
00144   The result of this eval at each qp goes into thermalCond()
00145 */
00146 
00147     for (std::size_t cell=0; cell < workset.numCells; ++cell) {
00148       for (std::size_t qp=0; qp < numQPs; ++qp) {
00149          thermalCond(cell, qp) = R * std::log(Cht * Vbar) - Qh / Temperature(cell, qp);
00150       }
00151     }
00152 
00153 }
00154 
00155 // **********************************************************************
00156 template<typename EvalT,typename Traits>
00157 Teuchos::RCP<const Teuchos::ParameterList>
00158 JThermConductivity<EvalT,Traits>::getValidJThermCondParameters() const
00159 {
00160   Teuchos::RCP<Teuchos::ParameterList> validPL =
00161        rcp(new Teuchos::ParameterList("Valid JTherm Conductivity Params"));;
00162 
00163   validPL->set<std::string>("Qh Type", "Constant", 
00164                "Constant Qh across the entire domain");
00165   validPL->set<std::string>("R Type", "Constant", 
00166                "Constant R across the entire domain");
00167   validPL->set<std::string>("C_{H,Tot} Type", "Constant", 
00168                "Constant C_{H,Tot} across the entire domain");
00169   validPL->set<std::string>("Vbar Type", "Constant", 
00170                "Constant Vbar across the entire domain");
00171   validPL->set<double>("Value", 1.0, "Constant material parameter value");
00172 
00173   return validPL;
00174 }
00175 
00176 // **********************************************************************
00177 // **********************************************************************
00178 }
00179 

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