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 > _coupled_disp
 
std::vector< AuxVariableName > _aux_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 52 of file GlobalStrainAction.C.

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

Member Function Documentation

◆ act()

void GlobalStrainAction::act ( )
override

Definition at line 66 of file GlobalStrainAction.C.

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

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 32 of file GlobalStrainAction.h.

Referenced by act().

◆ _block_names

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

Definition at line 31 of file GlobalStrainAction.h.

Referenced by act().

◆ _coupled_disp

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

Definition at line 28 of file GlobalStrainAction.h.

Referenced by GlobalStrainAction().


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