00001
00002
00003
00004
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
00033
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
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
00062
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 }
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
00141
00142
00143
00144
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