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
00012 template<typename EvalT, typename Traits>
00013 PHAL::TEProp<EvalT, Traits>::
00014 TEProp(Teuchos::ParameterList& p) :
00015 rhoCp(p.get<std::string>("QP Variable Name 3"),
00016 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout")),
00017 permittivity(p.get<std::string>("QP Variable Name 2"),
00018 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout")),
00019 thermalCond(p.get<std::string>("QP Variable Name"),
00020 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout")),
00021 Temp(p.get<std::string>("Temperature Variable Name"),
00022 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout")),
00023 coordVec(p.get<std::string>("Coordinate Vector Name"),
00024 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout"))
00025 {
00026 Teuchos::ParameterList* teprop_list =
00027 p.get<Teuchos::ParameterList*>("Parameter List");
00028
00029 Teuchos::RCP<PHX::DataLayout> scalar_dl =
00030 p.get< Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout");
00031 Teuchos::RCP<PHX::DataLayout> vector_dl =
00032 p.get< Teuchos::RCP<PHX::DataLayout> >("QP Vector Data Layout");
00033 std::vector<PHX::DataLayout::size_type> dims;
00034 vector_dl->dimensions(dims);
00035 numQPs = dims[1];
00036 numDims = dims[2];
00037
00038 mats = teprop_list->get<int>("Number of Materials");;
00039
00040 Teuchos::Array<double> dbl_elecCs = Teuchos::getArrayFromStringParameter<double> (*teprop_list,
00041 "Electrical Conductivity", mats, true);
00042 elecCs.resize(dbl_elecCs.size());
00043 for (int i=0; i<dbl_elecCs.size(); i++) elecCs[i] = dbl_elecCs[i];
00044
00045 thermCs = Teuchos::getArrayFromStringParameter<double> (*teprop_list,
00046 "Thermal Conductivity", mats, true);
00047 rhoCps = Teuchos::getArrayFromStringParameter<double> (*teprop_list,
00048 "Rho Cp", mats, true);
00049 factor = Teuchos::getArrayFromStringParameter<double> (*teprop_list,
00050 "Coupling Factor", mats, true);
00051 xBounds = Teuchos::getArrayFromStringParameter<double> (*teprop_list,
00052 "X Bounds", mats+1, true);
00053
00054
00055 Teuchos::RCP<ParamLib> paramLib =
00056 p.get< Teuchos::RCP<ParamLib> >("Parameter Library", Teuchos::null);
00057
00058 for (int i=0; i<mats; i++) {
00059 std::stringstream ss;
00060 ss << "Electrical Conductivity of Material " << i;
00061 new Sacado::ParameterRegistration<EvalT, SPL_Traits>(ss.str(), this, paramLib);
00062 }
00063
00064
00065 this->addDependentField(Temp);
00066 this->addDependentField(coordVec);
00067 this->addEvaluatedField(rhoCp);
00068 this->addEvaluatedField(permittivity);
00069 this->addEvaluatedField(thermalCond);
00070 this->setName("TEProp"+PHX::TypeString<EvalT>::value);
00071 }
00072
00073
00074 template<typename EvalT, typename Traits>
00075 void PHAL::TEProp<EvalT, Traits>::
00076 postRegistrationSetup(typename Traits::SetupData d,
00077 PHX::FieldManager<Traits>& fm)
00078 {
00079 this->utils.setFieldData(permittivity,fm);
00080 this->utils.setFieldData(thermalCond,fm);
00081 this->utils.setFieldData(rhoCp,fm);
00082 this->utils.setFieldData(coordVec,fm);
00083 this->utils.setFieldData(Temp,fm);
00084 }
00085
00086
00087 template<typename EvalT, typename Traits>
00088 void PHAL::TEProp<EvalT, Traits>::
00089 evaluateFields(typename Traits::EvalData workset)
00090 {
00091 unsigned int numCells = workset.numCells;
00092
00093 for (std::size_t cell=0; cell < numCells; ++cell) {
00094 for (std::size_t qp=0; qp < numQPs; ++qp) {
00095 int mat = whichMat(coordVec(cell,qp,0));
00096 permittivity(cell,qp) = elecCs[mat] / (1.0 + factor[mat] * Temp(cell,qp));
00097 thermalCond(cell,qp) = thermCs[mat];
00098 rhoCp(cell,qp) = rhoCps[mat];
00099 }
00100 }
00101 }
00102
00103
00104 template<typename EvalT, typename Traits>
00105 int PHAL::TEProp<EvalT, Traits>::
00106 whichMat(const MeshScalarT& x)
00107 {
00108 TEUCHOS_TEST_FOR_EXCEPTION(x<xBounds[0] || x>xBounds[mats], std::logic_error,
00109 "Quadrature point " << x << " not within bounds \n");
00110 for (int i=0; i<mats; i++)
00111 if (x<xBounds[i+1]) return i;
00112 TEUCHOS_TEST_FOR_EXCEPTION(true, std::logic_error,
00113 "Quadrature point " << x << " not within bounds \n");
00114 return -1;
00115 }
00116
00117 template<typename EvalT,typename Traits>
00118 typename PHAL::TEProp<EvalT,Traits>::ScalarT&
00119 PHAL::TEProp<EvalT,Traits>::getValue(const std::string &n)
00120 {
00121 int mat;
00122 for (int i=0; i<mats; i++) {
00123 std::stringstream ss;
00124 ss << "Electrical Conductivity of Material " << i;
00125 if (n == ss.str()) { mat=i; break; }
00126 }
00127 return elecCs[mat];
00128 }
00129
00130
00131