www.mooseframework.org
Public Member Functions | Private Attributes | List of all members
SolidMechanicsAction Class Reference

#include <SolidMechanicsAction.h>

Inheritance diagram for SolidMechanicsAction:
[legend]

Public Member Functions

 SolidMechanicsAction (const InputParameters &params)
 
virtual void act ()
 

Private Attributes

const NonlinearVariableName _disp_x
 
const NonlinearVariableName _disp_y
 
const NonlinearVariableName _disp_z
 
const NonlinearVariableName _disp_r
 
const NonlinearVariableName _temp
 
const Real _zeta
 
const Real _alpha
 

Detailed Description

Definition at line 21 of file SolidMechanicsAction.h.

Constructor & Destructor Documentation

◆ SolidMechanicsAction()

SolidMechanicsAction::SolidMechanicsAction ( const InputParameters &  params)

Definition at line 64 of file SolidMechanicsAction.C.

65  : Action(params),
66  _disp_x(getParam<NonlinearVariableName>("disp_x")),
67  _disp_y(getParam<NonlinearVariableName>("disp_y")),
68  _disp_z(getParam<NonlinearVariableName>("disp_z")),
69  _disp_r(getParam<NonlinearVariableName>("disp_r")),
70  _temp(getParam<NonlinearVariableName>("temp")),
71  _zeta(getParam<Real>("zeta")),
72  _alpha(getParam<Real>("alpha"))
73 {
74 }
const NonlinearVariableName _disp_x
const NonlinearVariableName _disp_r
const NonlinearVariableName _disp_z
const NonlinearVariableName _temp
const NonlinearVariableName _disp_y

Member Function Documentation

◆ act()

void SolidMechanicsAction::act ( )
virtual

Definition at line 77 of file SolidMechanicsAction.C.

