www.mooseframework.org
Public Member Functions | Protected Attributes | List of all members
GlobalStrainAction Class Reference

#include <GlobalStrainAction.h>

Inheritance diagram for GlobalStrainAction:
[legend]

Public Member Functions

 GlobalStrainAction (const InputParameters &params)
 
void act () override
 

Protected Attributes

std::vector< VariableName > _disp
 
std::vector< AuxVariableName > _aux_disp
 
std::vector< AuxVariableName > _global_disp
 
std::vector< SubdomainName > _block_names
 
std::set< SubdomainID > _block_ids
 

Detailed Description

Definition at line 20 of file GlobalStrainAction.h.

Constructor & Destructor Documentation

◆ GlobalStrainAction()

GlobalStrainAction::GlobalStrainAction ( const InputParameters &  params)

Definition at line 53 of file GlobalStrainAction.C.

54  : Action(params),
55  _disp(getParam<std::vector<VariableName>>("displacements")),
56  _aux_disp(getParam<std::vector<AuxVariableName>>("auxiliary_displacements")),
57  _global_disp(getParam<std::vector<AuxVariableName>>("global_displacements")),
58  _block_names(getParam<std::vector<SubdomainName>>("block")),
59  _block_ids()
60 {
61  if (_aux_disp.size() != _disp.size())
62  mooseError("Number of auxiliary displacement variables should be equal to the number of "
63  "nonlinear displacement variables, i.e., ",
64  _disp.size());
65 }
std::vector< AuxVariableName > _aux_disp
std::vector< VariableName > _disp
std::vector< SubdomainName > _block_names
std::set< SubdomainID > _block_ids
std::vector< AuxVariableName > _global_disp

Member Function Documentation

◆ act()

void GlobalStrainAction::act ( )
override

Definition at line 68 of file GlobalStrainAction.C.

