Permalink
Browse files

Merge pull request #12587 from SudiptaBiswas/gbl_disp_action

Add option to visualize global displacement from GlobalStrainAction
  • Loading branch information...
dschwen committed Dec 13, 2018
2 parents 67624fb + 94b855f commit 25669cda1bbd0810e17eb3644c697cd87182d4a2
@@ -25,8 +25,9 @@ class GlobalStrainAction : public Action
void act() override;

protected:
std::vector<VariableName> _coupled_disp;
std::vector<VariableName> _disp;
std::vector<AuxVariableName> _aux_disp;
std::vector<AuxVariableName> _global_disp;

std::vector<SubdomainName> _block_names;
std::set<SubdomainID> _block_ids;
@@ -38,28 +38,30 @@ validParams<GlobalStrainAction>()
params.addParam<std::vector<AuxVariableName>>(
"auxiliary_displacements",
"The auxliary displacement variables to be calculated from scalar variables");
params.addParam<std::vector<AuxVariableName>>(
"global_displacements",
"The global displacement variables to be calculated from scalar variables");
params.addParam<std::vector<Real>>("applied_stress_tensor",
"Vector of values defining the constant applied stress "
"to add, in order 11, 22, 33, 23, 13, 12");
params.addParam<std::string>("base_name", "Material property base name");
params.addParam<bool>(
"output_global_displacement", false, "Option to output global displacement only");
params.addParam<std::vector<SubdomainName>>("block", "The block id where this variable lives");

return params;
}

GlobalStrainAction::GlobalStrainAction(const InputParameters & params)
: Action(params),
_coupled_disp(getParam<std::vector<VariableName>>("displacements")),
_disp(getParam<std::vector<VariableName>>("displacements")),
_aux_disp(getParam<std::vector<AuxVariableName>>("auxiliary_displacements")),
_global_disp(getParam<std::vector<AuxVariableName>>("global_displacements")),
_block_names(getParam<std::vector<SubdomainName>>("block")),
_block_ids()
{
if (_aux_disp.size() != _coupled_disp.size())
if (_aux_disp.size() != _disp.size())
mooseError("Number of auxiliary displacement variables should be equal to the number of "
"nonlinear displacement variables, i.e., ",
_coupled_disp.size());
_disp.size());
}

void
@@ -123,12 +125,24 @@ GlobalStrainAction::act()
//
else if (_current_task == "add_aux_variable")
{
const bool second = _problem->mesh().hasSecondOrderElements();

for (unsigned int i = 0; i < _aux_disp.size(); ++i)
{
std::string aux_var_name = _aux_disp[i];

_problem->addAuxVariable(aux_var_name,
FEType(Utility::string_to_enum<Order>("FIRST"),
FEType(Utility::string_to_enum<Order>(second ? "SECOND" : "FIRST"),
Utility::string_to_enum<FEFamily>("LAGRANGE")),
_block_ids.empty() ? nullptr : &_block_ids);
}

for (unsigned int i = 0; i < _global_disp.size(); ++i)
{
std::string aux_var_name = _global_disp[i];

_problem->addAuxVariable(aux_var_name,
FEType(Utility::string_to_enum<Order>(second ? "SECOND" : "FIRST"),
Utility::string_to_enum<FEFamily>("LAGRANGE")),
_block_ids.empty() ? nullptr : &_block_ids);
}
@@ -149,6 +163,26 @@ GlobalStrainAction::act()
params.set<AuxVariableName>("variable") = aux_var_name;
params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
params.set<bool>("use_displaced_mesh") = false;
params.set<bool>("output_global_displacement") = false;
params.set<std::vector<VariableName>>("scalar_global_strain") = {
getParam<NonlinearVariableName>("scalar_global_strain")};
params.set<UserObjectName>("global_strain_uo") = uo_name;
params.set<unsigned int>("component") = i;

_problem->addAuxKernel(aux_type, aux_var_name + '_' + name(), params);
}

for (unsigned int i = 0; i < _global_disp.size(); ++i)
{
std::string aux_var_name = _global_disp[i];

std::string aux_type = "GlobalDisplacementAux";
InputParameters params = _factory.getValidParams(aux_type);
params.applyParameters(parameters(), {"scalar_global_strain"});
params.set<AuxVariableName>("variable") = aux_var_name;
params.set<ExecFlagEnum>("execute_on") = EXEC_TIMESTEP_END;
params.set<bool>("use_displaced_mesh") = false;
params.set<bool>("output_global_displacement") = true;
params.set<std::vector<VariableName>>("scalar_global_strain") = {
getParam<NonlinearVariableName>("scalar_global_strain")};
params.set<UserObjectName>("global_strain_uo") = uo_name;
@@ -52,6 +52,7 @@
scalar_global_strain = global_strain
displacements = 'u_x u_y u_z'
auxiliary_displacements = 'disp_x disp_y disp_z'
global_displacements = 'ug_x ug_y ug_z'
[../]
[../]
[../]

0 comments on commit 25669cd

Please sign in to comment.