diff --git a/framework/include/interfaces/ScalarCoupleable.h b/framework/include/interfaces/ScalarCoupleable.h index 86fa387dab75..ccd69b18e798 100644 --- a/framework/include/interfaces/ScalarCoupleable.h +++ b/framework/include/interfaces/ScalarCoupleable.h @@ -19,6 +19,10 @@ #include #include +#define usingScalarCoupleableMembers \ + using ScalarCoupleable::coupledScalarComponents; \ + using ScalarCoupleable::coupledScalarValueOld + // Forward declarations class FEProblemBase; class InputParameters; diff --git a/framework/include/materials/ADMaterial.h b/framework/include/materials/ADMaterial.h index 5ee719eabb51..9377cb8152e5 100644 --- a/framework/include/materials/ADMaterial.h +++ b/framework/include/materials/ADMaterial.h @@ -18,6 +18,7 @@ #define usingMaterialMembers \ usingMooseObjectMembers; \ usingCoupleableMembers; \ + usingScalarCoupleableMembers; \ usingTransientInterfaceMembers; \ usingBlockRestrictableMembers; \ usingFunctionInterfaceMembers; \ diff --git a/modules/combined/test/tests/elastic_thermal_patch/ad_elastic_thermal_weak_plane_stress_jacobian.i b/modules/combined/test/tests/elastic_thermal_patch/ad_elastic_thermal_weak_plane_stress_jacobian.i new file mode 100644 index 000000000000..991a37a2768c --- /dev/null +++ b/modules/combined/test/tests/elastic_thermal_patch/ad_elastic_thermal_weak_plane_stress_jacobian.i @@ -0,0 +1,70 @@ +[GlobalParams] + displacements = 'disp_x disp_y' + temperature = temp + out_of_plane_strain = strain_zz +[] + +[Mesh] + file = square.e +[] + +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] + [./strain_zz] + [../] + [./temp] + [../] +[] + +[Modules/TensorMechanics/Master] + [./plane_stress] + planar_formulation = WEAK_PLANE_STRESS + strain = SMALL + eigenstrain_names = thermal_eigenstrain + use_automatic_differentiation = true + [../] +[] + +[Kernels] + [./heat] + type = HeatConduction + variable = temp + use_displaced_mesh = false + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeIsotropicElasticityTensor + poissons_ratio = 0.0 + youngs_modulus = 1 + [../] + [./thermal_strain] + type = ADComputeThermalExpansionEigenstrain + thermal_expansion_coeff = 1e-5 + stress_free_temperature = 0 + eigenstrain_name = thermal_eigenstrain + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] + + [./conductivity] + type = HeatConductionMaterial + thermal_conductivity = 1 + use_displaced_mesh = false + [../] +[] + +[Executioner] + type = Transient + solve_type = NEWTON + + petsc_options_iname = '-ksp_type -pc_type -snes_type' + petsc_options_value = 'bcgs bjacobi test' + + end_time = 1.0 +[] diff --git a/modules/combined/test/tests/elastic_thermal_patch/tests b/modules/combined/test/tests/elastic_thermal_patch/tests index 4ba8f2176217..5ad305682a26 100644 --- a/modules/combined/test/tests/elastic_thermal_patch/tests +++ b/modules/combined/test/tests/elastic_thermal_patch/tests @@ -92,4 +92,10 @@ difference_tol = 1E10 requirement = 'The system shall compute thermal strain in conjunction with weak plane stress' [../] + + [./ad_elastic_thermal_weak_plane_stress_jacobian] + type = 'PetscJacobianTester' + input = 'ad_elastic_thermal_weak_plane_stress_jacobian.i' + requirement = 'The system shall compute thermal strain in conjunction with AD weak plane stress' + [../] [] diff --git a/modules/tensor_mechanics/doc/content/source/kernels/ADWeakPlaneStress.md b/modules/tensor_mechanics/doc/content/source/kernels/ADWeakPlaneStress.md new file mode 100644 index 000000000000..fe7ad01ba5c4 --- /dev/null +++ b/modules/tensor_mechanics/doc/content/source/kernels/ADWeakPlaneStress.md @@ -0,0 +1,24 @@ +# ADWeakPlaneStress + +!syntax description /Kernels/ADWeakPlaneStress + +## Description + +In 2D plane stress conditions, the out-of-plane stress is zero. The `ADWeakPlaneStress` kernel +operates on an out-of-plane strain variable and computes the following residual: +\begin{equation} + \int \phi \; \sigma_{zz} \; \textrm{dV}. +\end{equation} +Thus, the out-of-plane stress is driven toward zero but may not be strictly zero everywhere. +The computed out-of-plane strain may vary at different points on the plane. + +For finite deformation models, this kernel should be run on the displaced mesh by setting +`use_displaced_mesh = true`. + +!syntax parameters /Kernels/ADWeakPlaneStress + +!syntax inputs /Kernels/ADWeakPlaneStress + +!syntax children /Kernels/ADWeakPlaneStress + +!bibtex bibliography diff --git a/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneFiniteStrain.md b/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneFiniteStrain.md new file mode 100644 index 000000000000..09a922cc10f6 --- /dev/null +++ b/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneFiniteStrain.md @@ -0,0 +1,204 @@ +# Compute Plane Finite Strain + +!syntax description /Materials/ADComputePlaneFiniteStrain + + +## Description + +The material `ADComputePlaneFiniteStrain` calculates the finite strain for 2D +plane strain problems. It can be used for classical +[plane strain or plane stress](https://en.wikipedia.org/wiki/Plane_stress) +problems, or in +[Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) simulations. + +## Out of Plane Strain + +In the classical plane strain problem, it is assumed that the front and back +surfaces of the body are constrained in the out-of-plane direction, and that +the displacements in that direction on those surfaces are zero. As a +result, the strain and deformation gradient components in the out-of-plane +direction are held constant at zero: +\begin{equation} + \label{eqn:classical_dop_deform_grad} + F|^{dop} = 0 \text{ and } \epsilon|^{dop} = 0 +\end{equation} +$F|^{dop}$ is the deformation gradient tensor diagonal component for the +direction of the out-of-plane strain and $\epsilon|^{dop}$ is the corresponding +strain component. + +### Plane Stress and Generalized Plane Strain + +In the cases of the plane stress and generalized plane strain assumptions, the +component of strain and the deformation gradient in the out-of-plane direction +is non-zero. To solve for this out-of-plane strain, we invoke the approximation +of the stretch rate tensor +\begin{equation} + \label{eqn:stretch_tensor_approx} + \boldsymbol{D} = \log \left( \sqrt{\hat{\boldsymbol{F}}^T \cdot \hat{\boldsymbol{F}}} \right) \cdot \frac{1}{dt} +\end{equation} +and define the deformation gradient component in the out-of-plane direction as +\begin{equation} + \label{eqn:dop_deform_grad} + F|^{dop} = \exp \left( \epsilon|^{op} - 1.0 \right) +\end{equation} +where $F|^{dop}$ is the deformation gradient tensor diagonal component for the +direction of the out-of-plane strain and $\epsilon|^{op}$ is a prescribed +out-of-plane strain value: this strain value can be given either as a scalar +variable or a nonlinear field variable. + +For the case of plane stress, the [ADWeakPlaneStress](ADWeakPlaneStress.md) kernel +is used to integrate the out-of-plane component of the stress over the area of +each element, and assemble that integral to the residual of the out-of-plane +strain field variable. This results in a weak enforcement of the condition that +the out-of-plane stress is zero, which allows for re-use of the same constitutive +models for models of all dimensionality. + +The [Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) +problems use scalar variables. Multiple scalar variables can be provided such +that one strain calculator is needed for multiple generalized plane strain +models on different subdomains. + + +## Strain and Deformation Gradient Formulation + +The incremental deformation gradient for the 2D planar system is defined as +\begin{equation} + \label{eqn:incremental_deformation_grad} + \hat{\boldsymbol{F}} = \boldsymbol{A} : \bar{\boldsymbol{F}}^{-1} + \boldsymbol{I} +\end{equation} +where $\boldsymbol{I}$ is the Rank-2 identity tensor, $\boldsymbol{A}$ is the deformation +gradient, and $\bar{\boldsymbol{F}}$ is the old deformation gradient. + +#### $Z$-Direction of Out-of-Plane Strain (Default) + +The default out-of-plane direction is along the $z$-axis. For this direction +the current and old deformation gradient tensors, used in +[eqn:incremental_deformation_grad], are given as +\begin{equation} + \label{eqn:deform_grads} + \boldsymbol{A} = \begin{bmatrix} + u_{x,x} & u_{x,y} & 0 \\ + u_{y,x} & u_{y,y} & 0 \\ + 0 & 0 & F|^{dop} + \end{bmatrix} + \boldsymbol{I} + \qquad \text{ and } \qquad + \bar{\boldsymbol{F}} = \begin{bmatrix} + u_{x,x}|_{old} & u_{x,y}|_{old} & 0 \\ + u_{y,x}|_{old} & u_{y,y}|_{old} & 0 \\ + 0 & 0 & F|^{dop}_{old} + \end{bmatrix} + \boldsymbol{I} +\end{equation} +where $F|^{dop}$ is defined in [eqn:dop_deform_grad]. +Note that $\bar{\boldsymbol{F}}$ uses the values of the strain expressions from +the previous time step. +As in the classical presentation of the strain tensor in plane strain problems, +the components of the deformation tensor associated with the $z$-direction are +zero; these zero components indicate no coupling between the in-plane displacements +and the out-of-plane strain variable. + +#### $X$-Direction of Out-of-Plane Strain + +If the user selects the out-of-plane direction as along the $x$-direction, the +current and old deformation gradient tensors from [eqn:incremental_deformation_grad] +are formulated as +\begin{equation} + \label{eqn:deform_grads_xdirs} + \boldsymbol{A} = \begin{bmatrix} + F|^{dop} & 0 & 0 \\ + 0 & u_{y,y} & u_{z,y} \\ + 0 & u_{y,z} & u_{z,z} + \end{bmatrix} + \boldsymbol{I} + \qquad \text{ and } \qquad + \bar{\boldsymbol{F}} = \begin{bmatrix} + F|^{dop}_{old} & 0 & 0 \\ + 0 & u_{y,y}|_{old} & u_{y,z}|_{old} \\ + 0 & u_{z,y}|_{old}& u_{z,z}|_{old} + \end{bmatrix} + \boldsymbol{I} +\end{equation} +so that the off-diagonal components of the deformation tensors associated with +the $x$-direction are zeros. + +#### $Y$-Direction of Out-of-Plane Strain + +If the user selects the out-of-plane direction as along the $y$-direction, the +current and old deformation gradient tensors from [eqn:incremental_deformation_grad] +are formulated as +\begin{equation} + \label{eqn:deform_grads_ydirs} + \boldsymbol{A} = \begin{bmatrix} + u_{x,x} & 0 & u_{z,x} \\ + 0 & F|^{dop} & 0 \\ + u_{x,z} & 0 & u_{z,z} + \end{bmatrix} + \boldsymbol{I} + \qquad \text{ and } \qquad + \bar{\boldsymbol{F}} = \begin{bmatrix} + u_{x,x}|_{old} & 0 & u_{x,z}|_{old} \\ + 0 & F|^{dop}_{old} & 0 \\ + u_{z,x}|_{old} & 0 & u_{z,z}|_{old} + \end{bmatrix} + \boldsymbol{I} +\end{equation} +so that the off-diagonal components of the deformation tensors associated with +the $y$-direction are zeros. + + +### Finalized Deformation Gradient + +If selected by the user, the incremental deformation gradient is conditioned with +a $\bar{B}$ formulation to mitigate volumetric locking of the elements. +The volumetric locking correction is applied to both the incremental deformation +gradient +\begin{equation} + \label{eqn:vlc_fhat} + \hat{\boldsymbol{F}}|_{vlc} = \left( \frac{1}{det(\hat{\boldsymbol{F}})} \frac{\hat{\boldsymbol{F}}_{avg}}{V_{elem}} \right)^{1/3} +\end{equation} +and the total deformation gradient. For more details about the theory behind +[eqn:vlc_fhat] see the +[Volumetric Locking Correction](/tensor_mechanics/VolumetricLocking.md) +documentation. + +Once the incremental deformation gradient is calculated for the specific 2D geometry, +the deformation gradient is passed to the strain and rotation methods used by the +3D Cartesian simulations, as described in the [Finite Strain Class](ADComputeFiniteStrain.md) +documentation. + +## Example Input Files + +### Plane Stress + +The tensor mechanics [Master action](/Modules/TensorMechanics/Master/index.md) +can be used to create the `ADComputePlaneFiniteStrain` class by setting +`planar_formulation = WEAK_PLANE_STRESS` and `strain = FINITE` in the +`Master` action block. + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_finite.i block=Modules/TensorMechanics/Master + +Note that for plane stress analysis, the `out_of_plane_strain` parameter must be +defined, and is the name of the out-of-plane strain field variable. + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_finite.i block=Variables/strain_zz + +In the case of this example, `out_of_plane_strain` is defined in the `GlobalParams` block. + +### Generalized Plane Strain + +The use of this plane strain class for +[Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) +simulations uses the scalar out-of-plane strains. The tensor mechanics +[Master action](/Modules/TensorMechanics/Master/index.md) is used to create the +`ADComputePlaneFiniteStrain` class with the `planar_formulation = GENERALIZED_PLANE_STRAIN` +and the `strain = FINITE` settings. + +!listing modules/tensor_mechanics/test/tests/generalized_plane_strain/generalized_plane_strain_finite.i block=Modules/TensorMechanics/Master/all + +Note that the argument for the `scalar_out_of_plane_strain` parameter is the +name of the scalar strain variable + +!listing modules/tensor_mechanics/test/tests/generalized_plane_strain/generalized_plane_strain_finite.i block=Variables/scalar_strain_zz + +!syntax parameters /Materials/ADComputePlaneFiniteStrain + +!syntax inputs /Materials/ADComputePlaneFiniteStrain + +!syntax children /Materials/ADComputePlaneFiniteStrain + +!bibtex bibliography diff --git a/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneIncrementalStrain.md b/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneIncrementalStrain.md new file mode 100644 index 000000000000..9af2395d3588 --- /dev/null +++ b/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneIncrementalStrain.md @@ -0,0 +1,197 @@ +# Compute Plane Incremental Strain + +!syntax description /Materials/ADComputePlaneIncrementalStrain + +## Description + +The material `ADComputePlaneIncrementalStrain` calculates the small incremental +strain for 2D plane strain problems. It can be used for classical +[plane strain or plane stress](https://en.wikipedia.org/wiki/Plane_stress) +problems, or in +[Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) simulations. + +## Out of Plane Strain + +In the classical plane strain problem, it is assumed that the front and back +surfaces of the body are constrained in the out-of-plane direction, and that +the displacements in that direction on those surfaces are zero. As a +result, the strain and deformation gradient components in the out-of-plane +direction are held constant at zero: +\begin{equation} + \label{eqn:classical_dop_deform_grad} + F|^{dop} = 0 \text{ and } \epsilon|^{dop} = 0 +\end{equation} +$F|^{dop}$ is the deformation gradient tensor diagonal component for the +direction of the out-of-plane strain and $\epsilon|^{dop}$ is the corresponding +strain component. + +### Generalized Plane Strain + +In the cases of the generalized plane strain and weak plane stress models, the +component of strain and the deformation gradient in the out-of-plane direction +is non-zero. To solve for this out-of-plane strain, we use the out-of-plane +strain variable as the deformation gradient component +\begin{equation} + \label{eqn:dop_deform_grad} + F|^{dop} = \epsilon|^{op} +\end{equation} +where $F|^{dop}$ is the deformation gradient tensor diagonal component for the +direction of the out-of-plane strain and $\epsilon|^{op}$ is a prescribed +out-of-plane strain value: this strain value can be given either as a scalar +variable or a nonlinear field variable. +The [Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) +problems use scalar variables. Multiple scalar variables can be provided such +that one strain calculator is needed for multiple generalized plane strain +models on different subdomains. + +For the case of plane stress, the [ADWeakPlaneStress](ADWeakPlaneStress.md) kernel +is used to integrate the out-of-plane component of the stress over the area of +each element, and assemble that integral to the residual of the out-of-plane +strain field variable. This results in a weak enforcement of the condition that +the out-of-plane stress is zero, which allows for re-use of the same constitutive +models for models of all dimensionality. + +## Strain and Deformation Gradient Formulation + +The small strain increment is calculated with the form +\begin{equation} + \label{eqn:strain_increment} + \Delta \boldsymbol{\epsilon} = \frac{1}{2} \left( \boldsymbol{D} + \boldsymbol{D}^T \right) + \text{ where } \boldsymbol{D} = \boldsymbol{A} - \bar{\boldsymbol{F}} + \boldsymbol{I} +\end{equation} +where $\boldsymbol{I}$ is the Rank-2 identity tensor, $\boldsymbol{A}$ is the deformation +gradient, and $\bar{\boldsymbol{F}}$ is the old deformation gradient. + +#### $Z$-Direction of Out-of-Plane Strain (Default) + +The default out-of-plane direction is along the $z$-axis. For this direction +the current and old deformation gradient tensors, used in +[eqn:strain_increment], are given as +\begin{equation} + \label{eqn:deform_grads} + \boldsymbol{A} = \begin{bmatrix} + u_{x,x} & u_{x,y} & 0 \\ + u_{y,x} & u_{y,y} & 0 \\ + 0 & 0 & F|^{dop} + \end{bmatrix} + \boldsymbol{I} + \qquad \text{ and } \qquad + \bar{\boldsymbol{F}} = \begin{bmatrix} + u_{x,x}|_{old} & u_{x,y}|_{old} & 0 \\ + u_{y,x}|_{old} & u_{y,y}|_{old} & 0 \\ + 0 & 0 & F|^{dop}_{old} + \end{bmatrix} + \boldsymbol{I} +\end{equation} +where $F|^{dop}$ is defined in [eqn:dop_deform_grad]. +Note that $\bar{\boldsymbol{F}}$ uses the values of the strain expressions from +the previous time step. +As in the classical presentation of the strain tensor in plane strain problems, +the components of the deformation tensor associated with the $z$-direction are +zero; these zero components indicate no coupling between the in-plane displacements +and the out-of-plane strain variable. + +#### $X$-Direction of Out-of-Plane Strain + +If the user selects the out-of-plane direction as along the $x$-direction, the +current and old deformation gradient tensors from [eqn:strain_increment] are +formulated as +\begin{equation} + \label{eqn:deform_grads_xdirs} + \boldsymbol{A} = \begin{bmatrix} + F|^{dop} & 0 & 0 \\ + 0 & u_{y,y} & u_{z,y} \\ + 0 & u_{y,z} & u_{z,z} + \end{bmatrix} + \boldsymbol{I} + \qquad \text{ and } \qquad + \bar{\boldsymbol{F}} = \begin{bmatrix} + F|^{dop}_{old} & 0 & 0 \\ + 0 & u_{y,y}|_{old} & u_{y,z}|_{old} \\ + 0 & u_{z,y}|_{old}& u_{z,z}|_{old} + \end{bmatrix} + \boldsymbol{I} +\end{equation} +so that the off-diagonal components of the deformation tensors associated with +the $x$-direction are zeros. + +#### $Y$-Direction of Out-of-Plane Strain + +If the user selects the out-of-plane direction as along the $y$-direction, the +current and old deformation gradient tensors from [eqn:strain_increment] are +formulated as +\begin{equation} + \label{eqn:deform_grads_ydirs} + \boldsymbol{A} = \begin{bmatrix} + u_{x,x} & 0 & u_{z,x} \\ + 0 & F|^{dop} & 0 \\ + u_{x,z} & 0 & u_{z,z} + \end{bmatrix} + \boldsymbol{I} + \qquad \text{ and } \qquad + \bar{\boldsymbol{F}} = \begin{bmatrix} + u_{x,x}|_{old} & 0 & u_{x,z}|_{old} \\ + 0 & F|^{dop}_{old} & 0 \\ + u_{z,x}|_{old} & 0 & u_{z,z}|_{old} + \end{bmatrix} + \boldsymbol{I} +\end{equation} +so that the off-diagonal components of the deformation tensors associated with +the $y$-direction are zeros. + +### Finalized Deformation Gradient + +Once the incremental deformation gradient is calculated for the specific 2D geometry, +the deformation gradient is passed to the strain and rotation methods used by the +3D Cartesian simulations, as described in the +[Compute Incremental Small Strain](ComputeIncrementalSmallStrain.md) documentation. + +If selected by the user, the incremental strain tensor is conditioned with +a $\bar{B}$ formulation to mitigate volumetric locking of the elements. +The volumetric locking correction is applied to the total strain +\begin{equation} + \label{eqn:vlc_strain} + \Delta \boldsymbol{\epsilon}|_{vlc} = \boldsymbol{\epsilon} + \frac{\left( \boldsymbol{\epsilon}_V - tr(\boldsymbol{\Delta \epsilon}) \right)}{3} \cdot \boldsymbol{I} +\end{equation} +where $\boldsymbol{\epsilon}_V$ is the volumetric strain and $\boldsymbol{I}$ +is the Rank-2 identity tensor. For more details about the theory +behind [eqn:vlc_strain] see the +[Volumetric Locking Correction](/tensor_mechanics/VolumetricLocking.md) +documentation. + +## Example Input Files + +### Plane Stress + +The tensor mechanics [Master action](/Modules/TensorMechanics/Master/index.md) +can be used to create the `ADComputePlaneIncrementalStrain` class by setting +`planar_formulation = WEAK_PLANE_STRESS`, `strain = SMALL`, and `incremental = true` in the +`Master` action block. + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_incremental.i block=Modules/TensorMechanics/Master + +Note that for plane stress analysis, the `out_of_plane_strain` parameter must be +defined, and is the name of the out-of-plane strain field variable. + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_incremental.i block=Variables/strain_zz + +In the case of this example, `out_of_plane_strain` is defined in the `GlobalParams` block. + +### Generalized Plane Strain + +The use of this plane strain class for +[Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) +simulations uses the scalar out-of-plane strains. The tensor mechanics +[Master action](/Modules/TensorMechanics/Master/index.md) is used to create the +`ADComputePlaneIncrementalStrain` class with the `planar_formulation = GENERALIZED_PLANE_STRAIN`, +`strain = SMALL`, and `incremental = true` settings. + +!listing modules/tensor_mechanics/test/tests/generalized_plane_strain/generalized_plane_strain_increment.i block=Modules/TensorMechanics/Master/all + +Note that the argument for the `scalar_out_of_plane_strain` parameter is the +name of the scalar strain variable + +!listing modules/tensor_mechanics/test/tests/generalized_plane_strain/generalized_plane_strain_increment.i block=Variables/scalar_strain_zz + + +!syntax parameters /Materials/ADComputePlaneIncrementalStrain + +!syntax inputs /Materials/ADComputePlaneIncrementalStrain + +!syntax children /Materials/ADComputePlaneIncrementalStrain + +!bibtex bibliography diff --git a/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneSmallStrain.md b/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneSmallStrain.md new file mode 100644 index 000000000000..6a0d87450dd9 --- /dev/null +++ b/modules/tensor_mechanics/doc/content/source/materials/ADComputePlaneSmallStrain.md @@ -0,0 +1,179 @@ +# Compute Plane Small Strain + +!syntax description /Materials/ADComputePlaneSmallStrain + +## Description + +The material `ADComputePlaneSmallStrain` calculates the small total +strain for 2D plane strain problems. It can be used for classical +[plane strain or plane stress](https://en.wikipedia.org/wiki/Plane_stress) +problems, or in +[Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) simulations. + +## Out of Plane Strain + +In the classical plane strain problem, it is assumed that the front and back +surfaces of the body are constrained in the out-of-plane direction, and that +the displacements in that direction on those surfaces are zero. As a +result, the strain and deformation gradient components in the out-of-plane +direction are held constant at zero: +\begin{equation} + \label{eqn:classical_dop_deform_grad} + \epsilon|^{dop} = 0 +\end{equation} +$\epsilon|^{dop}$ is the strain tensor diagonal component for the +direction of the out-of-plane strain. + +### Plane Stress and Generalized Plane Strain + +In the cases of the plane stress and generalized plane strain assumptions, the +component of strain and the deformation gradient in the out-of-plane direction +is non-zero. To solve for this out-of-plane strain, we use the out-of-plane +strain variable as the strain tensor component +\begin{equation} + \label{eqn:dop_deform_grad} + \epsilon|^{dop} = \epsilon|^{op} +\end{equation} +where $\epsilon|^{dop}$ is the strain tensor diagonal component for +the direction of the out-of-plane strain and $\epsilon|^{op}$ is a +prescribed out-of-plane strain value: this strain value can be +given either as a scalar variable or a nonlinear field variable. +The [Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) +problems use scalar variables. Multiple scalar variables can be provided such +that one strain calculator is needed for multiple generalized plane strain +models on different subdomains. + +For the case of plane stress, the [ADWeakPlaneStress](ADWeakPlaneStress.md) kernel +is used to integrate the out-of-plane component of the stress over the area of +each element, and assemble that integral to the residual of the out-of-plane +strain field variable. This results in a weak enforcement of the condition that +the out-of-plane stress is zero, which allows for re-use of the same constitutive +models for models of all dimensionality. + +## Strain and Deformation Gradient Formulation + +The definition of a small total linearized strain is +\begin{equation} + \label{eqn:def_small_total_strain} + \epsilon_{ij} = \frac{1}{2} \left( u_{i,j} + u_{j,i} \right) +\end{equation} +The values of each of the strain tensor components depends on the direction +selected by the user as the out-of-plane direction. + +#### $Z$-Direction of Out-of-Plane Strain (Default) + +The default out-of-plane direction is along the $z$-axis. For this direction +the strain tensor, [eqn:def_small_total_strain], is given as +\begin{equation} + \label{eqn:strain_tensor} + \boldsymbol{\epsilon} = \begin{bmatrix} + u_{x,x} & \frac{1}{2} \left(u_{x,y} + u_{y,x} \right) & 0 \\ + \frac{1}{2} \left(u_{x,y} + u_{y,x} \right) & u_{y,y} & 0 \\ + 0 & 0 & \epsilon|^{dop} + \end{bmatrix} +\end{equation} +where $\epsilon|^{dop}$ is defined in [eqn:dop_deform_grad]. +As in the classical presentation of the strain tensor in plane +strain problems, the components of the strain tensor associated +with the $z$-direction are zero; these zero components indicate no +coupling between the in-plane and the out-of-plane strains. + +#### $X$-Direction of Out-of-Plane Strain + +If the user selects the out-of-plane direction as along the +$x$-direction, the strain tensor from [eqn:def_small_total_strain] +is given as +\begin{equation} + \label{eqn:deform_grads_xdirs} + \boldsymbol{\epsilon} = \begin{bmatrix} + \epsilon|^{dop} & 0 & 0 \\ + 0 & u_{y,y} & \frac{1}{2} \left(u_{y,z} + u_{z,y} \right) \\ + 0 & \frac{1}{2} \left(u_{y,z} + u_{z,y} \right) & u_{z,z} + \end{bmatrix} +\end{equation} +so that the off-diagonal components of the strain tensor associated +with the $x$-direction are zeros. + +#### $Y$-Direction of Out-of-Plane Strain + +If the user selects the out-of-plane direction as along the +$y$-direction, the strain tensor from [eqn:def_small_total_strain] +is given as +\begin{equation} + \label{eqn:deform_grads_ydirs} + \boldsymbol{\epsilon} = \begin{bmatrix} + u_{x,x} & 0 & \frac{1}{2} \left(u_{x,z} + u_{z,x} \right) \\ + 0 & \epsilon|^{dop} & 0 \\ + \frac{1}{2} \left(u_{x,z} + u_{z,x} \right) & 0 & u_{z,z} + \end{bmatrix} +\end{equation} +so that the off-diagonal components of the strain tensor associated +with the $y$-direction are zeros. + +### Volumetric Locking Correction for Strain Tensor + +If selected by the user, the strain tensor is conditioned with +a $\bar{B}$ formulation to mitigate volumetric locking of the elements. +The volumetric locking correction is applied to the total strain +\begin{equation} + \label{eqn:vlc_strain} + \boldsymbol{\epsilon}|_{vlc} = \boldsymbol{\epsilon} + \frac{\left( \boldsymbol{\epsilon}_V - tr(\boldsymbol{\epsilon}) \right)}{3} \cdot \boldsymbol{I} +\end{equation} +where $\boldsymbol{\epsilon}_V$ is the volumetric strain and $\boldsymbol{I}$ +is the Rank-2 identity tensor. For more details about the theory +behind [eqn:vlc_strain] see the +[Volumetric Locking Correction](/tensor_mechanics/VolumetricLocking.md) +documentation. + +## Example Input Files + +### Plane Stress + +The tensor mechanics [Master action](/Modules/TensorMechanics/Master/index.md) +can be used to create the `ADComputePlaneSmallStrain` class by setting +`planar_formulation = WEAK_PLANE_STRESS` and `strain = SMALL` in the +`Master` action block. + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_small.i block=Modules/TensorMechanics/Master + +Note that for plane stress analysis, the `out_of_plane_strain` parameter must be +defined, and is the name of the out-of-plane strain field variable. + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_small.i block=Variables/strain_zz + +In the case of this example, `out_of_plane_strain` is defined in the `GlobalParams` block. + +### Generalized Plane Strain + +The use of this plane strain class for +[Generalized Plane Strain](tensor_mechanics/generalized_plane_strain.md) +simulations uses the scalar out-of-plane strains. The tensor mechanics +[Master action](/Modules/TensorMechanics/Master/index.md) is used to create the +`ADComputePlaneSmallStrain` class with the `planar_formulation = GENERALIZED_PLANE_STRAIN` +and `strain = SMALL` settings. + +!listing modules/tensor_mechanics/test/tests/generalized_plane_strain/generalized_plane_strain_small.i block=Modules/TensorMechanics/Master/all + +Note that the argument for the `scalar_out_of_plane_strain` parameter is the +name of the scalar strain variable + +!listing modules/tensor_mechanics/test/tests/generalized_plane_strain/generalized_plane_strain_small.i block=Variables/scalar_strain_zz + +### $Y$-Direction of Out-of-Plane Strain + +This plane strain class is used to model plane strain with an out-of-plane strain +in directions other than in the $z$-direction. As an example, the tensor mechanics +[Master action](/Modules/TensorMechanics/Master/index.md) can be used to create +the `ComputePlaneFiniteStrain` class for a $y$-direction out-of-plane strain with +the `planar_formulation = PLANE_STRAIN` and the `out_of_plane_direction = y` +settings. + +!listing modules/tensor_mechanics/test/tests/2D_different_planes/planestrain_xz.i block=Modules/TensorMechanics/Master/plane_strain + +!syntax parameters /Materials/ADComputePlaneSmallStrain + +!syntax inputs /Materials/ADComputePlaneSmallStrain + +!syntax children /Materials/ADComputePlaneSmallStrain + +!bibtex bibliography diff --git a/modules/tensor_mechanics/doc/content/source/materials/ADComputeStrainIncrementBasedStress.md b/modules/tensor_mechanics/doc/content/source/materials/ADComputeStrainIncrementBasedStress.md new file mode 100644 index 000000000000..3d9333b9e270 --- /dev/null +++ b/modules/tensor_mechanics/doc/content/source/materials/ADComputeStrainIncrementBasedStress.md @@ -0,0 +1,38 @@ +# Compute Strain Increment Based Stress + +!syntax description /Materials/ADComputeStrainIncrementBasedStress + +## Description + +This stress calculator finds the value of the stress as a function of the elastic +strain increment when a series of inelastic strains are specified in the input file. +The stress is calculated as +\begin{equation} + \label{eqn:stress} + \sigma_{ij} = \sigma_{ij}^{old} + C_{ijkl} \Delta \epsilon_{jk}^{el} +\end{equation} +where $\sigma_{ij}$ is the stress and $C_{ijkl}$ is the elasticity tensor of the +material. +The elastic strain increment, $\Delta \epsilon_{jk}^{el}$ is found by subtracting +the sum of the inelastic strains from the mechanical strain: +\begin{equation} + \label{eqn:elastic_strain_incr} + \Delta \boldsymbol{\epsilon}^{el} = \boldsymbol{\epsilon}^{mech} - \boldsymbol{\epsilon}^{mech-old} + - \sum_n \left( \boldsymbol{\epsilon}^{inel}_n - {\boldsymbol{\epsilon}^{inel-old}}_n \right) +\end{equation} +where $\boldsymbol{\epsilon}^{mech}$ is the mechanical strain and +$\boldsymbol{\epsilon}^{inel}$ is the inelastic strain. +In the tensor mechanics module mechanical strain is defined as the sum of the +elastic and inelastic (e.g. creep and/or plasticity) strains. + +## Example Input File + +!listing modules/tensor_mechanics/test/tests/plane_stress/weak_plane_stress_incremental.i block=Materials/stress + +!syntax parameters /Materials/ADComputeStrainIncrementBasedStress + +!syntax inputs /Materials/ADComputeStrainIncrementBasedStress + +!syntax children /Materials/ADComputeStrainIncrementBasedStress + +!bibtex bibliography diff --git a/modules/tensor_mechanics/doc/content/source/materials/ComputePlaneSmallStrain.md b/modules/tensor_mechanics/doc/content/source/materials/ComputePlaneSmallStrain.md index f536490e1a5c..12996e0812aa 100644 --- a/modules/tensor_mechanics/doc/content/source/materials/ComputePlaneSmallStrain.md +++ b/modules/tensor_mechanics/doc/content/source/materials/ComputePlaneSmallStrain.md @@ -14,7 +14,7 @@ problems, or in In the classical plane strain problem, it is assumed that the front and back surfaces of the body are constrained in the out-of-plane direction, and that -the displacements in that direction on those surfaces are zero. As a +the displacements in that direction on those surfaces are zero. As a result, the strain and deformation gradient components in the out-of-plane direction are held constant at zero: \begin{equation} diff --git a/modules/tensor_mechanics/include/actions/GeneralizedPlaneStrainAction.h b/modules/tensor_mechanics/include/actions/GeneralizedPlaneStrainAction.h index 2cabb4e9b51e..c89e680223d0 100644 --- a/modules/tensor_mechanics/include/actions/GeneralizedPlaneStrainAction.h +++ b/modules/tensor_mechanics/include/actions/GeneralizedPlaneStrainAction.h @@ -27,6 +27,8 @@ class GeneralizedPlaneStrainAction : public Action protected: std::vector _displacements; + + /// Number of displacement variables unsigned int _ndisp; const unsigned int _out_of_plane_direction; }; diff --git a/modules/tensor_mechanics/include/actions/TensorMechanicsAction.h b/modules/tensor_mechanics/include/actions/TensorMechanicsAction.h index 3d1d781e9fac..0f0ad4c0ba82 100644 --- a/modules/tensor_mechanics/include/actions/TensorMechanicsAction.h +++ b/modules/tensor_mechanics/include/actions/TensorMechanicsAction.h @@ -33,11 +33,14 @@ class TensorMechanicsAction : public TensorMechanicsActionBase virtual std::string getKernelType(); virtual InputParameters getKernelParameters(std::string type); - ///@{ displacement variables + /// Displacement variables std::vector _displacements; + + /// Number of displacement variables unsigned int _ndisp; + + /// Coupled displacement variables std::vector _coupled_displacements; - ///@} ///@{ residual debugging std::vector _save_in; diff --git a/modules/tensor_mechanics/include/auxkernels/ElasticEnergyAux.h b/modules/tensor_mechanics/include/auxkernels/ElasticEnergyAux.h index 6aae78e7369e..02c76d867fb3 100644 --- a/modules/tensor_mechanics/include/auxkernels/ElasticEnergyAux.h +++ b/modules/tensor_mechanics/include/auxkernels/ElasticEnergyAux.h @@ -29,8 +29,10 @@ class ElasticEnergyAux : public AuxKernel protected: virtual Real computeValue(); + /// Base name of the material system used to calculate the elastic energy const std::string _base_name; + /// The stress tensor const MaterialProperty & _stress; const MaterialProperty & _elastic_strain; }; diff --git a/modules/tensor_mechanics/include/auxkernels/GlobalDisplacementAux.h b/modules/tensor_mechanics/include/auxkernels/GlobalDisplacementAux.h index 83a430aa3907..fe10965301b2 100644 --- a/modules/tensor_mechanics/include/auxkernels/GlobalDisplacementAux.h +++ b/modules/tensor_mechanics/include/auxkernels/GlobalDisplacementAux.h @@ -32,6 +32,8 @@ class GlobalDisplacementAux : public AuxKernel protected: const VariableValue & _scalar_global_strain; + + /// Component of the displacement vector const unsigned int _component; bool _output_global_disp; @@ -41,6 +43,10 @@ class GlobalDisplacementAux : public AuxKernel const Point _ref_point; const unsigned int _dim; + + /// Number of displacement variables const unsigned int _ndisp; + + /// Displacement variables std::vector _disp; }; diff --git a/modules/tensor_mechanics/include/bcs/DashpotBC.h b/modules/tensor_mechanics/include/bcs/DashpotBC.h index 154e5732bbec..6e12565e1d71 100644 --- a/modules/tensor_mechanics/include/bcs/DashpotBC.h +++ b/modules/tensor_mechanics/include/bcs/DashpotBC.h @@ -38,6 +38,7 @@ class DashpotBC : public IntegratedBC virtual Real computeQpOffDiagJacobian(unsigned int jvar); private: + /// Component of the velocity vector unsigned int _component; Real _coefficient; diff --git a/modules/tensor_mechanics/include/bcs/PenaltyInclinedNoDisplacementBC.h b/modules/tensor_mechanics/include/bcs/PenaltyInclinedNoDisplacementBC.h index 4acb6437dd29..4b9ebe934790 100644 --- a/modules/tensor_mechanics/include/bcs/PenaltyInclinedNoDisplacementBC.h +++ b/modules/tensor_mechanics/include/bcs/PenaltyInclinedNoDisplacementBC.h @@ -32,11 +32,14 @@ class PenaltyInclinedNoDisplacementBC : public IntegratedBC virtual Real computeQpJacobian() override; virtual Real computeQpOffDiagJacobian(unsigned int jvar) override; + // An integer corresponding to the direction const unsigned int _component; /// Coupled displacement variables unsigned int _ndisp; std::vector _disp; + + /// Variable IDs of coupled displacement variables std::vector _disp_var; private: diff --git a/modules/tensor_mechanics/include/kernels/ADDynamicStressDivergenceTensors.h b/modules/tensor_mechanics/include/kernels/ADDynamicStressDivergenceTensors.h index 1f4a2d5daa50..a84ae322fbed 100644 --- a/modules/tensor_mechanics/include/kernels/ADDynamicStressDivergenceTensors.h +++ b/modules/tensor_mechanics/include/kernels/ADDynamicStressDivergenceTensors.h @@ -34,8 +34,10 @@ class ADDynamicStressDivergenceTensors : public ADStressDivergenceTensors & _stress_older; const MaterialProperty & _stress_old; + ///@} // Rayleigh damping parameter _zeta and HHT time integration parameter _alpha const MaterialProperty & _zeta; diff --git a/modules/tensor_mechanics/include/kernels/ADStressDivergenceShell.h b/modules/tensor_mechanics/include/kernels/ADStressDivergenceShell.h index 137fad2bc10b..219600607998 100644 --- a/modules/tensor_mechanics/include/kernels/ADStressDivergenceShell.h +++ b/modules/tensor_mechanics/include/kernels/ADStressDivergenceShell.h @@ -46,6 +46,7 @@ class ADStressDivergenceShell : public ADKernel protected: virtual ADReal computeQpResidual() override; + /// An integer corresponding to the direction this kernel acts in const unsigned int _component; const bool _large_strain; diff --git a/modules/tensor_mechanics/include/kernels/ADStressDivergenceTensors.h b/modules/tensor_mechanics/include/kernels/ADStressDivergenceTensors.h index 04dc26ca03c1..cb3ae6126906 100644 --- a/modules/tensor_mechanics/include/kernels/ADStressDivergenceTensors.h +++ b/modules/tensor_mechanics/include/kernels/ADStressDivergenceTensors.h @@ -19,6 +19,8 @@ using ADStressDivergenceTensors::_ndisp; \ using ADStressDivergenceTensors::_disp_var; \ using ADStressDivergenceTensors::_avg_grad_test; \ + using ADStressDivergenceTensors::_out_of_plane_strain_coupled; \ + using ADStressDivergenceTensors::_out_of_plane_strain; \ using ADStressDivergenceTensors::_volumetric_locking_correction // Forward Declarations @@ -48,18 +50,30 @@ class ADStressDivergenceTensors : public ADKernel ADReal computeQpResidual() override; void precalculateResidual() override; + /// Base name of the material system that this kernel applies to const std::string _base_name; + /// The stress tensor that the divergence operator operates on const ADMaterialProperty(RankTwoTensor) & _stress; + + /// An integer corresponding to the direction this kernel acts in const unsigned int _component; - /// Coupled displacement variables + /// Number of coupled displacement variables const unsigned int _ndisp; + + /// Coupled displacement variable IDs std::vector _disp_var; /// Gradient of test function averaged over the element. Used in volumetric locking correction calculation. std::vector _avg_grad_test; + /// Whether out-of-plane strain is coupeld + const bool _out_of_plane_strain_coupled; + + /// Pointer to the out-of-plane strain variable + const ADVariableValue * _out_of_plane_strain; + /// Flag for volumetric locking correction const bool _volumetric_locking_correction; diff --git a/modules/tensor_mechanics/include/kernels/ADWeakPlaneStress.h b/modules/tensor_mechanics/include/kernels/ADWeakPlaneStress.h new file mode 100644 index 000000000000..5e2e112616f0 --- /dev/null +++ b/modules/tensor_mechanics/include/kernels/ADWeakPlaneStress.h @@ -0,0 +1,50 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADKernelValue.h" + +#define usingWeakPlaneStressMembers \ + usingKernelValueMembers; \ + using ADWeakPlaneStress::_base_name; \ + using ADWeakPlaneStress::_stress; \ + using ADWeakPlaneStress::_direction; + +// Forward Declarations +template +class ADWeakPlaneStress; + +declareADValidParams(ADWeakPlaneStress); + +/** + * ADWeakPlaneStress is the automatic differentiation version of WeakPlaneStress + */ +template +class ADWeakPlaneStress : public ADKernelValue +{ +public: + static InputParameters validParams(); + + ADWeakPlaneStress(const InputParameters & parameters); + +protected: + ADReal precomputeQpResidual() override; + + /// Base name of the material system that this kernel applies to + const std::string _base_name; + + /// The stress tensor that provides the out-of-plane stress + const ADMaterialProperty(RankTwoTensor) & _stress; + + /// The direction of the out-of-plane strain variable + const unsigned int _direction; + + usingKernelValueMembers; +}; diff --git a/modules/tensor_mechanics/include/kernels/AsymptoticExpansionHomogenizationKernel.h b/modules/tensor_mechanics/include/kernels/AsymptoticExpansionHomogenizationKernel.h index 79111919f5a5..c3a045a502ca 100644 --- a/modules/tensor_mechanics/include/kernels/AsymptoticExpansionHomogenizationKernel.h +++ b/modules/tensor_mechanics/include/kernels/AsymptoticExpansionHomogenizationKernel.h @@ -27,10 +27,13 @@ class AsymptoticExpansionHomogenizationKernel : public Kernel protected: virtual Real computeQpResidual(); + /// Base name of the material system that this kernel applies to const std::string _base_name; + const MaterialProperty & _elasticity_tensor; private: + /// An integer corresponding to the direction this kernel acts in const unsigned int _component; const unsigned int _column; const std::array _k_index; diff --git a/modules/tensor_mechanics/include/kernels/DynamicStressDivergenceTensors.h b/modules/tensor_mechanics/include/kernels/DynamicStressDivergenceTensors.h index b113c8dc5d47..b166eb74dc91 100644 --- a/modules/tensor_mechanics/include/kernels/DynamicStressDivergenceTensors.h +++ b/modules/tensor_mechanics/include/kernels/DynamicStressDivergenceTensors.h @@ -32,8 +32,10 @@ class DynamicStressDivergenceTensors : public StressDivergenceTensors virtual Real computeQpJacobian(); virtual Real computeQpOffDiagJacobian(unsigned int jvar); + ///{@ The old and older states of the stress tensor that the divergence operator operates on const MaterialProperty & _stress_older; const MaterialProperty & _stress_old; + ///@} // Rayleigh damping parameter _zeta and HHT time integration parameter _alpha const MaterialProperty & _zeta; diff --git a/modules/tensor_mechanics/include/kernels/GeneralizedPlaneStrainOffDiag.h b/modules/tensor_mechanics/include/kernels/GeneralizedPlaneStrainOffDiag.h index 4ef95a9c21a3..59610064f47d 100644 --- a/modules/tensor_mechanics/include/kernels/GeneralizedPlaneStrainOffDiag.h +++ b/modules/tensor_mechanics/include/kernels/GeneralizedPlaneStrainOffDiag.h @@ -46,13 +46,17 @@ class GeneralizedPlaneStrainOffDiag : public DerivativeMaterialInterface virtual void computeDispOffDiagJacobianScalar(unsigned int component, unsigned int jvar); virtual void computeTempOffDiagJacobianScalar(unsigned int jvar); + /// Base name of the material system that this kernel applies to const std::string _base_name; const MaterialProperty & _Jacobian_mult; const std::vector _eigenstrain_names; std::vector *> _deigenstrain_dT; + /// Variable number of the out-of-plane strain scalar variable unsigned int _scalar_out_of_plane_strain_var; + + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; const unsigned int _scalar_var_id; @@ -61,5 +65,6 @@ class GeneralizedPlaneStrainOffDiag : public DerivativeMaterialInterface const unsigned int _num_disp_var; std::vector _disp_var; + /// The direction of the out-of-plane strain unsigned int _scalar_out_of_plane_strain_direction; }; diff --git a/modules/tensor_mechanics/include/kernels/PhaseFieldFractureMechanicsOffDiag.h b/modules/tensor_mechanics/include/kernels/PhaseFieldFractureMechanicsOffDiag.h index 107adbccc529..f3388c7c0b6d 100644 --- a/modules/tensor_mechanics/include/kernels/PhaseFieldFractureMechanicsOffDiag.h +++ b/modules/tensor_mechanics/include/kernels/PhaseFieldFractureMechanicsOffDiag.h @@ -38,7 +38,10 @@ class PhaseFieldFractureMechanicsOffDiag : public DerivativeMaterialInterface & _stress; const MaterialProperty & _Jacobian_mult; @@ -59,10 +62,13 @@ class StressDivergenceTensors : public ALEKernel const MaterialProperty * _rotation_increment; // MaterialProperty & _d_stress_dT; + /// An integer corresponding to the direction this kernel acts in const unsigned int _component; /// Coupled displacement variables unsigned int _ndisp; + + /// Displacement variables IDs std::vector _disp_var; const bool _temp_coupled; diff --git a/modules/tensor_mechanics/include/kernels/StressDivergenceTensorsTruss.h b/modules/tensor_mechanics/include/kernels/StressDivergenceTensorsTruss.h index d3c4994013d7..050050148814 100644 --- a/modules/tensor_mechanics/include/kernels/StressDivergenceTensorsTruss.h +++ b/modules/tensor_mechanics/include/kernels/StressDivergenceTensorsTruss.h @@ -33,17 +33,25 @@ class StressDivergenceTensorsTruss : public Kernel virtual void computeOffDiagJacobian(MooseVariableFEBase & jvar) override; using Kernel::computeOffDiagJacobian; + /// Base name of the material system that this kernel applies to const std::string _base_name; const MaterialProperty & _axial_stress; const MaterialProperty & _e_over_l; private: + /// An integer corresponding to the direction this kernel acts in const unsigned int _component; + + /// Number of displacement variables const unsigned int _ndisp; + + /// Whether temperature is coupeld const bool _temp_coupled; const unsigned int _temp_var; + + /// Variable numbers of coupled displacement variables std::vector _disp_var; const VariableValue & _area; diff --git a/modules/tensor_mechanics/include/kernels/WeakPlaneStress.h b/modules/tensor_mechanics/include/kernels/WeakPlaneStress.h index 80674c2996b5..452c54bfad56 100644 --- a/modules/tensor_mechanics/include/kernels/WeakPlaneStress.h +++ b/modules/tensor_mechanics/include/kernels/WeakPlaneStress.h @@ -35,16 +35,23 @@ class WeakPlaneStress : public DerivativeMaterialInterface virtual Real computeQpJacobian() override; virtual Real computeQpOffDiagJacobian(unsigned int jvar) override; + /// Base name of the material system that this kernel applies to const std::string _base_name; + /// The stress tensor that provides the out-of-plane stress const MaterialProperty & _stress; const MaterialProperty & _Jacobian_mult; + /// The direction of the out-of-plane strain variable const unsigned int _direction; /// Coupled displacement variables const bool _disp_coupled; + + /// Number of displacement variables unsigned int _ndisp; + + /// Variable numbers of the displacement variables std::vector _disp_var; const bool _temp_coupled; diff --git a/modules/tensor_mechanics/include/materials/ADComputeElasticityTensorBase.h b/modules/tensor_mechanics/include/materials/ADComputeElasticityTensorBase.h index c39e7109aeb0..f39538c25b54 100644 --- a/modules/tensor_mechanics/include/materials/ADComputeElasticityTensorBase.h +++ b/modules/tensor_mechanics/include/materials/ADComputeElasticityTensorBase.h @@ -45,7 +45,9 @@ class ADComputeElasticityTensorBase : public ADMaterial, virtual void computeQpProperties(); virtual void computeQpElasticityTensor() = 0; + /// Base name of the material system const std::string _base_name; + std::string _elasticity_tensor_name; ADMaterialProperty(RankFourTensor) & _elasticity_tensor; diff --git a/modules/tensor_mechanics/include/materials/ADComputeFiniteStrainElasticStress.h b/modules/tensor_mechanics/include/materials/ADComputeFiniteStrainElasticStress.h index fcb7c918d8ea..828acb0a2215 100644 --- a/modules/tensor_mechanics/include/materials/ADComputeFiniteStrainElasticStress.h +++ b/modules/tensor_mechanics/include/materials/ADComputeFiniteStrainElasticStress.h @@ -48,8 +48,11 @@ class ADComputeFiniteStrainElasticStress : public ADComputeStressBase & _stress_old; /** diff --git a/modules/tensor_mechanics/include/materials/ADComputePlaneFiniteStrain.h b/modules/tensor_mechanics/include/materials/ADComputePlaneFiniteStrain.h new file mode 100644 index 000000000000..2701360adfcd --- /dev/null +++ b/modules/tensor_mechanics/include/materials/ADComputePlaneFiniteStrain.h @@ -0,0 +1,65 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADCompute2DFiniteStrain.h" +#include "SubblockIndexProvider.h" + +template +class ADComputePlaneFiniteStrain; + +declareADValidParams(ADComputePlaneFiniteStrain); + +/** + * ADComputePlaneFiniteStrain defines strain increment and rotation + * increment for finite strain under 2D planar assumptions. + */ +template +class ADComputePlaneFiniteStrain : public ADCompute2DFiniteStrain +{ +public: + static InputParameters validParams(); + + ADComputePlaneFiniteStrain(const InputParameters & parameters); + +protected: + virtual ADReal computeOutOfPlaneGradDisp() override; + virtual Real computeOutOfPlaneGradDispOld() override; + + /// gets its subblock index for current element + unsigned int getCurrentSubblockIndex() const + { + return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; + }; + + /// A Userobject that carries the subblock ID for all elements + const SubblockIndexProvider * _subblock_id_provider; + + /// Whether out-of-plane strain scalar variables are coupled + const bool _scalar_out_of_plane_strain_coupled; + + /// Number of out-of-plane strain scalar variables + unsigned int _nscalar_strains; + + ///{@ Current and old values of the out-of-plane strain scalar variable + std::vector _scalar_out_of_plane_strain; + std::vector _scalar_out_of_plane_strain_old; + ///@} + + /// Whether out-of-plane strain variables are coupled + const bool _out_of_plane_strain_coupled; + + ///{@ Current and old values of the out-of-plane strain variable + const ADVariableValue & _out_of_plane_strain; + const VariableValue & _out_of_plane_strain_old; + ///@} + + usingCompute2DFiniteStrainMembers; +}; diff --git a/modules/tensor_mechanics/include/materials/ADComputePlaneIncrementalStrain.h b/modules/tensor_mechanics/include/materials/ADComputePlaneIncrementalStrain.h new file mode 100644 index 000000000000..794d887aa6c5 --- /dev/null +++ b/modules/tensor_mechanics/include/materials/ADComputePlaneIncrementalStrain.h @@ -0,0 +1,66 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADCompute2DIncrementalStrain.h" +#include "SubblockIndexProvider.h" + +template +class ADComputePlaneIncrementalStrain; + +declareADValidParams(ADComputePlaneIncrementalStrain); + +/** + * ADComputePlaneIncrementalStrain defines strain increment + * for small strains in a 2D planar simulation. + */ + +template +class ADComputePlaneIncrementalStrain : public ADCompute2DIncrementalStrain +{ +public: + static InputParameters validParams(); + + ADComputePlaneIncrementalStrain(const InputParameters & parameters); + +protected: + virtual ADReal computeOutOfPlaneGradDisp() override; + virtual Real computeOutOfPlaneGradDispOld() override; + + /// gets its subblock index for current element + unsigned int getCurrentSubblockIndex() const + { + return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; + }; + + /// A Userobject that carries the subblock ID for all elements + const SubblockIndexProvider * _subblock_id_provider; + + /// Whether out-of-plane strain scalar variables are coupled + const bool _scalar_out_of_plane_strain_coupled; + + /// Number of out-of-plane strain scalar variables + unsigned int _nscalar_strains; + + ///{@ Current and old values of the out-of-plane strain scalar variable + std::vector _scalar_out_of_plane_strain; + std::vector _scalar_out_of_plane_strain_old; + ///@} + + /// Whether an out-of-plane strain variable is coupled + const bool _out_of_plane_strain_coupled; + + ///{@ Current and old values of the out-of-plane strain variable + const ADVariableValue & _out_of_plane_strain; + const VariableValue & _out_of_plane_strain_old; + ///@} + + usingCompute2DIncrementalStrainMembers; +}; diff --git a/modules/tensor_mechanics/include/materials/ADComputePlaneSmallStrain.h b/modules/tensor_mechanics/include/materials/ADComputePlaneSmallStrain.h new file mode 100644 index 000000000000..141b5de7e903 --- /dev/null +++ b/modules/tensor_mechanics/include/materials/ADComputePlaneSmallStrain.h @@ -0,0 +1,63 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADCompute2DSmallStrain.h" +#include "SubblockIndexProvider.h" + +template +class ADComputePlaneSmallStrain; + +declareADValidParams(ADComputePlaneSmallStrain); + +/** + * ADComputePlaneSmallStrain defines small strains under generalized + * plane strain and plane stress assumptions, where the out of plane strain + * can be uniformly or non-uniformly zero or nonzero. + */ +template +class ADComputePlaneSmallStrain : public ADCompute2DSmallStrain +{ +public: + static InputParameters validParams(); + + ADComputePlaneSmallStrain(const InputParameters & parameters); + +protected: + /// calculates and returns the out-of-plane strain for the current quadrature point + virtual ADReal computeOutOfPlaneStrain(); + + /// gets its subblock index for current element + unsigned int getCurrentSubblockIndex() const + { + return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; + }; + + /// A Userobject that carries the subblock ID for all elements + const SubblockIndexProvider * _subblock_id_provider; + +private: + /// Whether out-of-plane strain scalar variables are coupled + const bool _scalar_out_of_plane_strain_coupled; + + /// Whether an out-of-plane strain variable is coupled + const bool _out_of_plane_strain_coupled; + + /// The out-of-plane strain variable + const ADVariableValue & _out_of_plane_strain; + + /// Number of out-of-plane strain scalar variables + unsigned int _nscalar_strains; + + /// The out-of-plane strain scalar variables + std::vector _scalar_out_of_plane_strain; + + usingCompute2DSmallStrainMembers; +}; diff --git a/modules/tensor_mechanics/include/materials/ADComputeStrainBase.h b/modules/tensor_mechanics/include/materials/ADComputeStrainBase.h index c5b890c77b13..027aeb7b0186 100644 --- a/modules/tensor_mechanics/include/materials/ADComputeStrainBase.h +++ b/modules/tensor_mechanics/include/materials/ADComputeStrainBase.h @@ -54,9 +54,14 @@ class ADComputeStrainBase : public ADMaterial /// Coupled displacement variables const unsigned int _ndisp; + + /// Displacement variables std::vector _disp; + + /// Gradient of displacements std::vector _grad_disp; + /// Base name of the material system const std::string _base_name; ADMaterialProperty(RankTwoTensor) & _mechanical_strain; diff --git a/modules/tensor_mechanics/include/materials/ADComputeStrainIncrementBasedStress.h b/modules/tensor_mechanics/include/materials/ADComputeStrainIncrementBasedStress.h new file mode 100644 index 000000000000..e5f94ae31721 --- /dev/null +++ b/modules/tensor_mechanics/include/materials/ADComputeStrainIncrementBasedStress.h @@ -0,0 +1,54 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#pragma once + +#include "ADComputeStressBase.h" + +template +class ADComputeStrainIncrementBasedStress; + +declareADValidParams(ADComputeStrainIncrementBasedStress); + +/** + * ADComputeStrainIncrementBasedStress computes stress considering list of inelastic strain + * increments + */ +template +class ADComputeStrainIncrementBasedStress : public ADComputeStressBase +{ +public: + static InputParameters validParams(); + + ADComputeStrainIncrementBasedStress(const InputParameters & parameters); + +protected: + virtual void computeQpStress(); + + /// Name of the elasticity tensor material property + const std::string _elasticity_tensor_name; + /// Elasticity tensor material property + const MaterialProperty & _elasticity_tensor; + /// Old state of the stress tensor material property + const MaterialProperty & _stress_old; + /// Old state of the mechanical strain material property + const MaterialProperty & _mechanical_strain_old; + /// + ///@{ Vectors of current and old states of the inelastic strain material properties + std::vector *> _inelastic_strains; + std::vector *> _inelastic_strains_old; + ///@} + + /// Names of the inelastic strain material properties for all inelastic models + std::vector _inelastic_strain_names; + /// Number of inelastic models + unsigned int _num_inelastic_strain_models; + + usingComputeStressBaseMembers; +}; diff --git a/modules/tensor_mechanics/include/materials/ADComputeStressBase.h b/modules/tensor_mechanics/include/materials/ADComputeStressBase.h index 87bb898d8631..83c81314e3dc 100644 --- a/modules/tensor_mechanics/include/materials/ADComputeStressBase.h +++ b/modules/tensor_mechanics/include/materials/ADComputeStressBase.h @@ -50,9 +50,12 @@ class ADComputeStressBase : public ADMaterial virtual void computeQpProperties() override; virtual void computeQpStress() = 0; + /// Base name of the material system const std::string _base_name; const ADMaterialProperty(RankTwoTensor) & _mechanical_strain; + + /// The stress tensor to be calculated ADMaterialProperty(RankTwoTensor) & _stress; ADMaterialProperty(RankTwoTensor) & _elastic_strain; diff --git a/modules/tensor_mechanics/include/materials/CompositeElasticityTensor.h b/modules/tensor_mechanics/include/materials/CompositeElasticityTensor.h index 3679ba5555f9..4fa8cee55883 100644 --- a/modules/tensor_mechanics/include/materials/CompositeElasticityTensor.h +++ b/modules/tensor_mechanics/include/materials/CompositeElasticityTensor.h @@ -36,6 +36,7 @@ class CompositeElasticityTensor : public CompositeTensorBase _scalar_out_of_plane_strain; std::vector _scalar_out_of_plane_strain_old; + ///@} }; diff --git a/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DIncrementalStrain.h b/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DIncrementalStrain.h index 0d4d041ee9b1..d64ae209064f 100644 --- a/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DIncrementalStrain.h +++ b/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DIncrementalStrain.h @@ -55,14 +55,25 @@ class ComputeAxisymmetric1DIncrementalStrain : public Compute1DIncrementalStrain /// the old value of the first component of the displacements vector const VariableValue & _disp_old_0; + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; + /// Whether an out-of-plane strain variable is coupled bool _has_out_of_plane_strain; + + ///{@ Current and old values of the out-of-plane strain variable const VariableValue & _out_of_plane_strain; const VariableValue & _out_of_plane_strain_old; + ///@} + /// Whether an out-of-plane strain scalar variable is coupled bool _has_scalar_out_of_plane_strain; + + /// Number of out-of-plane strain scalar variables unsigned int _nscalar_strains; + + ///{@ Current and old values of the out-of-plane strain scalar variable std::vector _scalar_out_of_plane_strain; std::vector _scalar_out_of_plane_strain_old; + ///@} }; diff --git a/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DSmallStrain.h b/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DSmallStrain.h index b12bee71e8ca..2028b82b6afb 100644 --- a/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DSmallStrain.h +++ b/modules/tensor_mechanics/include/materials/ComputeAxisymmetric1DSmallStrain.h @@ -44,12 +44,21 @@ class ComputeAxisymmetric1DSmallStrain : public Compute1DSmallStrain return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; }; + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; + /// Whether an out-of-plane strain variable is coupled const bool _has_out_of_plane_strain; + + /// The out-of-plane strain variable const VariableValue & _out_of_plane_strain; + /// Whether out-of-plane strain scalar variables are coupled const bool _has_scalar_out_of_plane_strain; + + /// Number of out-of-plane strain scalar variables unsigned int _nscalar_strains; + + /// The out-of-plane strain scalar variables std::vector _scalar_out_of_plane_strain; }; diff --git a/modules/tensor_mechanics/include/materials/ComputeDeformGradBasedStress.h b/modules/tensor_mechanics/include/materials/ComputeDeformGradBasedStress.h index e8949e77b63e..6ce69a7ab4f2 100644 --- a/modules/tensor_mechanics/include/materials/ComputeDeformGradBasedStress.h +++ b/modules/tensor_mechanics/include/materials/ComputeDeformGradBasedStress.h @@ -38,6 +38,8 @@ class ComputeDeformGradBasedStress : public DerivativeMaterialInterface & _deformation_gradient; const MaterialProperty & _elasticity_tensor; + /// The stress tensor to be calculated MaterialProperty & _stress; + MaterialProperty & _Jacobian_mult; }; diff --git a/modules/tensor_mechanics/include/materials/ComputeElasticityTensorBase.h b/modules/tensor_mechanics/include/materials/ComputeElasticityTensorBase.h index 229450f5a80f..852d55de72d4 100644 --- a/modules/tensor_mechanics/include/materials/ComputeElasticityTensorBase.h +++ b/modules/tensor_mechanics/include/materials/ComputeElasticityTensorBase.h @@ -34,7 +34,9 @@ class ComputeElasticityTensorBase : public DerivativeMaterialInterface virtual void computeQpProperties(); virtual void computeQpElasticityTensor() = 0; + /// Base name of the material system const std::string _base_name; + std::string _elasticity_tensor_name; MaterialProperty & _elasticity_tensor; diff --git a/modules/tensor_mechanics/include/materials/ComputeExtraStressBase.h b/modules/tensor_mechanics/include/materials/ComputeExtraStressBase.h index 3f0fa70d0d77..4b2869805dca 100644 --- a/modules/tensor_mechanics/include/materials/ComputeExtraStressBase.h +++ b/modules/tensor_mechanics/include/materials/ComputeExtraStressBase.h @@ -32,6 +32,7 @@ class ComputeExtraStressBase : public Material virtual void computeQpProperties(); virtual void computeQpExtraStress() = 0; + /// Base name of the material system const std::string _base_name; std::string _extra_stress_name; diff --git a/modules/tensor_mechanics/include/materials/ComputeGlobalStrain.h b/modules/tensor_mechanics/include/materials/ComputeGlobalStrain.h index d8984dcef00e..61bf9c80ade5 100644 --- a/modules/tensor_mechanics/include/materials/ComputeGlobalStrain.h +++ b/modules/tensor_mechanics/include/materials/ComputeGlobalStrain.h @@ -45,5 +45,7 @@ class ComputeGlobalStrain : public Material const VectorValue & _periodic_dir; const unsigned int _dim; + + /// Number of displacement variables const unsigned int _ndisp; }; diff --git a/modules/tensor_mechanics/include/materials/ComputePlaneFiniteStrain.h b/modules/tensor_mechanics/include/materials/ComputePlaneFiniteStrain.h index ad76335af566..c5bd45fb93bf 100644 --- a/modules/tensor_mechanics/include/materials/ComputePlaneFiniteStrain.h +++ b/modules/tensor_mechanics/include/materials/ComputePlaneFiniteStrain.h @@ -38,14 +38,25 @@ class ComputePlaneFiniteStrain : public Compute2DFiniteStrain return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; }; + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; + /// Whether out-of-plane strain scalar variables are coupled const bool _scalar_out_of_plane_strain_coupled; + + /// Number of out-of-plane strain scalar variables unsigned int _nscalar_strains; + + ///{@ Current and old values of the out-of-plane strain scalar variable std::vector _scalar_out_of_plane_strain; std::vector _scalar_out_of_plane_strain_old; + ///@} + /// Whether an out-of-plane strain variable is coupled const bool _out_of_plane_strain_coupled; + + ///{@ Current and old values of the out-of-plane strain variable const VariableValue & _out_of_plane_strain; const VariableValue & _out_of_plane_strain_old; + ///@} }; diff --git a/modules/tensor_mechanics/include/materials/ComputePlaneIncrementalStrain.h b/modules/tensor_mechanics/include/materials/ComputePlaneIncrementalStrain.h index ad72e8eaca17..b3aa639d38d3 100644 --- a/modules/tensor_mechanics/include/materials/ComputePlaneIncrementalStrain.h +++ b/modules/tensor_mechanics/include/materials/ComputePlaneIncrementalStrain.h @@ -38,14 +38,25 @@ class ComputePlaneIncrementalStrain : public Compute2DIncrementalStrain return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; }; + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; + /// Whether out-of-plane strain scalar variables are coupled const bool _scalar_out_of_plane_strain_coupled; + + /// Number of out-of-plane strain scalar variables unsigned int _nscalar_strains; + + ///{@ Current and old values of the out-of-plane strain scalar variable std::vector _scalar_out_of_plane_strain; std::vector _scalar_out_of_plane_strain_old; + ///@} + /// Whether an out-of-plane strain variable is coupled const bool _out_of_plane_strain_coupled; + + ///{@ Current and old values of the out-of-plane strain variable const VariableValue & _out_of_plane_strain; const VariableValue & _out_of_plane_strain_old; + ///@} }; diff --git a/modules/tensor_mechanics/include/materials/ComputePlaneSmallStrain.h b/modules/tensor_mechanics/include/materials/ComputePlaneSmallStrain.h index d3b3c642ee89..9bb2db393c64 100644 --- a/modules/tensor_mechanics/include/materials/ComputePlaneSmallStrain.h +++ b/modules/tensor_mechanics/include/materials/ComputePlaneSmallStrain.h @@ -38,13 +38,22 @@ class ComputePlaneSmallStrain : public Compute2DSmallStrain return _subblock_id_provider ? _subblock_id_provider->getSubblockIndex(*_current_elem) : 0; }; + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; private: + /// Whether out-of-plane strain scalar variables are coupled const bool _scalar_out_of_plane_strain_coupled; + /// Whether an out-of-plane strain variable is coupled const bool _out_of_plane_strain_coupled; + + /// The out-of-plane strain variable const VariableValue & _out_of_plane_strain; + + /// Number of out-of-plane strain scalar variables unsigned int _nscalar_strains; + + /// The out-of-plane strain scalar variables std::vector _scalar_out_of_plane_strain; }; diff --git a/modules/tensor_mechanics/include/materials/ComputeStrainBase.h b/modules/tensor_mechanics/include/materials/ComputeStrainBase.h index b1ab6a1e104e..c4d493441e0e 100644 --- a/modules/tensor_mechanics/include/materials/ComputeStrainBase.h +++ b/modules/tensor_mechanics/include/materials/ComputeStrainBase.h @@ -38,9 +38,14 @@ class ComputeStrainBase : public DerivativeMaterialInterface /// Coupled displacement variables unsigned int _ndisp; + + /// Displacement variables std::vector _disp; + + /// Gradient of displacements std::vector _grad_disp; + /// Base name of the material system const std::string _base_name; MaterialProperty & _mechanical_strain; diff --git a/modules/tensor_mechanics/include/materials/ComputeStrainIncrementBasedStress.h b/modules/tensor_mechanics/include/materials/ComputeStrainIncrementBasedStress.h index c2504918af71..04d44e985453 100644 --- a/modules/tensor_mechanics/include/materials/ComputeStrainIncrementBasedStress.h +++ b/modules/tensor_mechanics/include/materials/ComputeStrainIncrementBasedStress.h @@ -36,10 +36,9 @@ class ComputeStrainIncrementBasedStress : public ComputeStressBase const MaterialProperty & _elasticity_tensor; /// Old state of the stress tensor material property const MaterialProperty & _stress_old; - ///@{ Current and old states of the mechanical strain material property - const MaterialProperty & _mechanical_strain; + /// Old state of the mechanical strain material property const MaterialProperty & _mechanical_strain_old; - ///@} + ///@{ Vectors of current and old states of the inelastic strain material properties std::vector *> _inelastic_strains; std::vector *> _inelastic_strains_old; diff --git a/modules/tensor_mechanics/include/materials/EshelbyTensor.h b/modules/tensor_mechanics/include/materials/EshelbyTensor.h index c01fb17f63e1..67c0ecffc038 100644 --- a/modules/tensor_mechanics/include/materials/EshelbyTensor.h +++ b/modules/tensor_mechanics/include/materials/EshelbyTensor.h @@ -35,12 +35,18 @@ class EshelbyTensor : public DerivativeMaterialInterface virtual void computeQpProperties() override; protected: + /// Base name of the material system const std::string _base_name; const MaterialProperty & _sed; MaterialProperty & _eshelby_tensor; + + /// The stress tensor const MaterialProperty & _stress; + + /// The odl stress tensor const MaterialProperty & _stress_old; + std::vector _grad_disp; MaterialProperty & _J_thermal_term_vec; diff --git a/modules/tensor_mechanics/include/materials/FiniteStrainPlasticMaterial.h b/modules/tensor_mechanics/include/materials/FiniteStrainPlasticMaterial.h index fa08d391c1b4..aeddbceeeef8 100644 --- a/modules/tensor_mechanics/include/materials/FiniteStrainPlasticMaterial.h +++ b/modules/tensor_mechanics/include/materials/FiniteStrainPlasticMaterial.h @@ -10,7 +10,6 @@ #pragma once // Original class author: A.M. Jokisaari, O. Heinonen - #include "ComputeStressBase.h" class FiniteStrainPlasticMaterial; @@ -41,6 +40,7 @@ class FiniteStrainPlasticMaterial : public ComputeStressBase const MaterialProperty & _plastic_strain_old; MaterialProperty & _eqv_plastic_strain; const MaterialProperty & _eqv_plastic_strain_old; + /// The old stress tensor const MaterialProperty & _stress_old; const MaterialProperty & _strain_increment; const MaterialProperty & _rotation_increment; diff --git a/modules/tensor_mechanics/include/materials/InclusionProperties.h b/modules/tensor_mechanics/include/materials/InclusionProperties.h index 043acffc6ade..d1b98607d692 100644 --- a/modules/tensor_mechanics/include/materials/InclusionProperties.h +++ b/modules/tensor_mechanics/include/materials/InclusionProperties.h @@ -62,6 +62,7 @@ class InclusionProperties : public Material RankTwoTensor _elastic_strain_int; Real _elastic_energy_int; + /// The stress tensor MaterialProperty & _stress; MaterialProperty & _strain; MaterialProperty & _elastic_energy; diff --git a/modules/tensor_mechanics/include/materials/MultiPhaseStressMaterial.h b/modules/tensor_mechanics/include/materials/MultiPhaseStressMaterial.h index e8d98434450d..8c7b54ddbc98 100644 --- a/modules/tensor_mechanics/include/materials/MultiPhaseStressMaterial.h +++ b/modules/tensor_mechanics/include/materials/MultiPhaseStressMaterial.h @@ -52,7 +52,11 @@ class MultiPhaseStressMaterial : public Material std::vector *> _dphase_stress_dstrain; // global material properties + + /// Base name of the material system const std::string _base_name; + + /// The stress tensor MaterialProperty & _stress; MaterialProperty & _dstress_dstrain; }; diff --git a/modules/tensor_mechanics/include/materials/StrainEnergyDensity.h b/modules/tensor_mechanics/include/materials/StrainEnergyDensity.h index 8beaf35b8042..fdda748d9d4c 100644 --- a/modules/tensor_mechanics/include/materials/StrainEnergyDensity.h +++ b/modules/tensor_mechanics/include/materials/StrainEnergyDensity.h @@ -36,6 +36,7 @@ class StrainEnergyDensity : public DerivativeMaterialInterface virtual void computeQpProperties() override; protected: + /// Base name of the material system const std::string _base_name; /// Whether the material model is a total or incremental model @@ -45,9 +46,10 @@ class StrainEnergyDensity : public DerivativeMaterialInterface MaterialProperty & _strain_energy_density; const MaterialProperty & _strain_energy_density_old; - /// Current and old values of stress + ///{@ Current and old values of stress const MaterialProperty & _stress; const MaterialProperty & _stress_old; + ///@} /// Current value of mechanical strain which includes elastic and /// inelastic components of the strain diff --git a/modules/tensor_mechanics/include/materials/StressBasedChemicalPotential.h b/modules/tensor_mechanics/include/materials/StressBasedChemicalPotential.h index 36b1f202432e..1c8fcdd318ce 100644 --- a/modules/tensor_mechanics/include/materials/StressBasedChemicalPotential.h +++ b/modules/tensor_mechanics/include/materials/StressBasedChemicalPotential.h @@ -37,6 +37,7 @@ class StressBasedChemicalPotential : public DerivativeMaterialInterface & _chemical_potential; MaterialProperty * _dchemical_potential; + /// The old stress tensor const MaterialProperty & _stress_old; const MaterialProperty & _direction_tensor; const MaterialProperty & _prefactor; diff --git a/modules/tensor_mechanics/include/materials/ThermalFractureIntegral.h b/modules/tensor_mechanics/include/materials/ThermalFractureIntegral.h index eee943fc43c1..47acf0034ce7 100644 --- a/modules/tensor_mechanics/include/materials/ThermalFractureIntegral.h +++ b/modules/tensor_mechanics/include/materials/ThermalFractureIntegral.h @@ -35,6 +35,7 @@ class ThermalFractureIntegral : public DerivativeMaterialInterface virtual void computeQpProperties() override; protected: + /// Base name of the material system const std::string _base_name; const std::vector _eigenstrain_names; std::vector *> _deigenstrain_dT; diff --git a/modules/tensor_mechanics/include/materials/TrussMaterial.h b/modules/tensor_mechanics/include/materials/TrussMaterial.h index 2e4a92588921..a817a07998f4 100644 --- a/modules/tensor_mechanics/include/materials/TrussMaterial.h +++ b/modules/tensor_mechanics/include/materials/TrussMaterial.h @@ -33,8 +33,10 @@ class TrussMaterial : public Material std::vector _disp_var; + /// Base name of the material system const std::string _base_name; + /// Number of displacement variables unsigned int _ndisp; const VariableValue & _youngs_modulus; diff --git a/modules/tensor_mechanics/include/materials/VolumeDeformGradCorrectedStress.h b/modules/tensor_mechanics/include/materials/VolumeDeformGradCorrectedStress.h index f4aeb881377f..51d1f1944b79 100644 --- a/modules/tensor_mechanics/include/materials/VolumeDeformGradCorrectedStress.h +++ b/modules/tensor_mechanics/include/materials/VolumeDeformGradCorrectedStress.h @@ -40,6 +40,7 @@ class VolumeDeformGradCorrectedStress : public DerivativeMaterialInterface & _deformation_gradient; const MaterialProperty * _pre_Jacobian_mult; + /// The stress tensor transformed to the current configuration MaterialProperty & _stress; MaterialProperty * _Jacobian_mult; }; diff --git a/modules/tensor_mechanics/include/postprocessors/AsymptoticExpansionHomogenizationElasticConstants.h b/modules/tensor_mechanics/include/postprocessors/AsymptoticExpansionHomogenizationElasticConstants.h index 67dc2917026c..e93c8c480027 100644 --- a/modules/tensor_mechanics/include/postprocessors/AsymptoticExpansionHomogenizationElasticConstants.h +++ b/modules/tensor_mechanics/include/postprocessors/AsymptoticExpansionHomogenizationElasticConstants.h @@ -36,6 +36,7 @@ class AsymptoticExpansionHomogenizationElasticConstants : public ElementIntegral virtual Real computeQpIntegral(); private: + /// Base name of the material system const std::string _base_name; const std::array, 6> _grad; diff --git a/modules/tensor_mechanics/include/userobjects/GeneralizedPlaneStrainUserObject.h b/modules/tensor_mechanics/include/userobjects/GeneralizedPlaneStrainUserObject.h index 3d6088c073b1..6b5654e252ee 100644 --- a/modules/tensor_mechanics/include/userobjects/GeneralizedPlaneStrainUserObject.h +++ b/modules/tensor_mechanics/include/userobjects/GeneralizedPlaneStrainUserObject.h @@ -40,15 +40,21 @@ class GeneralizedPlaneStrainUserObject : public ElementUserObject virtual Real returnJacobian(unsigned int scalar_var_id = 0) const; protected: + /// Base name of the material system const std::string _base_name; const MaterialProperty & _Cijkl; + + /// The stress tensor const MaterialProperty & _stress; + /// A Userobject that carries the subblock ID for all elements const SubblockIndexProvider * _subblock_id_provider; const Function & _out_of_plane_pressure; const Real _factor; + + /// The direction of the out-of-plane strain scalar variable unsigned int _scalar_out_of_plane_strain_direction; std::vector _residual; std::vector _reference_residual; diff --git a/modules/tensor_mechanics/include/userobjects/GlobalStrainUserObject.h b/modules/tensor_mechanics/include/userobjects/GlobalStrainUserObject.h index 9842904b9a10..9f75596fd8b1 100644 --- a/modules/tensor_mechanics/include/userobjects/GlobalStrainUserObject.h +++ b/modules/tensor_mechanics/include/userobjects/GlobalStrainUserObject.h @@ -41,9 +41,12 @@ class GlobalStrainUserObject : public ElementUserObject, public GlobalStrainUser virtual void computeAdditionalStress(){}; protected: + /// Base name of the material system const std::string _base_name; const MaterialProperty & _dstress_dstrain; + + /// The stress tensor const MaterialProperty & _stress; RankTwoTensor _applied_stress_tensor; @@ -51,7 +54,11 @@ class GlobalStrainUserObject : public ElementUserObject, public GlobalStrainUser RankFourTensor _jacobian; const unsigned int _dim; + + /// Number of displacement variables const unsigned int _ndisp; + + /// Variable numbers of the displacement variables std::vector _disp_var; VectorValue _periodic_dir; }; diff --git a/modules/tensor_mechanics/include/userobjects/HEVPFlowRateUOBase.h b/modules/tensor_mechanics/include/userobjects/HEVPFlowRateUOBase.h index bd0ee646ce2b..1c71e139b75f 100644 --- a/modules/tensor_mechanics/include/userobjects/HEVPFlowRateUOBase.h +++ b/modules/tensor_mechanics/include/userobjects/HEVPFlowRateUOBase.h @@ -37,6 +37,8 @@ class HEVPFlowRateUOBase : public DiscreteElementUserObject protected: std::string _strength_prop_name; + + /// Base name of the material system const std::string _base_name; const MaterialProperty & _strength; std::string _pk2_prop_name; diff --git a/modules/tensor_mechanics/src/actions/TensorMechanicsAction.C b/modules/tensor_mechanics/src/actions/TensorMechanicsAction.C index d724705dc391..eb53ab612971 100644 --- a/modules/tensor_mechanics/src/actions/TensorMechanicsAction.C +++ b/modules/tensor_mechanics/src/actions/TensorMechanicsAction.C @@ -186,7 +186,7 @@ TensorMechanicsAction::act() if (_planar_formulation == PlanarFormulation::GeneralizedPlaneStrain) { if (_use_ad) - paramError("use_ad", "AD not setup for use with PlaneStrain"); + paramError("use_automatic_differentiation", "AD not setup for use with PlaneStrain"); // Set the action parameters const std::string type = "GeneralizedPlaneStrainAction"; auto action_params = _action_factory.getValidParams(type); @@ -265,10 +265,10 @@ TensorMechanicsAction::act() _planar_formulation == PlanarFormulation::PlaneStrain || _planar_formulation == PlanarFormulation::GeneralizedPlaneStrain) { - if (_use_ad) - paramError( - "use_ad", - "AD not setup for use with WeakPlaneStress, PlaneStrain, or GeneralizedPlaneStrain"); + if (_use_ad && (_planar_formulation == PlanarFormulation::PlaneStrain || + _planar_formulation == PlanarFormulation::GeneralizedPlaneStrain)) + paramError("use_automatic_differentiation", + "AD not setup for use with PlaneStrain or GeneralizedPlaneStrain"); std::map, std::string> type_map = { {{Moose::COORD_XYZ, StrainAndIncrement::SmallTotal}, "ComputePlaneSmallStrain"}, @@ -370,10 +370,20 @@ TensorMechanicsAction::act() if (_planar_formulation == PlanarFormulation::WeakPlaneStress) { - auto params = getKernelParameters("WeakPlaneStress"); + auto params = getKernelParameters(ad_prepend + "WeakPlaneStress" + ad_append); std::string wps_kernel_name = "TM_WPS_" + name(); params.set("variable") = getParam("out_of_plane_strain"); - _problem->addKernel("WeakPlaneStress", wps_kernel_name, params); + + if (_use_ad) + { + _problem->addKernel( + ad_prepend + "WeakPlaneStress" + "", wps_kernel_name + "_residual", params); + _problem->addKernel( + ad_prepend + "WeakPlaneStress" + "", wps_kernel_name + "_jacobian", params); + _problem->haveADObjects(true); + } + else + _problem->addKernel("WeakPlaneStress", wps_kernel_name, params); } } } @@ -544,12 +554,9 @@ InputParameters TensorMechanicsAction::getKernelParameters(std::string type) { InputParameters params = _factory.getValidParams(type); - params.applyParameters(parameters(), - {"displacements", - "use_displaced_mesh", - "save_in", - "diag_save_in", - "out_of_plane_strain"}); + params.applyParameters( + parameters(), + {"displacements", "use_displaced_mesh", "save_in", "diag_save_in", "out_of_plane_strain"}); params.set>("displacements") = _coupled_displacements; params.set("use_displaced_mesh") = _use_displaced_mesh; diff --git a/modules/tensor_mechanics/src/kernels/ADStressDivergenceTensors.C b/modules/tensor_mechanics/src/kernels/ADStressDivergenceTensors.C index 698f5718e352..0321a9d1eb4a 100644 --- a/modules/tensor_mechanics/src/kernels/ADStressDivergenceTensors.C +++ b/modules/tensor_mechanics/src/kernels/ADStressDivergenceTensors.C @@ -29,6 +29,9 @@ ADStressDivergenceTensors::validParams() params.addRequiredCoupledVar("displacements", "The string of displacements suitable for the problem statement"); params.addParam("base_name", "Material property base name"); + params.addCoupledVar("out_of_plane_strain", + "The name of the out_of_plane_strain variable used in the " + "WeakPlaneStress kernel."); params.set("use_displaced_mesh") = false; params.addParam("volumetric_locking_correction", false, @@ -46,6 +49,9 @@ ADStressDivergenceTensors::ADStressDivergenceTensors( _ndisp(coupledComponents("displacements")), _disp_var(_ndisp), _avg_grad_test(), + _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")), + _out_of_plane_strain(_out_of_plane_strain_coupled ? &adCoupledValue("out_of_plane_strain") + : nullptr), _volumetric_locking_correction(getParam("volumetric_locking_correction")) { for (unsigned int i = 0; i < _ndisp; ++i) @@ -77,6 +83,12 @@ ADStressDivergenceTensors::computeQpResidual() if (_volumetric_locking_correction) residual += (_avg_grad_test[_i] - _grad_test[_i][_qp](_component)) / 3.0 * _stress[_qp].trace(); + if (_ndisp != 3 && _out_of_plane_strain_coupled && _use_displaced_mesh) + { + const ADReal out_of_plane_thickness = std::exp((*_out_of_plane_strain)[_qp]); + residual *= out_of_plane_thickness; + } + return residual; } diff --git a/modules/tensor_mechanics/src/kernels/ADWeakPlaneStress.C b/modules/tensor_mechanics/src/kernels/ADWeakPlaneStress.C new file mode 100644 index 000000000000..c2471003bcdf --- /dev/null +++ b/modules/tensor_mechanics/src/kernels/ADWeakPlaneStress.C @@ -0,0 +1,46 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADWeakPlaneStress.h" + +registerADMooseObject("TensorMechanicsApp", ADWeakPlaneStress); + +defineADLegacyParams(ADWeakPlaneStress); + +template +InputParameters +ADWeakPlaneStress::validParams() +{ + InputParameters params = ADKernelValue::validParams(); + params.addClassDescription("Plane stress kernel to provide out-of-plane strain contribution."); + params.addParam("base_name", "Material property base name"); + MooseEnum direction("x y z", "z"); + params.addParam("out_of_plane_strain_direction", + direction, + "The direction of the out-of-plane strain variable"); + params.set("use_displaced_mesh") = false; + + return params; +} + +template +ADWeakPlaneStress::ADWeakPlaneStress(const InputParameters & parameters) + : ADKernelValue(parameters), + _base_name(isParamValid("base_name") ? getParam("base_name") + "_" : ""), + _stress(getADMaterialProperty(_base_name + "stress")), + _direction(getParam("out_of_plane_strain_direction")) +{ +} + +template +ADReal +ADWeakPlaneStress::precomputeQpResidual() +{ + return _stress[_qp](_direction, _direction); +} diff --git a/modules/tensor_mechanics/src/materials/ADComputePlaneFiniteStrain.C b/modules/tensor_mechanics/src/materials/ADComputePlaneFiniteStrain.C new file mode 100644 index 000000000000..3e845e31017e --- /dev/null +++ b/modules/tensor_mechanics/src/materials/ADComputePlaneFiniteStrain.C @@ -0,0 +1,84 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADComputePlaneFiniteStrain.h" + +registerADMooseObject("TensorMechanicsApp", ADComputePlaneFiniteStrain); + +defineADLegacyParams(ADComputePlaneFiniteStrain); + +template +InputParameters +ADComputePlaneFiniteStrain::validParams() +{ + InputParameters params = ADCompute2DFiniteStrain::validParams(); + params.addClassDescription("Compute strain increment and rotation increment for finite strain " + "under 2D planar assumptions."); + params.addParam("subblock_index_provider", + "SubblockIndexProvider user object name"); + params.addCoupledVar("scalar_out_of_plane_strain", + "Scalar variable for generalized plane strain"); + params.addCoupledVar("out_of_plane_strain", "Nonlinear variable for plane stress condition"); + + return params; +} + +template +ADComputePlaneFiniteStrain::ADComputePlaneFiniteStrain( + const InputParameters & parameters) + : ADCompute2DFiniteStrain(parameters), + _subblock_id_provider(isParamValid("subblock_index_provider") + ? &getUserObject("subblock_index_provider") + : nullptr), + _scalar_out_of_plane_strain_coupled(isParamValid("scalar_out_of_plane_strain")), + _nscalar_strains(coupledScalarComponents("scalar_out_of_plane_strain")), + _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")), + _out_of_plane_strain(_out_of_plane_strain_coupled ? adCoupledValue("out_of_plane_strain") + : adZeroValue()), + _out_of_plane_strain_old(_out_of_plane_strain_coupled ? coupledValueOld("out_of_plane_strain") + : _zero) +{ + if (_out_of_plane_strain_coupled && _scalar_out_of_plane_strain_coupled) + mooseError("Must define only one of out_of_plane_strain or scalar_out_of_plane_strain"); + + if (_scalar_out_of_plane_strain_coupled) + { + _scalar_out_of_plane_strain.resize(_nscalar_strains); + _scalar_out_of_plane_strain_old.resize(_nscalar_strains); + for (unsigned int i = 0; i < _nscalar_strains; ++i) + { + _scalar_out_of_plane_strain[i] = &adCoupledScalarValue("scalar_out_of_plane_strain", i); + _scalar_out_of_plane_strain_old[i] = &coupledScalarValueOld("scalar_out_of_plane_strain", i); + } + } +} + +template +ADReal +ADComputePlaneFiniteStrain::computeOutOfPlaneGradDisp() +{ + /** + * This is consistent with the approximation of stretch rate tensor + * D = log(sqrt(Fhat^T * Fhat)) / dt + */ + if (_scalar_out_of_plane_strain_coupled) + return std::exp((*_scalar_out_of_plane_strain[getCurrentSubblockIndex()])[0]) - 1.0; + else + return std::exp(_out_of_plane_strain[_qp]) - 1.0; +} + +template +Real +ADComputePlaneFiniteStrain::computeOutOfPlaneGradDispOld() +{ + if (_scalar_out_of_plane_strain_coupled) + return std::exp((*_scalar_out_of_plane_strain_old[getCurrentSubblockIndex()])[0]) - 1.0; + else + return std::exp(_out_of_plane_strain_old[_qp]) - 1.0; +} diff --git a/modules/tensor_mechanics/src/materials/ADComputePlaneIncrementalStrain.C b/modules/tensor_mechanics/src/materials/ADComputePlaneIncrementalStrain.C new file mode 100644 index 000000000000..25be1237d495 --- /dev/null +++ b/modules/tensor_mechanics/src/materials/ADComputePlaneIncrementalStrain.C @@ -0,0 +1,80 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADComputePlaneIncrementalStrain.h" + +registerADMooseObject("TensorMechanicsApp", ADComputePlaneIncrementalStrain); + +defineADLegacyParams(ADComputePlaneIncrementalStrain); + +template +InputParameters +ADComputePlaneIncrementalStrain::validParams() +{ + InputParameters params = ADCompute2DIncrementalStrain::validParams(); + params.addClassDescription( + "Compute strain increment for small strain under 2D planar assumptions."); + params.addParam("subblock_index_provider", + "SubblockIndexProvider user object name"); + params.addCoupledVar("scalar_out_of_plane_strain", + "Scalar variable for generalized plane strain"); + params.addCoupledVar("out_of_plane_strain", "Nonlinear variable for plane stress condition"); + + return params; +} + +template +ADComputePlaneIncrementalStrain::ADComputePlaneIncrementalStrain( + const InputParameters & parameters) + : ADCompute2DIncrementalStrain(parameters), + _subblock_id_provider(isParamValid("subblock_index_provider") + ? &getUserObject("subblock_index_provider") + : nullptr), + _scalar_out_of_plane_strain_coupled(isParamValid("scalar_out_of_plane_strain")), + _nscalar_strains(coupledScalarComponents("scalar_out_of_plane_strain")), + _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")), + _out_of_plane_strain(_out_of_plane_strain_coupled ? adCoupledValue("out_of_plane_strain") + : adZeroValue()), + _out_of_plane_strain_old(_out_of_plane_strain_coupled ? coupledValueOld("out_of_plane_strain") + : _zero) +{ + if (_out_of_plane_strain_coupled && _scalar_out_of_plane_strain_coupled) + mooseError("Must define only one of out_of_plane_strain or scalar_out_of_plane_strain"); + + if (_scalar_out_of_plane_strain_coupled) + { + _scalar_out_of_plane_strain.resize(_nscalar_strains); + _scalar_out_of_plane_strain_old.resize(_nscalar_strains); + for (unsigned int i = 0; i < _nscalar_strains; ++i) + { + _scalar_out_of_plane_strain[i] = &adCoupledScalarValue("scalar_out_of_plane_strain", i); + _scalar_out_of_plane_strain_old[i] = &coupledScalarValueOld("scalar_out_of_plane_strain", i); + } + } +} + +template +ADReal +ADComputePlaneIncrementalStrain::computeOutOfPlaneGradDisp() +{ + if (_scalar_out_of_plane_strain_coupled) + return (*_scalar_out_of_plane_strain[getCurrentSubblockIndex()])[0]; + else + return _out_of_plane_strain[_qp]; +} + +template +Real +ADComputePlaneIncrementalStrain::computeOutOfPlaneGradDispOld() +{ + if (_scalar_out_of_plane_strain_coupled) + return (*_scalar_out_of_plane_strain_old[getCurrentSubblockIndex()])[0]; + else + return _out_of_plane_strain_old[_qp]; +} diff --git a/modules/tensor_mechanics/src/materials/ADComputePlaneSmallStrain.C b/modules/tensor_mechanics/src/materials/ADComputePlaneSmallStrain.C new file mode 100644 index 000000000000..9119cc266283 --- /dev/null +++ b/modules/tensor_mechanics/src/materials/ADComputePlaneSmallStrain.C @@ -0,0 +1,64 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADComputePlaneSmallStrain.h" + +registerADMooseObject("TensorMechanicsApp", ADComputePlaneSmallStrain); + +defineADLegacyParams(ADComputePlaneSmallStrain); + +template +InputParameters +ADComputePlaneSmallStrain::validParams() +{ + InputParameters params = ADCompute2DSmallStrain::validParams(); + params.addClassDescription("Compute a small strain under generalized plane strain assumptions " + "where the out of plane strain is generally nonzero."); + params.addParam("subblock_index_provider", + "SubblockIndexProvider user object name"); + params.addCoupledVar("scalar_out_of_plane_strain", + "Scalar variable for generalized plane strain"); + params.addCoupledVar("out_of_plane_strain", "Nonlinear variable for plane stress condition"); + + return params; +} + +template +ADComputePlaneSmallStrain::ADComputePlaneSmallStrain( + const InputParameters & parameters) + : ADCompute2DSmallStrain(parameters), + _subblock_id_provider(isParamValid("subblock_index_provider") + ? &getUserObject("subblock_index_provider") + : nullptr), + _scalar_out_of_plane_strain_coupled(isParamValid("scalar_out_of_plane_strain")), + _out_of_plane_strain_coupled(isCoupled("out_of_plane_strain")), + _out_of_plane_strain(_out_of_plane_strain_coupled ? adCoupledValue("out_of_plane_strain") + : adZeroValue()), + _nscalar_strains(coupledScalarComponents("scalar_out_of_plane_strain")) +{ + if (_out_of_plane_strain_coupled && _scalar_out_of_plane_strain_coupled) + mooseError("Must define only one of out_of_plane_strain or scalar_out_of_plane_strain"); + + if (_scalar_out_of_plane_strain_coupled) + { + _scalar_out_of_plane_strain.resize(_nscalar_strains); + for (unsigned int i = 0; i < _nscalar_strains; ++i) + _scalar_out_of_plane_strain[i] = &adCoupledScalarValue("scalar_out_of_plane_strain", i); + } +} + +template +ADReal +ADComputePlaneSmallStrain::computeOutOfPlaneStrain() +{ + if (_scalar_out_of_plane_strain_coupled) + return (*_scalar_out_of_plane_strain[getCurrentSubblockIndex()])[0]; + else + return _out_of_plane_strain[_qp]; +} diff --git a/modules/tensor_mechanics/src/materials/ADComputeStrainIncrementBasedStress.C b/modules/tensor_mechanics/src/materials/ADComputeStrainIncrementBasedStress.C new file mode 100644 index 000000000000..abe6715c726c --- /dev/null +++ b/modules/tensor_mechanics/src/materials/ADComputeStrainIncrementBasedStress.C @@ -0,0 +1,66 @@ +//* This file is part of the MOOSE framework +//* https://www.mooseframework.org +//* +//* All rights reserved, see COPYRIGHT for full restrictions +//* https://github.com/idaholab/moose/blob/master/COPYRIGHT +//* +//* Licensed under LGPL 2.1, please see LICENSE for details +//* https://www.gnu.org/licenses/lgpl-2.1.html + +#include "ADComputeStrainIncrementBasedStress.h" + +registerADMooseObject("TensorMechanicsApp", ADComputeStrainIncrementBasedStress); + +defineADLegacyParams(ADComputeStrainIncrementBasedStress); + +template +InputParameters +ADComputeStrainIncrementBasedStress::validParams() +{ + InputParameters params = ADComputeStressBase::validParams(); + params.addClassDescription("Compute stress after subtracting inelastic strain increments"); + params.addParam>("inelastic_strain_names", + "Names of inelastic strain properties"); + + return params; +} + +template +ADComputeStrainIncrementBasedStress::ADComputeStrainIncrementBasedStress( + const InputParameters & parameters) + : ADComputeStressBase(parameters), + _elasticity_tensor_name(_base_name + "elasticity_tensor"), + _elasticity_tensor(getMaterialPropertyByName(_elasticity_tensor_name)), + _stress_old(getMaterialPropertyOld(_base_name + "stress")), + _mechanical_strain_old( + getMaterialPropertyOldByName(_base_name + "mechanical_strain")), + _inelastic_strain_names(getParam>("inelastic_strain_names")) +{ + _num_inelastic_strain_models = _inelastic_strain_names.size(); + + if (_num_inelastic_strain_models > 0) + { + _inelastic_strains.resize(_num_inelastic_strain_models); + _inelastic_strains_old.resize(_num_inelastic_strain_models); + + for (unsigned int i = 0; i < _num_inelastic_strain_models; ++i) + { + _inelastic_strains[i] = &getADMaterialProperty(_inelastic_strain_names[i]); + _inelastic_strains_old[i] = + &getMaterialPropertyOld(_inelastic_strain_names[i]); + } + } +} + +template +void +ADComputeStrainIncrementBasedStress::computeQpStress() +{ + ADRankTwoTensor elastic_strain_increment = + (_mechanical_strain[_qp] - _mechanical_strain_old[_qp]); + + for (unsigned int i = 0; i < _num_inelastic_strain_models; ++i) + elastic_strain_increment -= (*_inelastic_strains[i])[_qp] - (*_inelastic_strains_old[i])[_qp]; + + _stress[_qp] = _stress_old[_qp] + _elasticity_tensor[_qp] * elastic_strain_increment; +} diff --git a/modules/tensor_mechanics/src/materials/ComputeStrainIncrementBasedStress.C b/modules/tensor_mechanics/src/materials/ComputeStrainIncrementBasedStress.C index 754c9eb9535e..71f957809bef 100644 --- a/modules/tensor_mechanics/src/materials/ComputeStrainIncrementBasedStress.C +++ b/modules/tensor_mechanics/src/materials/ComputeStrainIncrementBasedStress.C @@ -30,7 +30,6 @@ ComputeStrainIncrementBasedStress::ComputeStrainIncrementBasedStress( _elasticity_tensor_name(_base_name + "elasticity_tensor"), _elasticity_tensor(getMaterialPropertyByName(_elasticity_tensor_name)), _stress_old(getMaterialPropertyOld(_base_name + "stress")), - _mechanical_strain(getMaterialPropertyByName(_base_name + "mechanical_strain")), _mechanical_strain_old( getMaterialPropertyOldByName(_base_name + "mechanical_strain")), _inelastic_strain_names(getParam>("inelastic_strain_names")) diff --git a/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_elastic_jacobian.i b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_elastic_jacobian.i new file mode 100644 index 000000000000..2d49e75191a1 --- /dev/null +++ b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_elastic_jacobian.i @@ -0,0 +1,46 @@ +[GlobalParams] + displacements = 'disp_x disp_y' + out_of_plane_strain = strain_zz +[] + +[Mesh] + file = 'square.e' +[] + +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] + [./strain_zz] + [../] +[] + +[Modules/TensorMechanics/Master] + [./plane_stress] + planar_formulation = WEAK_PLANE_STRESS + strain = SMALL + use_automatic_differentiation = true + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeIsotropicElasticityTensor + poissons_ratio = 0.0 + youngs_modulus = 1 + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] +[] + +[Executioner] + type = Transient + solve_type = NEWTON + + petsc_options_iname = '-ksp_type -pc_type -snes_type' + petsc_options_value = 'bcgs bjacobi test' + + end_time = 1.0 +[] diff --git a/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_finite.i b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_finite.i new file mode 100644 index 000000000000..7082bee13cc0 --- /dev/null +++ b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_finite.i @@ -0,0 +1,138 @@ +[GlobalParams] + displacements = 'disp_x disp_y' + temperature = temp + out_of_plane_strain = strain_zz +[] + +[Mesh] + file = 'square.e' +[] + +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] + [./strain_zz] + [../] +[] + +[AuxVariables] + [./temp] + [../] + [./nl_strain_zz] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[Postprocessors] + [./react_z] + type = MaterialTensorIntegral + rank_two_tensor = stress + index_i = 2 + index_j = 2 + [../] + [./min_strain_zz] + type = NodalExtremeValue + variable = strain_zz + value_type = min + [../] + [./max_strain_zz] + type = NodalExtremeValue + variable = strain_zz + value_type = max + [../] +[] + +[Modules/TensorMechanics/Master] + [./plane_stress] + planar_formulation = WEAK_PLANE_STRESS + strain = FINITE + generate_output = 'stress_xx stress_xy stress_yy stress_zz strain_xx strain_xy strain_yy' + eigenstrain_names = eigenstrain + use_automatic_differentiation = true + [../] +[] + +[AuxKernels] + [./tempfuncaux] + type = FunctionAux + variable = temp + function = tempfunc + use_displaced_mesh = false + [../] + [./strain_zz] + type = RankTwoAux + rank_two_tensor = total_strain + variable = nl_strain_zz + index_i = 2 + index_j = 2 + [../] +[] + +[Functions] + [./pull] + type = PiecewiseLinear + x='0 1 100' + y='0 0.00 0.00' + [../] + [./tempfunc] + type = ParsedFunction + value = '(1 - x) * t' + [../] +[] + +[BCs] + [./bottomx] + type = PresetBC + boundary = 1 + variable = disp_x + value = 0.0 + [../] + [./bottomy] + type = PresetBC + boundary = 1 + variable = disp_y + value = 0.0 + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeIsotropicElasticityTensor + poissons_ratio = 0.3 + youngs_modulus = 1e6 + [../] + [./thermal_strain] + type = ADComputeThermalExpansionEigenstrain + thermal_expansion_coeff = 0.02 + stress_free_temperature = 0.5 + eigenstrain_name = eigenstrain + [../] + [./stress] + type = ADComputeFiniteStrainElasticStress + [../] +[] + +[Executioner] + type = Transient + + solve_type = 'NEWTON' + + # controls for nonlinear iterations + nl_max_its = 15 + nl_rel_tol = 1e-14 + nl_abs_tol = 1e-12 + + # time control + start_time = 0.0 + dt = 1.0 + dtmin = 1.0 + end_time = 2.0 +[] + +[Outputs] + file_base = 'weak_plane_stress_finite_out' + exodus = true +[] diff --git a/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_incremental.i b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_incremental.i new file mode 100644 index 000000000000..0a7e52fc3fe5 --- /dev/null +++ b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_incremental.i @@ -0,0 +1,139 @@ +[GlobalParams] + displacements = 'disp_x disp_y' + temperature = temp + out_of_plane_strain = strain_zz +[] + +[Mesh] + file = 'square.e' +[] + +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] + [./strain_zz] + [../] +[] + +[AuxVariables] + [./temp] + [../] + [./nl_strain_zz] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[Postprocessors] + [./react_z] + type = MaterialTensorIntegral + rank_two_tensor = stress + index_i = 2 + index_j = 2 + [../] + [./min_strain_zz] + type = NodalExtremeValue + variable = strain_zz + value_type = min + [../] + [./max_strain_zz] + type = NodalExtremeValue + variable = strain_zz + value_type = max + [../] +[] + +[Modules/TensorMechanics/Master] + [./plane_stress] + planar_formulation = WEAK_PLANE_STRESS + strain = SMALL + incremental = true + generate_output = 'stress_xx stress_xy stress_yy stress_zz strain_xx strain_xy strain_yy' + eigenstrain_names = eigenstrain + use_automatic_differentiation = true + [../] +[] + +[AuxKernels] + [./tempfuncaux] + type = FunctionAux + variable = temp + function = tempfunc + use_displaced_mesh = false + [../] + [./strain_zz] + type = RankTwoAux + rank_two_tensor = total_strain + variable = nl_strain_zz + index_i = 2 + index_j = 2 + [../] +[] + +[Functions] + [./pull] + type = PiecewiseLinear + x='0 1 100' + y='0 0.00 0.00' + [../] + [./tempfunc] + type = ParsedFunction + value = '(1 - x) * t' + [../] +[] + +[BCs] + [./bottomx] + type = PresetBC + boundary = 1 + variable = disp_x + value = 0.0 + [../] + [./bottomy] + type = PresetBC + boundary = 1 + variable = disp_y + value = 0.0 + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeIsotropicElasticityTensor + poissons_ratio = 0.3 + youngs_modulus = 1e6 + [../] + [./thermal_strain] + type = ADComputeThermalExpansionEigenstrain + thermal_expansion_coeff = 0.02 + stress_free_temperature = 0.5 + eigenstrain_name = eigenstrain + [../] + [./stress] + type = ADComputeStrainIncrementBasedStress + [../] +[] + +[Executioner] + type = Transient + + solve_type = 'NEWTON' + +# controls for nonlinear iterations + nl_max_its = 15 + nl_rel_tol = 1e-14 + nl_abs_tol = 1e-12 + +# time control + start_time = 0.0 + dt = 1.0 + dtmin = 1.0 + end_time = 2.0 +[] + +[Outputs] + file_base = 'weak_plane_stress_incremental_out' + exodus = true +[] diff --git a/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_small.i b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_small.i new file mode 100644 index 000000000000..8ef0e54c6653 --- /dev/null +++ b/modules/tensor_mechanics/test/tests/plane_stress/ad_weak_plane_stress_small.i @@ -0,0 +1,140 @@ +[GlobalParams] + order = FIRST + family = LAGRANGE + displacements = 'disp_x disp_y' + temperature = temp + out_of_plane_strain = strain_zz +[] + +[Mesh] + file = 'square.e' +[] + +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] + [./strain_zz] + [../] +[] + +[AuxVariables] + [./temp] + [../] + [./nl_strain_zz] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[Postprocessors] + [./react_z] + type = MaterialTensorIntegral + rank_two_tensor = stress + index_i = 2 + index_j = 2 + [../] + [./min_strain_zz] + type = NodalExtremeValue + variable = strain_zz + value_type = min + [../] + [./max_strain_zz] + type = NodalExtremeValue + variable = strain_zz + value_type = max + [../] +[] + +[Modules/TensorMechanics/Master] + [./plane_stress] + planar_formulation = WEAK_PLANE_STRESS + strain = SMALL + generate_output = 'stress_xx stress_xy stress_yy stress_zz strain_xx strain_xy strain_yy' + eigenstrain_names = eigenstrain + use_automatic_differentiation = true + [../] +[] + +[AuxKernels] + [./tempfuncaux] + type = FunctionAux + variable = temp + function = tempfunc + use_displaced_mesh = false + [../] + [./strain_zz] + type = RankTwoAux + rank_two_tensor = total_strain + variable = nl_strain_zz + index_i = 2 + index_j = 2 + [../] +[] + +[Functions] + [./pull] + type = PiecewiseLinear + x='0 1 100' + y='0 0.00 0.00' + [../] + [./tempfunc] + type = ParsedFunction + value = '(1 - x) * t' + [../] +[] + +[BCs] + [./bottomx] + type = PresetBC + boundary = 1 + variable = disp_x + value = 0.0 + [../] + [./bottomy] + type = PresetBC + boundary = 1 + variable = disp_y + value = 0.0 + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeIsotropicElasticityTensor + poissons_ratio = 0.3 + youngs_modulus = 1e6 + [../] + [./thermal_strain] + type = ADComputeThermalExpansionEigenstrain + thermal_expansion_coeff = 0.02 + stress_free_temperature = 0.5 + eigenstrain_name = eigenstrain + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] +[] + +[Executioner] + type = Transient + + solve_type = 'NEWTON' + + # controls for nonlinear iterations + nl_max_its = 15 + nl_rel_tol = 1e-14 + nl_abs_tol = 1e-12 + + # time control + start_time = 0.0 + dt = 1.0 + dtmin = 1.0 + end_time = 2.0 +[] + +[Outputs] + file_base = 'weak_plane_stress_small_out' + exodus = true +[] diff --git a/modules/tensor_mechanics/test/tests/plane_stress/tests b/modules/tensor_mechanics/test/tests/plane_stress/tests index c00646b2ba15..fb39e7587edb 100644 --- a/modules/tensor_mechanics/test/tests/plane_stress/tests +++ b/modules/tensor_mechanics/test/tests/plane_stress/tests @@ -9,6 +9,14 @@ requirement = 'The system shall compute the correct Jacobian for plane stress conditions' [../] + [./ad_weak_plane_stress_elastic_jacobian] + type = 'PetscJacobianTester' + input = 'ad_weak_plane_stress_elastic_jacobian.i' + ratio_tol = 1E-12 + difference_tol = 1E10 + requirement = 'The system shall compute the correct Jacobian for plane stress conditions' + [../] + [./weak_plane_stress_small] type = 'Exodiff' input = 'weak_plane_stress_small.i' @@ -16,6 +24,14 @@ requirement = 'The system shall compute plane stress conditions with small strains with input provided using the Master action' [../] + [./ad_weak_plane_stress_small] + prereq = 'weak_plane_stress_small' + type = 'Exodiff' + input = 'ad_weak_plane_stress_small.i' + exodiff = 'weak_plane_stress_small_out.e' + requirement = 'The system shall compute plane stress conditions with small strains' + [../] + [./weak_plane_stress_incremental] type = 'Exodiff' input = 'weak_plane_stress_incremental.i' @@ -23,6 +39,14 @@ requirement = 'The system shall compute plane stress conditions with incremental strains with input provided using the Master action' [../] + [./ad_weak_plane_stress_incremental] + prereq = 'weak_plane_stress_incremental' + type = 'Exodiff' + input = 'ad_weak_plane_stress_incremental.i' + exodiff = 'weak_plane_stress_incremental_out.e' + requirement = 'The system shall compute plane stress conditions with incremental strains with input provided using the Master action' + [../] + [./weak_plane_stress_finite] type = 'Exodiff' input = 'weak_plane_stress_finite.i' @@ -31,6 +55,15 @@ requirement = 'The system shall compute plane stress conditions with finite strains with input provided using the Master action' [../] + [./ad_weak_plane_stress_finite] + prereq = 'weak_plane_stress_finite' + type = 'Exodiff' + input = 'ad_weak_plane_stress_finite.i' + exodiff = 'weak_plane_stress_finite_out.e' + abs_zero = 1e-9 + requirement = 'The system shall compute plane stress conditions with finite strains with input provided using the Master action' + [../] + [./3D_finite_tension_pull] type = 'CSVDiff' input = '3D_finite_tension_pull.i'