69 {
70  // get subdomain IDs
71  for (auto & name : _block_names)
72  _block_ids.insert(_problem->mesh().getSubdomainID(name));
73 
74  // user object name
75  const std::string uo_name = _name + "_GlobalStrainUserObject";
76 
77  //
78  // Add user object
79  //
80  if (_current_task == "add_user_object")
81  {
82  std::string uo_type = "GlobalStrainUserObject";
83  InputParameters params = _factory.getValidParams(uo_type);
84  params.applyParameters(parameters());
85  params.set<bool>("use_displaced_mesh") = false;
86  params.set<ExecFlagEnum>("execute_on") = {EXEC_INITIAL, EXEC_LINEAR, EXEC_NONLINEAR};
87 
88  _problem->addUserObject(uo_type, uo_name, params);
89  }
90 
91  //
92  // Add scalar kernel
93  //
94  else if (_current_task == "add_scalar_kernel")
95  {
96  std::string sk_type = "GlobalStrain";
97  InputParameters params = _factory.getValidParams(sk_type);
98  params.applyParameters(parameters());
99  params.set<bool>("use_displaced_mesh") = false;
100  params.set<NonlinearVariableName>("variable") = getParam<VariableName>("scalar_global_strain");
101  params.set<UserObjectName>("global_strain_uo") = uo_name;
102 
103  _problem->addScalarKernel(sk_type, _name + "_GlobalStrain", params);
104  }
105 
106  //
107  // Add ComputeGlobalStrain material
108  //
109  else if (_current_task == "add_material")
110  {
111  std::string mat_type = "ComputeGlobalStrain";
112  InputParameters params = _factory.getValidParams(mat_type);
113  params.applyParameters(parameters(), {"scalar_global_strain"});
114  params.set<bool>("use_displaced_mesh") = false;
115  params.set<std::vector<VariableName>>("scalar_global_strain") = {
116  getParam<VariableName>("scalar_global_strain")};
117  params.set<UserObjectName>("global_strain_uo") = uo_name;
118 
119  _problem->addMaterial(mat_type, _name + "_global_strain", params);
120  }
121 
122  //
123  // Add auxiliary displacement variables
124  //
125  else if (_current_task == "add_aux_variable")
126  {
127  const bool second = _problem->mesh().hasSecondOrderElements();
128 
129  for (unsigned int i = 0; i < _aux_disp.size(); ++i)
130  {
131  std::string aux_var_name = _aux_disp[i];
132 
133  _problem->addAuxVariable(aux_var_name,
134  FEType(Utility::string_to_enum<Order>(second ? "SECOND" : "FIRST"),
135  Utility::string_to_enum<FEFamily>("LAGRANGE")),
136  _block_ids.empty() ? nullptr : &_block_ids);
137  }
138 
139  for (unsigned int i = 0; i < _global_disp.size(); ++i)
140  {
141  std::string aux_var_name = _global_disp[i];
142 
143  _problem->addAuxVariable(aux_var_name,
144  FEType(Utility::string_to_enum<Order>(second ? "SECOND" : "FIRST"),
145  Utility::string_to_enum<FEFamily>("LAGRANGE")),
146  _block_ids.empty() ? nullptr : &_block_ids);
147  }
148  }
149 
150  //
151  // Add aux kernels for computing global displacements
152  //
153  else if (_current_task == "add_aux_kernel")
154  {
155  for (unsigned int i = 0; i < _aux_disp.size(); ++i)
156  {
157  std::string aux_var_name = _aux_disp[i];
158 
159  std::string aux_type = "GlobalDisplacementAux";
160  InputParameters params = _factory.getValidParams(aux_type);
161  params.applyParameters(parameters(), {"scalar_global_strain"});
162  params.set<AuxVariableName>("variable") = aux_var_name;
163  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
164  params.set<bool>("use_displaced_mesh") = false;
165  params.set<bool>("output_global_displacement") = false;
166  params.set<std::vector<VariableName>>("scalar_global_strain") = {
167  getParam<VariableName>("scalar_global_strain")};
168  params.set<UserObjectName>("global_strain_uo") = uo_name;
169  params.set<unsigned int>("component") = i;
170 
171  _problem->addAuxKernel(aux_type, aux_var_name + '_' + name(), params);
172  }
173 
174  for (unsigned int i = 0; i < _global_disp.size(); ++i)
175  {
176  std::string aux_var_name = _global_disp[i];
177 
178  std::string aux_type = "GlobalDisplacementAux";
179  InputParameters params = _factory.getValidParams(aux_type);
180  params.applyParameters(parameters(), {"scalar_global_strain"});
181  params.set<AuxVariableName>("variable") = aux_var_name;
182  params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
183  params.set<bool>("use_displaced_mesh") = false;
184  params.set<bool>("output_global_displacement") = true;
185  params.set<std::vector<VariableName>>("scalar_global_strain") = {
186  getParam<VariableName>("scalar_global_strain")};
187  params.set<UserObjectName>("global_strain_uo") = uo_name;
188  params.set<unsigned int>("component") = i;
189 
190  _problem->addAuxKernel(aux_type, aux_var_name + '_' + name(), params);
191  }
192  }
193 }
std::vector< AuxVariableName > _aux_disp
std::vector< SubdomainName > _block_names
std::set< SubdomainID > _block_ids
const std::string name
Definition: Setup.h:22
std::vector< AuxVariableName > _global_disp

Member Data Documentation

◆ _aux_disp

std::vector<AuxVariableName> GlobalStrainAction::_aux_disp
protected

Definition at line 29 of file GlobalStrainAction.h.

Referenced by act(), and GlobalStrainAction().

◆ _block_ids

std::set<SubdomainID> GlobalStrainAction::_block_ids
protected

Definition at line 33 of file GlobalStrainAction.h.

Referenced by act().

◆ _block_names

std::vector<SubdomainName> GlobalStrainAction::_block_names
protected

Definition at line 32 of file GlobalStrainAction.h.

Referenced by act().

◆ _disp

std::vector<VariableName> GlobalStrainAction::_disp
protected

Definition at line 28 of file GlobalStrainAction.h.

Referenced by GlobalStrainAction().

◆ _global_disp

std::vector<AuxVariableName> GlobalStrainAction::_global_disp
protected

Definition at line 30 of file GlobalStrainAction.h.

Referenced by act().


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