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 #include <typeinfo>
00014
00015 namespace LCM {
00016
00017 template<typename EvalT, typename Traits>
00018 DamageSource<EvalT, Traits>::
00019 DamageSource(Teuchos::ParameterList& p) :
00020 bulkModulus (p.get<std::string>("Bulk Modulus Name"),
00021 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00022 dp (p.get<std::string>("DP Name"),
00023 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00024 seff (p.get<std::string>("Effective Stress Name"),
00025 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00026 energy (p.get<std::string>("Energy Name"),
00027 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00028 J (p.get<std::string>("DetDefGrad Name"),
00029 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00030 damageLS (p.get<std::string>("Damage Length Scale Name"),
00031 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00032 gc (p.get<double>("gc Name")),
00033 damage (p.get<std::string>("Damage Name"),
00034 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") ),
00035 source (p.get<std::string>("Damage Source Name"),
00036 p.get<Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout") )
00037 {
00038 Teuchos::RCP<PHX::DataLayout> scalar_dl =
00039 p.get< Teuchos::RCP<PHX::DataLayout> >("QP Scalar Data Layout");
00040 std::vector<PHX::DataLayout::size_type> dims;
00041 scalar_dl->dimensions(dims);
00042 numQPs = dims[1];
00043
00044 Teuchos::RCP<ParamLib> paramLib =
00045 p.get< Teuchos::RCP<ParamLib> >("Parameter Library", Teuchos::null);
00046
00047
00048 this->addDependentField(bulkModulus);
00049 this->addDependentField(dp);
00050 this->addDependentField(J);
00051 this->addDependentField(damage);
00052 this->addDependentField(seff);
00053 this->addDependentField(energy);
00054 this->addDependentField(damageLS);
00055
00056 sourceName = p.get<std::string>("Damage Source Name")+"_old";
00057 damageName = p.get<std::string>("Damage Name")+"_old";
00058 this->addEvaluatedField(source);
00059 this->setName("Damage Source"+PHX::TypeString<EvalT>::value);
00060 }
00061
00062
00063 template<typename EvalT, typename Traits>
00064 void DamageSource<EvalT, Traits>::
00065 postRegistrationSetup(typename Traits::SetupData d,
00066 PHX::FieldManager<Traits>& fm)
00067 {
00068 this->utils.setFieldData(bulkModulus,fm);
00069 this->utils.setFieldData(dp,fm);
00070 this->utils.setFieldData(J,fm);
00071 this->utils.setFieldData(damage,fm);
00072 this->utils.setFieldData(damageLS,fm);
00073 this->utils.setFieldData(seff,fm);
00074 this->utils.setFieldData(energy,fm);
00075 this->utils.setFieldData(source,fm);
00076 }
00077
00078
00079 template<typename EvalT, typename Traits>
00080 void DamageSource<EvalT, Traits>::
00081 evaluateFields(typename Traits::EvalData workset)
00082 {
00083 bool print = false;
00084
00085
00086
00087
00088
00089 Albany::MDArray source_old_FC = (*workset.stateArrayPtr)[sourceName];
00090 Albany::MDArray damage_old_FC = (*workset.stateArrayPtr)[damageName];
00091
00092
00093 ScalarT p, triax, source_new, term;
00094 RealType damage_old, source_old;
00095
00096 for (std::size_t cell=0; cell < workset.numCells; ++cell)
00097 {
00098 for (std::size_t qp=0; qp < numQPs; ++qp)
00099 {
00100 source_old = source_old_FC(cell,qp);
00101 damage_old = damage_old_FC(cell,qp);
00102 ScalarT fac = 1.0 / ( 1.0 - damage(cell,qp) );
00103 p = 0.5 * bulkModulus(cell,qp) * (J(cell,qp) - (1.0/J(cell,qp)));
00104 triax = 0.0;
00105 if (seff(cell,qp) > 0.0) triax = p/seff(cell,qp);
00106
00107 source_new = - (damage(cell,qp) * gc) / damageLS(cell,qp)
00108 + 2.0 * (1.0 - damage(cell,qp)) * energy(cell,qp)
00109 + fac * triax * dp(cell,qp);
00110 term = 1.0*(std::abs(damage(cell,qp)-damage_old)
00111 - (damage(cell,qp)-damage_old) );
00112 source_new += term;
00113 if (print)
00114 {
00115 std::cout << "!*********!" << std::endl;
00116 std::cout << "damage : " << damage(cell,qp) << std::endl;
00117 std::cout << "damage_old: " << damage_old << std::endl;
00118 std::cout << "energy : " << energy(cell,qp) << std::endl;
00119 std::cout << "J : " << J(cell,qp) << std::endl;
00120 std::cout << "seff : " << seff(cell,qp) << std::endl;
00121 std::cout << "p : " << p << std::endl;
00122 std::cout << "triax : " << triax << std::endl;
00123 std::cout << "dp : " << dp(cell,qp) << std::endl;
00124 std::cout << "term : " << term << std::endl;
00125 std::cout << "source_old: " << source_old << std::endl;
00126 std::cout << "source_new: " << source_new << std::endl;
00127 }
00128
00129 source(cell,qp) = source_new;
00130 }
00131 }
00132 }
00133
00134
00135 }
00136