Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let us control the pressure action #29603

Open
wants to merge 2 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 Pressure boundary conditions,
the [Pressure.md] boundary conditions created by the `Pressure Action` cannot 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,31 @@ 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",
true,
"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 +102,14 @@ 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
params.set<bool>("enable") = getParam<bool>("enable");

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

if (_has_save_in_vars[i])
Expand Down
Binary file not shown.
142 changes: 142 additions & 0 deletions modules/solid_mechanics/test/tests/pressure/pressure_control_test.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
[Mesh]
type = FileMesh
file = pressure_test.e
displacements = 'disp_x disp_y disp_z'
[]

[Functions]
[rampConstant]
type = PiecewiseLinear
x = '0. 1. 2.'
y = '0. 1. 1.'
scale_factor = 1.0
[]
[zeroRamp]
type = PiecewiseLinear
x = '0. 1. 2.'
y = '0. 0. 1.'
scale_factor = 1.0
[]
[rampUnramp]
type = PiecewiseLinear
x = '0. 1. 2.'
y = '0. 1. 0.'
scale_factor = 10.0
[]
[]

[Variables]
[disp_x]
order = FIRST
family = LAGRANGE
[]
[disp_y]
order = FIRST
family = LAGRANGE
[]
[disp_z]
order = FIRST
family = LAGRANGE
[]
[]

[Kernels]
[SolidMechanics]
displacements = 'disp_x disp_y disp_z'
[]
[]

[BCs]
[no_x]
type = DirichletBC
variable = disp_x
boundary = 4
value = 0.0
[]
[no_y]
type = DirichletBC
variable = disp_y
boundary = 5
value = 0.0
[]
[no_z]
type = DirichletBC
variable = disp_z
boundary = 6
value = 0.0
[]
[Pressure]
[Side1]
boundary = 1
function = rampConstant
displacements = 'disp_x disp_y disp_z'
control_tags = 'tag_pressure'
[]
[Side2]
boundary = 2
function = zeroRamp
displacements = 'disp_x disp_y disp_z'
factor = 2.0
control_tags = 'tag_pressure'
[]
[Side3]
boundary = 3
function = rampUnramp
displacements = 'disp_x disp_y disp_z'
control_tags = 'tag_pressure'
[]
[]
[]

[Materials]
[Elasticity_tensor]
type = ComputeElasticityTensor
block = 1
fill_method = symmetric_isotropic
C_ijkl = '0 0.5e6'
[]
[strain]
type = ComputeSmallStrain
displacements = 'disp_x disp_y disp_z'
block = 1
[]
[stress]
type = ComputeLinearElasticStress
block = 1
[]
[]

[Controls]
# Turn Pressure on some boundaries for step 2, off at step 3
[pressure_crank]
type = TimePeriod
enable_objects = 'BCs/Pressure/Side1'
disable_objects = 'BCs/Pressure/Side2 BCs/Pressure/Side3'
start_time = 1
end_time = 2
# All Pressure are controlled outside of the period as well
reverse_on_false = true
[]
[]

[Executioner]
type = Transient
solve_type = PJFNK
nl_abs_tol = 1e-10
l_max_its = 20
start_time = 0.0
dt = 1.0
num_steps = 3
end_time = 2.0
[]

[Outputs]
[out]
type = Exodus
elemental_as_nodal = true
[]
[controls]
type = ControlOutput
show_active_objects = false
[]
[]
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