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]
displacements = 'disp_x disp_y'
[]
[Mesh]
[generated]
type = GeneratedMeshGenerator
dim = 2
nx = 10
ny = 10
xmax = 2
ymax = 1
[]
[]
[Modules/TensorMechanics/Master]
[all]
add_variables = true
[]
[]
#
# Added boundary/loading conditions
# https://mooseframework.inl.gov/modules/tensor_mechanics/tutorials/introduction/step02.html
#
[BCs]
[bottom_x]
type = DirichletBC
variable = disp_x
boundary = bottom
value = 0
[]
[bottom_y]
type = DirichletBC
variable = disp_y
boundary = bottom
value = 0
[]
[Pressure]
[top]
boundary = top
function = 1e7*t
[]
[]
[]
[Materials]
[elasticity]
type = ComputeIsotropicElasticityTensor
youngs_modulus = 1e9
poissons_ratio = 0.3
[]
[stress]
type = ComputeLinearElasticStress
[]
[]
# consider all off-diagonal Jacobians for preconditioning
[Preconditioning]
[SMP]
type = SMP
full = true
[]
[]
[Executioner]
type = Transient
# we chose a direct solver here
petsc_options_iname = '-pc_type'
petsc_options_value = 'lu'
end_time = 5
dt = 1
[]
[Outputs]
exodus = true
[]
(../moose/modules/tensor_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 tensor mechanics master action
"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.