Skip to content

Commit

Permalink
Forward controllable status through the pressure action
Browse files Browse the repository at this point in the history
  • Loading branch information
GiudGiud committed Dec 23, 2024
1 parent dc0e9c8 commit 0fc33c9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
## Description

The `Pressure` Action is used to create a set of pressure boundary conditions for a string of displacement variables; the typical use case for this action is the application of hydrostatic pressure. See the description, example use, and parameters on the [Pressure](/Pressure/index.md) action system page.

!alert warning
When using the [Controls system](syntax/Controls/index.md) to control the active status of the Pressure boundary conditions,
the [!param](/BCs/Pressure/enable) must be set explicitly in the input file AND the [Pressure.md] boundary conditions can no longer
be controlled individually, they will all follow the same enabled/disabled status.
34 changes: 27 additions & 7 deletions modules/solid_mechanics/src/actions/PressureAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ PressureAction::validParams()
"displacements",
"The displacements appropriate for the simulation geometry and coordinate system");

params.addParam<std::vector<AuxVariableName>>(
"save_in_disp_x", {}, "The save_in variables for x displacement");
params.addParam<std::vector<AuxVariableName>>(
"save_in_disp_y", {}, "The save_in variables for y displacement");
params.addParam<std::vector<AuxVariableName>>(
"save_in_disp_z", {}, "The save_in variables for z displacement");

params.addParam<Real>("factor", 1.0, "The factor to use in computing the pressure");
params.addParam<bool>("use_displaced_mesh", true, "Whether to use the displaced mesh.");
params.addParam<Real>("hht_alpha",
Expand All @@ -46,12 +39,30 @@ PressureAction::validParams()
params.addParam<bool>("use_automatic_differentiation",
false,
"Flag to use automatic differentiation (AD) objects when possible");

// To make controlling the Pressure BCs easier
params.addParam<bool>(
"enable",
"Set the enabled status of the BCs created by the Pressure action (defaults to true).");
params.declareControllable("enable");

// Residual output
params.addParam<std::vector<AuxVariableName>>(
"save_in_disp_x", {}, "The save_in variables for x displacement");
params.addParam<std::vector<AuxVariableName>>(
"save_in_disp_y", {}, "The save_in variables for y displacement");
params.addParam<std::vector<AuxVariableName>>(
"save_in_disp_z", {}, "The save_in variables for z displacement");
params.addParam<std::vector<TagName>>("extra_vector_tags",
"The extra tags for the vectors this Kernel should fill");
params.addParam<std::vector<TagName>>(
"absolute_value_vector_tags",
"The tags for the vectors this residual object should fill with the "
"absolute value of the residual contribution");

params.addParamNamesToGroup(
"save_in_disp_x save_in_disp_y save_in_disp_z extra_vector_tags absolute_value_vector_tags",
"Residual output");
return params;
}

Expand Down Expand Up @@ -90,6 +101,15 @@ PressureAction::act()
params.set<Real>("alpha") =
isParamValid("alpha") ? getParam<Real>("alpha") : getParam<Real>("hht_alpha");

// Forward control parameters
if (isParamValid("control_tags"))
params.set<std::vector<std::string>>("control_tags") =
getParam<std::vector<std::string>>("control_tags");
// Setting a reference like this in three BCs is dangerous (the three BCs can no longer
// be controlled independently). So we only do this if "enable" is set explicitly
if (isParamValid("enable"))
params.set<bool>("enable") = getParam<bool>("enable");

params.set<NonlinearVariableName>("variable") = displacements[i];

if (_has_save_in_vars[i])
Expand Down
8 changes: 8 additions & 0 deletions modules/solid_mechanics/test/tests/pressure/tests
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
design = 'syntax/BCs/Pressure/index.md'
requirement = 'The Pressure boundary condition action shall create the objects needed to apply pressure boundary conditions on a 3D model as demonstrated by correctly computing the response of an elastic small-strain isotropic unit cube with pressure applied on three faces to create a hydrostatic pressure using the volumetric locking correction b-bar formulation.'
[]
[controls]
type = Exodiff
input = 'pressure_control_test.i'
exodiff = 'pressure_control_test_out.e'
issues = '#29602'
design = 'syntax/BCs/Pressure/index.md'
requirement = 'The system shall be able to forward control parameters from the Pressure action to the pressure boundary conditions.'
[]
[jacobian_3D_hex8]
type = 'PetscJacobianTester'
input = 'cantilever.i'
Expand Down

0 comments on commit 0fc33c9

Please sign in to comment.