00001
00002
00003
00004
00005
00006
00007 #include <Teuchos_TestForException.hpp>
00008 #include <Phalanx_DataLayout.hpp>
00009 #include <Intrepid_MiniTensor.h>
00010
00011 namespace LCM
00012 {
00013
00014
00015 template<typename EvalT, typename Traits>
00016 ThermoMechanicalCoefficients<EvalT, Traits>::
00017 ThermoMechanicalCoefficients(Teuchos::ParameterList& p,
00018 const Teuchos::RCP<Albany::Layouts>& dl) :
00019 temperature_(p.get < std::string > ("Temperature Name"), dl->qp_scalar),
00020 temperature_dot_(p.get < std::string > ("Temperature Dot Name"),
00021 dl->qp_scalar),
00022 delta_time_(p.get < std::string > ("Delta Time Name"),
00023 dl->workset_scalar),
00024 thermal_cond_(p.get < std::string > ("Thermal Conductivity Name"),
00025 dl->qp_scalar),
00026 thermal_transient_coeff_(
00027 p.get < std::string > ("Thermal Transient Coefficient Name"),
00028 dl->qp_scalar),
00029 thermal_diffusivity_(p.get < std::string > ("Thermal Diffusivity Name"),
00030 dl->qp_tensor),
00031 have_mech_(p.get<bool>("Have Mechanics", false))
00032 {
00033
00034 Teuchos::ParameterList* mat_params =
00035 p.get<Teuchos::ParameterList*>("Material Parameters");
00036
00037 transient_coeff_ = mat_params->get<RealType>("Thermal Transient Coefficient");
00038 heat_capacity_ = mat_params->get<RealType>("Heat Capacity");
00039 density_ = mat_params->get<RealType>("Density");
00040
00041 this->addDependentField(temperature_);
00042 this->addDependentField(thermal_cond_);
00043 this->addDependentField(delta_time_);
00044
00045 this->addEvaluatedField(thermal_transient_coeff_);
00046 this->addEvaluatedField(thermal_diffusivity_);
00047 this->addEvaluatedField(temperature_dot_);
00048
00049 this->setName(
00050 "ThermoMechanical Coefficients" + PHX::TypeString < EvalT > ::value);
00051
00052 std::vector<PHX::DataLayout::size_type> dims;
00053 dl->qp_tensor->dimensions(dims);
00054 num_pts_ = dims[1];
00055 num_dims_ = dims[2];
00056
00057 if (have_mech_) {
00058 PHX::MDField<ScalarT,Cell,QuadPoint,Dim,Dim>
00059 temp_def_grad(p.get < std::string > ("Deformation Gradient Name"),
00060 dl->qp_tensor);
00061 def_grad_ = temp_def_grad;
00062 this->addDependentField(def_grad_);
00063 }
00064
00065 temperature_name_ = p.get<std::string>("Temperature Name")+"_old";
00066 }
00067
00068
00069 template<typename EvalT, typename Traits>
00070 void ThermoMechanicalCoefficients<EvalT, Traits>::
00071 postRegistrationSetup(typename Traits::SetupData d,
00072 PHX::FieldManager<Traits>& fm)
00073 {
00074 this->utils.setFieldData(temperature_, fm);
00075 this->utils.setFieldData(temperature_dot_, fm);
00076 this->utils.setFieldData(delta_time_, fm);
00077 this->utils.setFieldData(thermal_cond_, fm);
00078 this->utils.setFieldData(thermal_transient_coeff_, fm);
00079 this->utils.setFieldData(thermal_diffusivity_, fm);
00080 if (have_mech_) {
00081 this->utils.setFieldData(def_grad_, fm);
00082 }
00083 }
00084
00085
00086 template<typename EvalT, typename Traits>
00087 void ThermoMechanicalCoefficients<EvalT, Traits>::
00088 evaluateFields(typename Traits::EvalData workset)
00089 {
00090 Intrepid::Tensor<ScalarT> diffusivity(num_dims_);
00091 Intrepid::Tensor<ScalarT> I(Intrepid::eye<ScalarT>(num_dims_));
00092 Intrepid::Tensor<ScalarT> tensor;
00093 Intrepid::Tensor<ScalarT> F(num_dims_);
00094
00095 ScalarT dt = delta_time_(0);
00096 if (dt == 0.0) dt = 1.e-15;
00097 Albany::MDArray temperature_old = (*workset.stateArrayPtr)[temperature_name_];
00098 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00099 for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00100 temperature_dot_(cell,pt) =
00101 (temperature_(cell,pt) - temperature_old(cell,pt)) / dt;
00102 }
00103 }
00104
00105 if (have_mech_) {
00106 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00107 for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00108 F.fill(&def_grad_(cell, pt, 0, 0));
00109 tensor = Intrepid::inverse(Intrepid::transpose(F) * F);
00110 thermal_transient_coeff_(cell, pt) = transient_coeff_;
00111 diffusivity = thermal_cond_(cell, pt) / (density_ * heat_capacity_)
00112 * tensor;
00113 for (int i = 0; i < num_dims_; ++i) {
00114 for (int j = 0; j < num_dims_; ++j) {
00115 thermal_diffusivity_(cell, pt, i, j) = diffusivity(i, j);
00116 }
00117 }
00118 }
00119 }
00120 } else {
00121 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00122 for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00123 thermal_transient_coeff_(cell, pt) = transient_coeff_;
00124 diffusivity = thermal_cond_(cell, pt) / (density_ * heat_capacity_) * I;
00125 for (int i = 0; i < num_dims_; ++i) {
00126 for (int j = 0; j < num_dims_; ++j) {
00127 thermal_diffusivity_(cell, pt, i, j) = diffusivity(i, j);
00128 }
00129 }
00130 }
00131 }
00132 }
00133 }
00134
00135 }
00136