Step 2 - Adding boundary conditions
In the previous step we set up a basic small strain mechanics simulation that did... nothing. In this step we're adding a load to the top and we'll fix the displacements on the bottom surface of our block.
[GlobalParams<<<{"href": "../../../../syntax/GlobalParams/index.html"}>>>]
displacements = 'disp_x disp_y'
[]
[Mesh<<<{"href": "../../../../syntax/Mesh/index.html"}>>>]
[generated]
type = GeneratedMeshGenerator<<<{"description": "Create a line, square, or cube mesh with uniformly spaced or biased elements.", "href": "../../../../source/meshgenerators/GeneratedMeshGenerator.html"}>>>
dim<<<{"description": "The dimension of the mesh to be generated"}>>> = 2
nx<<<{"description": "Number of elements in the X direction"}>>> = 10
ny<<<{"description": "Number of elements in the Y direction"}>>> = 10
xmax<<<{"description": "Upper X Coordinate of the generated mesh"}>>> = 2
ymax<<<{"description": "Upper Y Coordinate of the generated mesh"}>>> = 1
[]
[]
[Physics<<<{"href": "../../../../syntax/Physics/index.html"}>>>/SolidMechanics<<<{"href": "../../../../syntax/Physics/SolidMechanics/index.html"}>>>/QuasiStatic<<<{"href": "../../../../syntax/Physics/SolidMechanics/QuasiStatic/index.html"}>>>]
[all]
add_variables<<<{"description": "Add the displacement variables"}>>> = true
[]
[]
#
# Added boundary/loading conditions
# https://mooseframework.inl.gov/modules/solid_mechanics/tutorials/introduction/step02.html
#
[BCs<<<{"href": "../../../../syntax/BCs/index.html"}>>>]
[bottom_x]
type = DirichletBC<<<{"description": "Imposes the essential boundary condition $u=g$, where $g$ is a constant, controllable value.", "href": "../../../../source/bcs/DirichletBC.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = disp_x
boundary<<<{"description": "The list of boundary IDs from the mesh where this object applies"}>>> = bottom
value<<<{"description": "Value of the BC"}>>> = 0
[]
[bottom_y]
type = DirichletBC<<<{"description": "Imposes the essential boundary condition $u=g$, where $g$ is a constant, controllable value.", "href": "../../../../source/bcs/DirichletBC.html"}>>>
variable<<<{"description": "The name of the variable that this residual object operates on"}>>> = disp_y
boundary<<<{"description": "The list of boundary IDs from the mesh where this object applies"}>>> = bottom
value<<<{"description": "Value of the BC"}>>> = 0
[]
[Pressure<<<{"href": "../../../../syntax/BCs/Pressure/index.html"}>>>]
[top]
boundary<<<{"description": "The list of boundary IDs from the mesh where the pressure will be applied"}>>> = top
function<<<{"description": "The function that describes the pressure"}>>> = 1e7*t
[]
[]
[]
[Materials<<<{"href": "../../../../syntax/Materials/index.html"}>>>]
[elasticity]
type = ComputeIsotropicElasticityTensor<<<{"description": "Compute a constant isotropic elasticity tensor.", "href": "../../../../source/materials/ComputeIsotropicElasticityTensor.html"}>>>
youngs_modulus<<<{"description": "Young's modulus of the material."}>>> = 1e9
poissons_ratio<<<{"description": "Poisson's ratio for the material."}>>> = 0.3
[]
[stress]
type = ComputeLinearElasticStress<<<{"description": "Compute stress using elasticity for small strains", "href": "../../../../source/materials/ComputeLinearElasticStress.html"}>>>
[]
[]
# consider all off-diagonal Jacobians for preconditioning
[Preconditioning<<<{"href": "../../../../syntax/Preconditioning/index.html"}>>>]
[SMP]
type = SMP<<<{"description": "Single matrix preconditioner (SMP) builds a preconditioner using user defined off-diagonal parts of the Jacobian.", "href": "../../../../source/preconditioners/SingleMatrixPreconditioner.html"}>>>
full<<<{"description": "Set to true if you want the full set of couplings between variables simply for convenience so you don't have to set every off_diag_row and off_diag_column combination."}>>> = true
[]
[]
[Executioner<<<{"href": "../../../../syntax/Executioner/index.html"}>>>]
type = Transient
# we chose a direct solver here
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
end_time = 5
dt = 1
[]
[Outputs<<<{"href": "../../../../syntax/Outputs/index.html"}>>>]
exodus<<<{"description": "Output the results using the default settings for Exodus output."}>>> = true
[]
(moose/modules/solid_mechanics/tutorials/introduction/mech_step02.i)Input file
BCs
BCs stands for boundary conditions. Those apply to the boundaries (or sidesets) of the simulation domain. In all boundary condition objects you will see the mandatory boundary
parameter, which expects a list of sideset names or IDs.
DirichletBC
The two DirichletBC
boundary conditions are both set on the bottom surface of the simulation domain. This fixes the disp_x
and disp_y
variables to 0 respectively. Check the list of available boundary conditions.
Pressure
You may have noticed [Pressure]
block looking different than the other two boundary conditions. This is because that block is a custom action syntax. Instead of a variable
parameter it uses the displacements
parameter defined in the global parameters block above. The action sets up a Pressure
boundary condition for each displacement variable. We will see other examples of actions later on.
Using the "function" parameter we supply a time dependent applied pressure. We are taking advantage of a MOOSE shorthand again here. Any time a FunctionName
type parameter is requested the user can instead supply a parsed function expression directly. If you need to specify a different type of function or need to reuse a single function multiple times in the input file, you should explicitly add a function object under the [Functions]
top level block. This pressure action could have instead been written as
[Functions]
[applied_pressure_function]
type = ParsedFunction
value = 1e7*t
[]
[]
[BCs]
[Pressure]
[top]
boundary = top
function = applied_pressure_function
[]
[]
[]
Preconditioning
The [Preconditioning]
block lets the user specify the which parts of the Jacobian matrix are built. Here we're selecting the single matrix preconditioner with the "full" option set to true
to build a fully coupled Jacobian matrix. This helps the solver to better take the cross coupling between displacement variables into account and will lead to improved convergence.
Executioner
Using the "petsc_options_iname" and "petsc_options_value" parameters we can specify pairs of PETSc options and their values. -pctype lu
selects a direct LU decomposition solver. It is a good choice for small problems but does not provide a lot of scalability for larger problems.
Questions
Go ahead and run the input and visualize the result. Look at how the applied boundary condition effect the deformation of the sample.
Exploring parameters
Experiment with different settings for the mechanical properties of the sample and the applied loading. What happens if you drastically reduce the Young's modulus or increase the applied pressure. Is the simulation result still valid?
Units again
What changes if you scale Young's and applied pressure by the same amount. Why?
Sidebar: Automatic differentiation
In the current input file we are using only objects that provide a manually derived implementation of their Jacobian matrix contribution. Such a derivation is not always feasible, and it is not exact under every circumstance.
If you created a large strain version of the input, try and convert it to use MOOSE's automatic differentiation system. A few places to look at:
"use_automatic_differentiation" in the solid mechanics quasi-static physics
"use_automatic_differentiation" in the Pressure BC action
Once you've answered the questions and run this example we will move on to Step 3 where the concept of subdomains or "blocks" is introduced.