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 18 of file SolidMechanicsAction.h.

Constructor & Destructor Documentation

SolidMechanicsAction::SolidMechanicsAction ( const InputParameters &  params)

Definition at line 60 of file SolidMechanicsAction.C.

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

Member Function Documentation

void SolidMechanicsAction::act ( )
virtual

Definition at line 73 of file SolidMechanicsAction.C.

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

Member Data Documentation

const Real SolidMechanicsAction::_alpha
private

Definition at line 32 of file SolidMechanicsAction.h.

Referenced by act().

const NonlinearVariableName SolidMechanicsAction::_disp_r
private

Definition at line 29 of file SolidMechanicsAction.h.

Referenced by act().

const NonlinearVariableName SolidMechanicsAction::_disp_x
private

Definition at line 26 of file SolidMechanicsAction.h.

Referenced by act().

const NonlinearVariableName SolidMechanicsAction::_disp_y
private

Definition at line 27 of file SolidMechanicsAction.h.

Referenced by act().

const NonlinearVariableName SolidMechanicsAction::_disp_z
private

Definition at line 28 of file SolidMechanicsAction.h.

Referenced by act().

const NonlinearVariableName SolidMechanicsAction::_temp
private

Definition at line 30 of file SolidMechanicsAction.h.

Referenced by act().

const Real SolidMechanicsAction::_zeta
private

Definition at line 31 of file SolidMechanicsAction.h.

Referenced by act().


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