78 {
79  // list of subdomains IDs per coordinate system
80  std::map<Moose::CoordinateSystemType, std::vector<SubdomainName>> coord_map;
81  std::set<SubdomainID> subdomains;
82 
83  if (isParamValid("block")) // Should it be restricted to certain blocks?
84  {
85  Moose::out << "Restricting to blocks!" << std::endl;
86  std::vector<SubdomainName> block = getParam<std::vector<SubdomainName>>("block");
87  for (unsigned int i = 0; i < block.size(); i++)
88  subdomains.insert(_problem->mesh().getSubdomainID(block[i]));
89  }
90  else // Put it everywhere
91  subdomains = _problem->mesh().meshSubdomains();
92 
93  for (std::set<SubdomainID>::const_iterator it = subdomains.begin(); it != subdomains.end(); ++it)
94  {
95  SubdomainID sid = *it;
96  Moose::CoordinateSystemType coord_type = _problem->getCoordSystem(sid);
97 
98  // Convert the SubdomainID into SubdomainName since kernel params take SubdomainNames (this is
99  // retarded...)
100  std::stringstream ss;
101  ss << sid;
102  SubdomainName sname = ss.str();
103 
104  coord_map[coord_type].push_back(sname);
105  }
106 
107  for (std::map<Moose::CoordinateSystemType, std::vector<SubdomainName>>::iterator it =
108  coord_map.begin();
109  it != coord_map.end();
110  ++it)
111  {
112  Moose::CoordinateSystemType coord_type = (*it).first;
113  std::vector<SubdomainName> & blocks = (*it).second;
114 
115  // Determine whether RZ or RSPHERICAL
116  bool rz(false);
117  bool rspherical(false);
118  unsigned int dim(1);
119  std::vector<std::string> keys;
120  std::vector<VariableName> vars;
121  std::vector<std::vector<AuxVariableName>> save_in;
122  std::vector<std::vector<AuxVariableName>> diag_save_in;
123  std::string type("StressDivergence");
124  if (getParam<MooseEnum>("type") == 0) // truss
125  {
126  type = "StressDivergenceTruss";
127  }
128  else if (coord_type == Moose::COORD_RZ)
129  {
130  rz = true;
131  type = "StressDivergenceRZ";
132  dim = 2;
133  keys.push_back("disp_r");
134  keys.push_back("disp_z");
135  vars.push_back(_disp_r);
136  vars.push_back(_disp_z);
137  save_in.resize(dim);
138  if (isParamValid("save_in_disp_r"))
139  save_in[0] = getParam<std::vector<AuxVariableName>>("save_in_disp_r");
140 
141  if (isParamValid("save_in_disp_z"))
142  save_in[1] = getParam<std::vector<AuxVariableName>>("save_in_disp_z");
143 
144  diag_save_in.resize(dim);
145  if (isParamValid("diag_save_in_disp_r"))
146  diag_save_in[0] = getParam<std::vector<AuxVariableName>>("diag_save_in_disp_r");
147 
148  if (isParamValid("diag_save_in_disp_z"))
149  diag_save_in[1] = getParam<std::vector<AuxVariableName>>("diag_save_in_disp_z");
150  }
151  else if (coord_type == Moose::COORD_RSPHERICAL)
152  {
153  rspherical = true;
154  type = "StressDivergenceRSpherical";
155  dim = 1;
156  keys.push_back("disp_r");
157  vars.push_back(_disp_r);
158  save_in.resize(dim);
159  if (isParamValid("save_in_disp_r"))
160  save_in[0] = getParam<std::vector<AuxVariableName>>("save_in_disp_r");
161 
162  diag_save_in.resize(dim);
163  if (isParamValid("diag_save_in_disp_r"))
164  diag_save_in[0] = getParam<std::vector<AuxVariableName>>("diag_save_in_disp_r");
165  }
166 
167  if (!rz && !rspherical && _disp_x == "")
168  {
169  mooseError("disp_x must be specified");
170  }
171 
172  if (!rz && !rspherical)
173  {
174  keys.push_back("disp_x");
175  vars.push_back(_disp_x);
176  if (_disp_y != "")
177  {
178  ++dim;
179  keys.push_back("disp_y");
180  vars.push_back(_disp_y);
181  if (_disp_z != "")
182  {
183  ++dim;
184  keys.push_back("disp_z");
185  vars.push_back(_disp_z);
186  }
187  }
188 
189  save_in.resize(dim);
190  if (isParamValid("save_in_disp_x"))
191  save_in[0] = getParam<std::vector<AuxVariableName>>("save_in_disp_x");
192 
193  if (isParamValid("save_in_disp_y"))
194  save_in[1] = getParam<std::vector<AuxVariableName>>("save_in_disp_y");
195 
196  if (isParamValid("save_in_disp_z"))
197  save_in[2] = getParam<std::vector<AuxVariableName>>("save_in_disp_z");
198 
199  diag_save_in.resize(dim);
200  if (isParamValid("diag_save_in_disp_x"))
201  diag_save_in[0] = getParam<std::vector<AuxVariableName>>("diag_save_in_disp_x");
202 
203  if (isParamValid("diag_save_in_disp_y"))
204  diag_save_in[1] = getParam<std::vector<AuxVariableName>>("diag_save_in_disp_y");
205 
206  if (isParamValid("diag_save_in_disp_z"))
207  diag_save_in[2] = getParam<std::vector<AuxVariableName>>("diag_save_in_disp_z");
208  }
209 
210  unsigned int num_coupled(dim);
211  if (_temp != "")
212  {
213  ++num_coupled;
214  keys.push_back("temp");
215  vars.push_back(_temp);
216  }
217 
218  InputParameters params = _factory.getValidParams(type);
219  for (unsigned j(0); j < num_coupled; ++j)
220  {
221  params.addCoupledVar(keys[j], "");
222  params.set<std::vector<VariableName>>(keys[j]) = {vars[j]};
223  }
224 
225  params.set<bool>("use_displaced_mesh") = getParam<bool>("use_displaced_mesh");
226  params.set<std::string>("appended_property_name") =
227  getParam<std::string>("appended_property_name");
228 
229  for (unsigned int i(0); i < dim; ++i)
230  {
231  std::stringstream name;
232  name << _name;
233  name << i;
234 
235  params.set<unsigned int>("component") = i;
236 
237  params.set<NonlinearVariableName>("variable") = vars[i];
238  params.set<std::vector<SubdomainName>>("block") = blocks;
239  params.set<std::vector<AuxVariableName>>("save_in") = save_in[i];
240  params.set<std::vector<AuxVariableName>>("diag_save_in") = diag_save_in[i];
241  params.set<Real>("zeta") = _zeta;
242  params.set<Real>("alpha") = _alpha;
243  params.set<bool>("volumetric_locking_correction") =
244  getParam<bool>("volumetric_locking_correction");
245  _problem->addKernel(type, name.str(), params);
246  }
247  }
248 }
const NonlinearVariableName _disp_x
const NonlinearVariableName _disp_r
const NonlinearVariableName _disp_z
const std::string name
Definition: Setup.h:22
const NonlinearVariableName _temp
const NonlinearVariableName _disp_y

Member Data Documentation

◆ _alpha

const Real SolidMechanicsAction::_alpha
private

Definition at line 35 of file SolidMechanicsAction.h.

Referenced by act().

◆ _disp_r

const NonlinearVariableName SolidMechanicsAction::_disp_r
private

Definition at line 32 of file SolidMechanicsAction.h.

Referenced by act().

◆ _disp_x

const NonlinearVariableName SolidMechanicsAction::_disp_x
private

Definition at line 29 of file SolidMechanicsAction.h.

Referenced by act().

◆ _disp_y

const NonlinearVariableName SolidMechanicsAction::_disp_y
private

Definition at line 30 of file SolidMechanicsAction.h.

Referenced by act().

◆ _disp_z

const NonlinearVariableName SolidMechanicsAction::_disp_z
private

Definition at line 31 of file SolidMechanicsAction.h.

Referenced by act().

◆ _temp

const NonlinearVariableName SolidMechanicsAction::_temp
private

Definition at line 33 of file SolidMechanicsAction.h.

Referenced by act().

◆ _zeta

const Real SolidMechanicsAction::_zeta
private

Definition at line 34 of file SolidMechanicsAction.h.

Referenced by act().


The documentation for this class was generated from the following files: