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 DamageCoefficients<EvalT, Traits>::
00017 DamageCoefficients(Teuchos::ParameterList& p,
00018 const Teuchos::RCP<Albany::Layouts>& dl) :
00019 damage_(p.get<std::string>("Damage Name"), dl->qp_scalar),
00020 delta_time_(p.get<std::string>("Delta Time Name"), dl->workset_scalar),
00021 damage_transient_coeff_(p.get<std::string>("Damage Transient Coefficient Name"),
00022 dl->qp_scalar),
00023 damage_diffusivity_(p.get<std::string>("Damage Diffusivity Name"),
00024 dl->qp_tensor),
00025 damage_dot_(p.get<std::string>("Damage Dot Name"), dl->qp_scalar),
00026 have_mech_(p.get<bool>("Have Mechanics", false))
00027 {
00028
00029 Teuchos::ParameterList* mat_params =
00030 p.get<Teuchos::ParameterList*>("Material Parameters");
00031
00032 transient_coeff_ = mat_params->get<RealType>("Damage Transient Coefficient");
00033 diffusivity_coeff_ = mat_params->get<RealType>("Damage Diffusivity Coefficient");
00034
00035 this->addDependentField(damage_);
00036 this->addDependentField(delta_time_);
00037
00038 this->addEvaluatedField(damage_transient_coeff_);
00039 this->addEvaluatedField(damage_diffusivity_);
00040 this->addEvaluatedField(damage_dot_);
00041
00042 this->setName("Damage Coefficients" + PHX::TypeString<EvalT>::value);
00043
00044 std::vector<PHX::DataLayout::size_type> dims;
00045 dl->qp_tensor->dimensions(dims);
00046 num_pts_ = dims[1];
00047 num_dims_ = dims[2];
00048
00049 if (have_mech_) {
00050 PHX::MDField<ScalarT, Cell, QuadPoint, Dim, Dim>
00051 temp_def_grad(p.get<std::string>("Deformation Gradient Name"),
00052 dl->qp_tensor);
00053 def_grad_ = temp_def_grad;
00054 this->addDependentField(def_grad_);
00055 }
00056 damage_name_ = p.get<std::string>("Damage Name")+"_old";
00057 }
00058
00059
00060 template<typename EvalT, typename Traits>
00061 void DamageCoefficients<EvalT, Traits>::
00062 postRegistrationSetup(typename Traits::SetupData d,
00063 PHX::FieldManager<Traits>& fm)
00064 {
00065 this->utils.setFieldData(damage_, fm);
00066 this->utils.setFieldData(damage_dot_, fm);
00067 this->utils.setFieldData(delta_time_, fm);
00068 this->utils.setFieldData(damage_transient_coeff_, fm);
00069 this->utils.setFieldData(damage_diffusivity_, fm);
00070 if (have_mech_) {
00071 this->utils.setFieldData(def_grad_, fm);
00072 }
00073 }
00074
00075
00076 template<typename EvalT, typename Traits>
00077 void DamageCoefficients<EvalT, Traits>::
00078 evaluateFields(typename Traits::EvalData workset)
00079 {
00080 Intrepid::Tensor<ScalarT> diffusivity(num_dims_);
00081 Intrepid::Tensor<ScalarT> I(Intrepid::eye<ScalarT>(num_dims_));
00082 Intrepid::Tensor<ScalarT> tensor;
00083 Intrepid::Tensor<ScalarT> F(num_dims_);
00084
00085 ScalarT dt = delta_time_(0);
00086 if (dt == 0.0) dt = 1.e-15;
00087 Albany::MDArray damage_old = (*workset.stateArrayPtr)[damage_name_];
00088 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00089 for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00090 damage_dot_(cell,pt) =
00091 (damage_(cell,pt) - damage_old(cell,pt)) / dt;
00092 }
00093 }
00094
00095 if (have_mech_) {
00096 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00097 for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00098 F.fill(&def_grad_(cell, pt, 0, 0));
00099 tensor = Intrepid::inverse(Intrepid::transpose(F) * F);
00100 damage_transient_coeff_(cell, pt) = transient_coeff_;
00101 diffusivity = diffusivity_coeff_ * tensor;
00102 for (int i = 0; i < num_dims_; ++i) {
00103 for (int j = 0; j < num_dims_; ++j) {
00104 damage_diffusivity_(cell, pt, i, j) = diffusivity(i, j);
00105 }
00106 }
00107 }
00108 }
00109 } else {
00110 for (std::size_t cell = 0; cell < workset.numCells; ++cell) {
00111 for (std::size_t pt = 0; pt < num_pts_; ++pt) {
00112 damage_transient_coeff_(cell, pt) = transient_coeff_;
00113 diffusivity = diffusivity_coeff_ * I;
00114 for (int i = 0; i < num_dims_; ++i) {
00115 for (int j = 0; j < num_dims_; ++j) {
00116 damage_diffusivity_(cell, pt, i, j) = diffusivity(i, j);
00117 }
00118 }
00119 }
00120 }
00121 }
00122 }
00123
00124 }
00125