www.mooseframework.org
CombinedCreepPlasticity.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
3 /* */
4 /* All contents are licensed under LGPL V2.1 */
5 /* See LICENSE for full restrictions */
6 /****************************************************************/
8 
9 #include "ReturnMappingModel.h"
11 
12 template <>
13 InputParameters
15 {
16  InputParameters params = validParams<ConstitutiveModel>();
17 
18  params.addRequiredParam<std::vector<std::string>>("submodels",
19  "List of submodel ConstitutiveModels");
20 
21  params.addParam<unsigned int>("max_its", 30, "Maximum number of submodel iterations");
22  params.addParam<bool>(
23  "output_iteration_info", false, "Set true to output submodel iteration information");
24  params.addParam<Real>(
25  "relative_tolerance", 1e-5, "Relative convergence tolerance for combined submodel iteration");
26  params.addParam<Real>(
27  "absolute_tolerance", 1e-5, "Absolute convergence tolerance for combined submodel iteration");
28  params.addClassDescription("Models creep and instantaneous plasticity deformation");
29 
30  return params;
31 }
32 
33 CombinedCreepPlasticity::CombinedCreepPlasticity(const InputParameters & parameters)
34  : ConstitutiveModel(parameters),
35  _submodels(),
36  _max_its(parameters.get<unsigned int>("max_its")),
37  _output_iteration_info(getParam<bool>("output_iteration_info")),
38  _relative_tolerance(parameters.get<Real>("relative_tolerance")),
39  _absolute_tolerance(parameters.get<Real>("absolute_tolerance")),
40  _matl_timestep_limit(declareProperty<Real>("matl_timestep_limit"))
41 {
42 }
43 
44 void
46 {
47  std::vector<SubdomainID> block_id =
48  std::vector<SubdomainID>(blockIDs().begin(), blockIDs().end());
49  const std::vector<std::string> & submodels = getParam<std::vector<std::string>>("submodels");
50  for (unsigned i(0); i < block_id.size(); ++i)
51  {
52  std::string suffix;
53  std::vector<MooseSharedPointer<Material>> const * mats_p;
54  if (_bnd)
55  {
56  mats_p = &_fe_problem.getMaterialWarehouse()[Moose::FACE_MATERIAL_DATA].getActiveBlockObjects(
57  block_id[i], _tid);
58  suffix = "_face";
59  }
60  else
61  mats_p = &_fe_problem.getMaterialWarehouse().getActiveBlockObjects(block_id[i], _tid);
62 
63  const std::vector<MooseSharedPointer<Material>> & mats = *mats_p;
64  for (unsigned int i_name(0); i_name < submodels.size(); ++i_name)
65  {
66  bool found = false;
67  for (unsigned int j = 0; j < mats.size(); ++j)
68  {
69  MooseSharedPointer<ReturnMappingModel> rmm =
70  MooseSharedNamespace::dynamic_pointer_cast<ReturnMappingModel>(mats[j]);
71  if (rmm && rmm->name() == submodels[i_name] + suffix)
72  {
73  _submodels[block_id[i]].push_back(rmm);
74  found = true;
75  break;
76  }
77  }
78  if (!found)
79  {
80  mooseError("Unable to find submodel " + submodels[i_name]);
81  }
82  }
83  }
84 
85  ConstitutiveModel::initialSetup();
86 }
87 
88 void
89 CombinedCreepPlasticity::computeStress(const Elem & current_elem,
90  const SymmElasticityTensor & elasticityTensor,
91  const SymmTensor & stress_old,
92  SymmTensor & strain_increment,
93  SymmTensor & stress_new)
94 {
95  // Given the stretching, compute the stress increment and add it to the old stress. Also update
96  // the creep strain
97  // stress = stressOld + stressIncrement
98  // creep_strain = creep_strainOld + creep_strainIncrement
99 
100  if (_t_step == 0 && !_app.isRestarting())
101  return;
102 
103  if (_output_iteration_info == true)
104  {
105  _console << std::endl
106  << "iteration output for CombinedCreepPlasticity solve:"
107  << " time=" << _t << " temperature=" << _temperature[_qp] << " int_pt=" << _qp
108  << std::endl;
109  }
110 
111  // compute trial stress
112  stress_new = elasticityTensor * strain_increment;
113  stress_new += stress_old;
114 
115  const SubdomainID current_block = current_elem.subdomain_id();
116  const std::vector<MooseSharedPointer<ReturnMappingModel>> & rmm(_submodels[current_block]);
117  const unsigned num_submodels = rmm.size();
118 
119  SymmTensor inelastic_strain_increment;
120 
121  SymmTensor elastic_strain_increment;
122  SymmTensor stress_new_last(stress_new);
123  Real delS(_absolute_tolerance + 1);
124  Real first_delS(delS);
125  unsigned int counter(0);
126 
127  for (unsigned i_rmm(0); i_rmm < num_submodels; ++i_rmm)
128  rmm[i_rmm]->setQp(_qp);
129 
130  while (counter < _max_its && delS > _absolute_tolerance &&
131  (delS / first_delS) > _relative_tolerance && (num_submodels != 1 || counter < 1))
132  {
133  elastic_strain_increment = strain_increment;
134  stress_new = elasticityTensor * (elastic_strain_increment - inelastic_strain_increment);
135  stress_new += stress_old;
136 
137  for (unsigned i_rmm(0); i_rmm < num_submodels; ++i_rmm)
138  {
139  rmm[i_rmm]->computeStress(current_elem,
140  elasticityTensor,
141  stress_old,
142  elastic_strain_increment,
143  stress_new,
144  inelastic_strain_increment);
145  }
146 
147  // now check convergence
148  SymmTensor deltaS(stress_new_last - stress_new);
149  delS = std::sqrt(deltaS.doubleContraction(deltaS));
150  if (counter == 0)
151  {
152  first_delS = delS;
153  }
154  stress_new_last = stress_new;
155 
156  if (_output_iteration_info == true)
157  {
158  _console << "stress_it=" << counter
159  << " rel_delS=" << (0 == first_delS ? 0 : delS / first_delS)
160  << " rel_tol=" << _relative_tolerance << " abs_delS=" << delS
161  << " abs_tol=" << _absolute_tolerance << std::endl;
162  }
163 
164  ++counter;
165  }
166 
167  if (counter == _max_its && delS > _absolute_tolerance &&
168  (delS / first_delS) > _relative_tolerance)
169  {
170  mooseError("Max stress iteration hit during CombinedCreepPlasticity solve!");
171  }
172 
173  strain_increment = elastic_strain_increment;
174 
175  _matl_timestep_limit[_qp] = 0.0;
176  for (unsigned i_rmm(0); i_rmm < num_submodels; ++i_rmm)
177  _matl_timestep_limit[_qp] += 1.0 / rmm[i_rmm]->computeTimeStepLimit();
178 
179  _matl_timestep_limit[_qp] = 1.0 / _matl_timestep_limit[_qp];
180 }
181 
182 bool
184  SymmTensor & strain_increment,
185  SymmTensor & d_strain_dT)
186 {
187  bool modified = false;
188  const SubdomainID current_block = current_elem.subdomain_id();
189  const std::vector<MooseSharedPointer<ReturnMappingModel>> & rmm(_submodels[current_block]);
190  const unsigned num_submodels = rmm.size();
191 
192  for (unsigned i_rmm(0); i_rmm < num_submodels; ++i_rmm)
193  {
194  rmm[i_rmm]->setQp(_qp);
195  modified |= rmm[i_rmm]->modifyStrainIncrement(current_elem, strain_increment, d_strain_dT);
196  }
197  return modified;
198 }
This class defines a basic set of capabilities any elasticity tensor should have. ...
std::map< SubdomainID, std::vector< MooseSharedPointer< ReturnMappingModel > > > _submodels
InputParameters validParams< CombinedCreepPlasticity >()
const VariableValue & _temperature
Base class for models that perform return mapping iterations to compute stress.
CombinedCreepPlasticity(const InputParameters &parameters)
MaterialProperty< Real > & _matl_timestep_limit
virtual bool modifyStrainIncrement(const Elem &current_elem, SymmTensor &strain_increment, SymmTensor &d_strain_dT)
InputParameters validParams< ConstitutiveModel >()
Real doubleContraction(const SymmTensor &rhs) const
Definition: SymmTensor.h:257
void setQp(unsigned int qp)
Sets the value of the variable _qp for inheriting classes.
static unsigned int counter
virtual void computeStress(const Elem &current_elem, const SymmElasticityTensor &elasticityTensor, const SymmTensor &stress_old, SymmTensor &strain_increment, SymmTensor &stress_new)
Compute the stress (sigma += deltaSigma)