From 7f95c996e2306329c83f90ed91db354cbb46ae58 Mon Sep 17 00:00:00 2001 From: tophmatthews Date: Fri, 22 Mar 2019 08:54:29 -0600 Subject: [PATCH 1/3] ADEigenstrain implementation (#13091) --- .../ad_linear_elasticity/applied_strain.i | 141 +++++ .../gold/applied_strain_out.e | 1 + .../gold/linear_elastic_material_out.e | 1 + .../ad_linear_elasticity/gold/tensor_out.e | 1 + .../gold/thermal_expansion_out.e | 1 + .../linear_elastic_material.i | 201 ++++++++ .../test/tests/ad_linear_elasticity/tensor.i | 481 ++++++++++++++++++ .../test/tests/ad_linear_elasticity/tests | 27 + .../ad_linear_elasticity/thermal_expansion.i | 149 ++++++ .../tests/linear_elasticity/applied_strain.i | 7 - .../linear_anisotropic_material.i | 6 +- .../linear_elastic_material.i | 5 - .../test/tests/linear_elasticity/tensor.i | 5 - .../linear_elasticity/thermal_expansion.i | 7 - .../include/materials/ADComputeEigenstrain.h | 42 ++ .../materials/ADComputeEigenstrainBase.h | 74 +++ .../src/materials/ADComputeEigenstrain.C | 39 ++ .../src/materials/ADComputeEigenstrainBase.C | 86 ++++ 18 files changed, 1245 insertions(+), 29 deletions(-) create mode 100644 modules/combined/test/tests/ad_linear_elasticity/applied_strain.i create mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e create mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e create mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e create mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e create mode 100644 modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i create mode 100644 modules/combined/test/tests/ad_linear_elasticity/tensor.i create mode 100644 modules/combined/test/tests/ad_linear_elasticity/tests create mode 100644 modules/combined/test/tests/ad_linear_elasticity/thermal_expansion.i create mode 100644 modules/tensor_mechanics/include/materials/ADComputeEigenstrain.h create mode 100644 modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h create mode 100644 modules/tensor_mechanics/src/materials/ADComputeEigenstrain.C create mode 100644 modules/tensor_mechanics/src/materials/ADComputeEigenstrainBase.C diff --git a/modules/combined/test/tests/ad_linear_elasticity/applied_strain.i b/modules/combined/test/tests/ad_linear_elasticity/applied_strain.i new file mode 100644 index 000000000000..7faf790bf39a --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/applied_strain.i @@ -0,0 +1,141 @@ +[GlobalParams] + displacements = 'disp_x disp_y' +[] + +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 2 + ny = 2 + nz = 0 + xmin = 0 + xmax = 2 + ymin = 0 + ymax = 2 + zmin = 0 + zmax = 0 + elem_type = QUAD4 +[] + +# [Modules/TensorMechanics/Master/All] +# strain = SMALL +# eigenstrain_names = eigenstrain +# add_variables = true +# generate_output = 'strain_xx strain_yy strain_xy' +# [] + +### Replaceable by action +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] +[] + +[Kernels] + [./x] + type = ADStressDivergenceTensors + variable = disp_x + component = 0 + [../] + [./y] + type = ADStressDivergenceTensors + variable = disp_y + component = 1 + [../] +[] + +[AuxVariables] + [./strain_xx] + order = CONSTANT + family = MONOMIAL + [../] + [./strain_yy] + order = CONSTANT + family = MONOMIAL + [../] + [./strain_xy] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[AuxKernels] + [./strain_xx_aux] + type = MaterialRankTwoTensorAux + variable = strain_xx + i = 0 + j = 0 + property = total_strain + [../] + [./strain_yy_aux] + type = MaterialRankTwoTensorAux + variable = strain_yy + i = 1 + j = 1 + property = total_strain + [../] + [./strain_xy_aux] + type = MaterialRankTwoTensorAux + variable = strain_xy + i = 0 + j = 1 + property = total_strain + [../] +[] + +[Materials] + [./strain] + type = ADComputeSmallStrain + eigenstrain_names = eigenstrain + [../] +[] +### Replaceable by action + +[Materials] + [./elasticity_tensor] + type = ComputeElasticityTensor + fill_method = symmetric9 + C_ijkl = '1e6 0 0 1e6 0 1e6 .5e6 .5e6 .5e6' + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] + [./eigenstrain] + type = ADComputeEigenstrain + eigen_base = '0.1 0.05 0 0 0 0.01' + prefactor = -1 + eigenstrain_name = eigenstrain + [../] +[] + +[BCs] + [./bottom_y] + type = PresetBC + variable = disp_y + boundary = 'bottom' + value = 0 + [../] + [./left_x] + type = PresetBC + variable = disp_x + boundary = 'left' + value = 0 + [../] +[] + +[Preconditioning] + [./SMP] + type = SMP + full = true + [../] +[] + +[Executioner] + type = Steady + solve_type = 'NEWTON' +[] + +[Outputs] + exodus = true +[] diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e new file mode 120000 index 000000000000..a2bf365f2a6a --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e @@ -0,0 +1 @@ +../../linear_elasticity/gold/applied_strain_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e new file mode 120000 index 000000000000..2b54ddf9e546 --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e @@ -0,0 +1 @@ +../../linear_elasticity/gold/linear_elastic_material_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e new file mode 120000 index 000000000000..69d44d75bb20 --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e @@ -0,0 +1 @@ +../../linear_elasticity/gold/tensor_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e new file mode 120000 index 000000000000..b9ea11f869ac --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e @@ -0,0 +1 @@ +../../linear_elasticity/gold/thermal_expansion_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i b/modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i new file mode 100644 index 000000000000..5c78cd61e03a --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i @@ -0,0 +1,201 @@ +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 10 + ny = 10 + nz = 0 + xmin = 0 + xmax = 50 + ymin = 0 + ymax = 50 + zmin = 0 + zmax = 0 + elem_type = QUAD4 +[] + +[GlobalParams] + displacements = 'disp_x disp_y' +[] + +[Variables] + [./diffused] + [./InitialCondition] + type = RandomIC + [../] + [../] +[] + +# [Modules/TensorMechanics/Master/All] +# strain = SMALL +# add_variables = true +# generate_output = 'stress_xx stress_yy stress_zz stress_xy stress_yz stress_zx' +# [] + +### Replaceable by action +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] +[] + +[Kernels] + [./x] + type = ADStressDivergenceTensors + variable = disp_x + component = 0 + [../] + [./y] + type = ADStressDivergenceTensors + variable = disp_y + component = 1 + [../] +[] + +[AuxVariables] + [./stress_xx] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_yy] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_zz] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_xy] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_yz] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_zx] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[AuxKernels] + [./stress_xx_aux] + type = MaterialRankTwoTensorAux + variable = stress_xx + i = 0 + j = 0 + property = stress + [../] + [./stress_yy_aux] + type = MaterialRankTwoTensorAux + variable = stress_yy + i = 1 + j = 1 + property = stress + [../] + [./stress_zz_aux] + type = MaterialRankTwoTensorAux + variable = stress_zz + i = 2 + j = 2 + property = stress + [../] + [./stress_xy_aux] + type = MaterialRankTwoTensorAux + variable = stress_xy + i = 0 + j = 1 + property = stress + [../] + [./stress_yz_aux] + type = MaterialRankTwoTensorAux + variable = stress_yz + i = 1 + j = 2 + property = stress + [../] + [./stress_zx_aux] + type = MaterialRankTwoTensorAux + variable = stress_zx + i = 2 + j = 0 + property = stress + [../] +[] + +[Materials] + [./strain] + type = ADComputeSmallStrain + [../] +[] +### Replaceable by action + +[Kernels] + [./diff] + type = ADDiffusion + variable = diffused + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeElasticityTensor + fill_method = symmetric9 + #reading C_11 C_12 C_13 C_22 C_23 C_33 C_44 C_55 C_66 + C_ijkl ='1.0e6 0.0 0.0 1.0e6 0.0 1.0e6 0.5e6 0.5e6 0.5e6' + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] +[] + +[BCs] + [./bottom] + type = PresetBC + variable = diffused + boundary = '1' + value = 1 + [../] + [./top] + type = PresetBC + variable = diffused + boundary = '2' + value = 0 + [../] + [./disp_x_BC] + type = PresetBC + variable = disp_x + boundary = '0 2' + value = 0.5 + [../] + [./disp_x_BC2] + type = PresetBC + variable = disp_x + boundary = '1 3' + value = 0.01 + [../] + [./disp_y_BC] + type = PresetBC + variable = disp_y + boundary = '0 2' + value = 0.8 + [../] + [./disp_y_BC2] + type = PresetBC + variable = disp_y + boundary = '1 3' + value = 0.02 + [../] +[] + +[Executioner] + type = Steady + solve_type = 'PJFNK' + + nl_rel_tol = 1e-12 +[] + +[Outputs] + exodus = true +[] diff --git a/modules/combined/test/tests/ad_linear_elasticity/tensor.i b/modules/combined/test/tests/ad_linear_elasticity/tensor.i new file mode 100644 index 000000000000..a6e74c107515 --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/tensor.i @@ -0,0 +1,481 @@ +# This input file is designed to test the RankTwoAux and RankFourAux +# auxkernels, which report values out of the Tensors used in materials +# properties. + +[GlobalParams] + displacements = 'disp_x disp_y' +[] + +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 2 + ny = 2 + nz = 0 + xmin = 0 + xmax = 2 + ymin = 0 + ymax = 2 + zmin = 0 + zmax = 0 + elem_type = QUAD4 +[] + +[Variables] + [./diffused] + [./InitialCondition] + type = RandomIC + [../] + [../] +[] + +[AuxVariables] + [./C11] + order = CONSTANT + family = MONOMIAL + [../] + [./C12] + order = CONSTANT + family = MONOMIAL + [../] + [./C13] + order = CONSTANT + family = MONOMIAL + [../] + [./C14] + order = CONSTANT + family = MONOMIAL + [../] + [./C15] + order = CONSTANT + family = MONOMIAL + [../] + [./C16] + order = CONSTANT + family = MONOMIAL + [../] + [./C22] + order = CONSTANT + family = MONOMIAL + [../] + [./C23] + order = CONSTANT + family = MONOMIAL + [../] + [./C24] + order = CONSTANT + family = MONOMIAL + [../] + [./C25] + order = CONSTANT + family = MONOMIAL + [../] + [./C26] + order = CONSTANT + family = MONOMIAL + [../] + [./C33] + order = CONSTANT + family = MONOMIAL + [../] + [./C34] + order = CONSTANT + family = MONOMIAL + [../] + [./C35] + order = CONSTANT + family = MONOMIAL + [../] + [./C36] + order = CONSTANT + family = MONOMIAL + [../] + [./C44] + order = CONSTANT + family = MONOMIAL + [../] + [./C45] + order = CONSTANT + family = MONOMIAL + [../] + [./C46] + order = CONSTANT + family = MONOMIAL + [../] + [./C55] + order = CONSTANT + family = MONOMIAL + [../] + [./C56] + order = CONSTANT + family = MONOMIAL + [../] + [./C66] + order = CONSTANT + family = MONOMIAL + [../] +[] + +# [Modules/TensorMechanics/Master/All] +# strain = SMALL +# add_variables = true +# generate_output = 'stress_xx stress_yy stress_zz stress_xy stress_yz stress_zx' +# [] + +### Replaceable by action +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] +[] + +[Kernels] + [./x] + type = ADStressDivergenceTensors + variable = disp_x + component = 0 + [../] + [./y] + type = ADStressDivergenceTensors + variable = disp_y + component = 1 + [../] +[] + +[AuxVariables] + [./stress_xx] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_yy] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_zz] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_xy] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_yz] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_zx] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[AuxKernels] + [./stress_xx_aux] + type = MaterialRankTwoTensorAux + variable = stress_xx + i = 0 + j = 0 + property = stress + [../] + [./stress_yy_aux] + type = MaterialRankTwoTensorAux + variable = stress_yy + i = 1 + j = 1 + property = stress + [../] + [./stress_zz_aux] + type = MaterialRankTwoTensorAux + variable = stress_zz + i = 2 + j = 2 + property = stress + [../] + [./stress_xy_aux] + type = MaterialRankTwoTensorAux + variable = stress_xy + i = 0 + j = 1 + property = stress + [../] + [./stress_yz_aux] + type = MaterialRankTwoTensorAux + variable = stress_yz + i = 1 + j = 2 + property = stress + [../] + [./stress_zx_aux] + type = MaterialRankTwoTensorAux + variable = stress_zx + i = 2 + j = 0 + property = stress + [../] +[] + +[Materials] + [./strain] + type = ADComputeSmallStrain + [../] +[] +### Replaceable by action + +[Kernels] + [./diff] + type = ADDiffusion + variable = diffused + [../] +[] + +[AuxKernels] + [./matl_C11] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 0 + index_k = 0 + index_l = 0 + variable = C11 + [../] + [./matl_C12] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 0 + index_k = 1 + index_l = 1 + variable = C12 + [../] + [./matl_C13] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 0 + index_k = 2 + index_l = 2 + variable = C13 + [../] + [./matl_C14] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 0 + index_k = 1 + index_l = 2 + variable = C14 + [../] + [./matl_C15] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 0 + index_k = 0 + index_l = 2 + variable = C15 + [../] + [./matl_C16] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 0 + index_k = 0 + index_l = 1 + variable = C16 + [../] + [./matl_C22] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 1 + index_k = 1 + index_l = 1 + variable = C22 + [../] + [./matl_C23] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 1 + index_k = 2 + index_l = 2 + variable = C23 + [../] + [./matl_C24] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 1 + index_k = 1 + index_l = 2 + variable = C24 + [../] + [./matl_C25] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 1 + index_k = 0 + index_l = 2 + variable = C25 + [../] + [./matl_C26] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 1 + index_k = 0 + index_l = 1 + variable = C26 + [../] + [./matl_C33] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 2 + index_j = 2 + index_k = 2 + index_l = 2 + variable = C33 + [../] + [./matl_C34] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 2 + index_j = 2 + index_k = 1 + index_l = 2 + variable = C34 + [../] + [./matl_C35] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 2 + index_j = 2 + index_k = 0 + index_l = 2 + variable = C35 + [../] + [./matl_C36] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 2 + index_j = 2 + index_k = 0 + index_l = 1 + variable = C36 + [../] + [./matl_C44] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 2 + index_k = 1 + index_l = 2 + variable = C44 + [../] + [./matl_C45] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 2 + index_k = 0 + index_l = 2 + variable = C45 + [../] + [./matl_C46] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 1 + index_j = 2 + index_k = 0 + index_l = 1 + variable = C46 + [../] + [./matl_C55] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 2 + index_k = 0 + index_l = 2 + variable = C55 + [../] + [./matl_C56] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 2 + index_k = 0 + index_l = 1 + variable = C56 + [../] + [./matl_C66] + type = RankFourAux + rank_four_tensor = elasticity_tensor + index_i = 0 + index_j = 1 + index_k = 0 + index_l = 1 + variable = C66 + [../] +[] + +[Materials] + [./elasticity_tensor] + type = ComputeElasticityTensor + fill_method = symmetric21 + C_ijkl ='1111 1122 1133 1123 1113 1112 2222 2233 2223 2213 2212 3333 3323 3313 3312 2323 2313 2312 1313 1312 1212' + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] +[] + +[BCs] + [./bottom] + type = PresetBC + variable = diffused + boundary = '1' + value = 1 + [../] + [./top] + type = PresetBC + variable = diffused + boundary = '2' + value = 0 + [../] + [./disp_x_BC] + type = PresetBC + variable = disp_x + boundary = '0 2' + value = 0.5 + [../] + [./disp_x_BC2] + type = PresetBC + variable = disp_x + boundary = '1 3' + value = 0.01 + [../] + [./disp_y_BC] + type = PresetBC + variable = disp_y + boundary = '0 2' + value = 0.8 + [../] + [./disp_y_BC2] + type = PresetBC + variable = disp_y + boundary = '1 3' + value = 0.02 + [../] +[] + +[Executioner] + type = Steady + solve_type = 'PJFNK' +[] + +[Outputs] + exodus = true +[] diff --git a/modules/combined/test/tests/ad_linear_elasticity/tests b/modules/combined/test/tests/ad_linear_elasticity/tests new file mode 100644 index 000000000000..ec3225505f39 --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/tests @@ -0,0 +1,27 @@ +[Tests] + [./linear_elastic_material] + type = 'Exodiff' + input = 'linear_elastic_material.i' + exodiff = 'linear_elastic_material_out.e' + max_parallel = 1 + [../] + + [./applied_strain] + type = 'Exodiff' + input = 'applied_strain.i' + exodiff = 'applied_strain_out.e' + [../] + + [./tensor] + type = 'Exodiff' + input = 'tensor.i' + exodiff = 'tensor_out.e' + max_parallel = 1 + [../] + + [./thermal_expansion] + type = 'Exodiff' + input = 'thermal_expansion.i' + exodiff = 'thermal_expansion_out.e' + [../] +[] diff --git a/modules/combined/test/tests/ad_linear_elasticity/thermal_expansion.i b/modules/combined/test/tests/ad_linear_elasticity/thermal_expansion.i new file mode 100644 index 000000000000..d12d87ef332d --- /dev/null +++ b/modules/combined/test/tests/ad_linear_elasticity/thermal_expansion.i @@ -0,0 +1,149 @@ +# This input file is designed to test the RankTwoAux and RankFourAux +# auxkernels, which report values out of the Tensors used in materials +# properties. +# Materials properties into AuxVariables - these are elemental variables, not nodal variables. + +[GlobalParams] + displacements = 'disp_x disp_y' +[] + +[Mesh] + type = GeneratedMesh + dim = 2 + nx = 2 + ny = 2 + nz = 0 + xmin = 0 + xmax = 2 + ymin = 0 + ymax = 2 + zmin = 0 + zmax = 0 + elem_type = QUAD4 +[] + +### Can be used when AD is added to tensor mechanics action +# [Modules/TensorMechanics/Master/All] +# strain = SMALL +# eigenstrain_names = eigenstrain +# add_variables = true +# generate_output = 'stress_xx stress_yy stress_xy' +# [] + + +### Replaceable by action +[Variables] + [./disp_x] + [../] + [./disp_y] + [../] +[] + +[Kernels] + [./x] + type = ADStressDivergenceTensors + variable = disp_x + component = 0 + [../] + [./y] + type = ADStressDivergenceTensors + variable = disp_y + component = 1 + [../] +[] + +[AuxVariables] + [./stress_xx] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_xy] + order = CONSTANT + family = MONOMIAL + [../] + [./stress_yy] + order = CONSTANT + family = MONOMIAL + [../] +[] + +[AuxKernels] + [./stress_xx_aux] + type = MaterialRankTwoTensorAux + variable = stress_xx + i = 0 + j = 0 + property = stress + [../] + [./stress_xy_aux] + type = MaterialRankTwoTensorAux + variable = stress_xy + i = 0 + j = 1 + property = stress + [../] + [./stress_yy_aux] + type = MaterialRankTwoTensorAux + variable = stress_yy + i = 1 + j = 1 + property = stress + [../] +[] + +[Materials] + [./strain] + type = ADComputeSmallStrain + eigenstrain_names = eigenstrain + [../] +[] +### Replaceable by action + +[Materials] + [./elasticity_tensor] + type = ComputeElasticityTensor + fill_method = symmetric9 + C_ijkl = '1e6 0 0 1e6 0 1e6 .5e6 .5e6 .5e6' + [../] + [./stress] + type = ADComputeLinearElasticStress + [../] + [./eigenstrain] + type = ADComputeEigenstrain + eigen_base = '1e-4' + eigenstrain_name = eigenstrain + [../] +[] + +[BCs] + [./bottom_y] + type = PresetBC + variable = disp_y + boundary = 'bottom' + value = 0 + [../] + [./left_x] + type = PresetBC + variable = disp_x + boundary = 'left' + value = 0 + [../] +[] + +[Preconditioning] + [./SMP] + type = SMP + full = true + [../] +[] + +[Executioner] + type = Steady + solve_type = 'NEWTON' + + nl_rel_tol = 1e-14 +[] + +[Outputs] + exodus = true +[] diff --git a/modules/combined/test/tests/linear_elasticity/applied_strain.i b/modules/combined/test/tests/linear_elasticity/applied_strain.i index 5a149e2f3de5..d6349bd7e081 100644 --- a/modules/combined/test/tests/linear_elasticity/applied_strain.i +++ b/modules/combined/test/tests/linear_elasticity/applied_strain.i @@ -17,13 +17,6 @@ elem_type = QUAD4 [] -[Variables] - [./disp_x] - [../] - [./disp_y] - [../] -[] - [Modules/TensorMechanics/Master/All] strain = SMALL eigenstrain_names = eigenstrain diff --git a/modules/combined/test/tests/linear_elasticity/linear_anisotropic_material.i b/modules/combined/test/tests/linear_elasticity/linear_anisotropic_material.i index 636e603a6c93..5c4df9d30b9a 100644 --- a/modules/combined/test/tests/linear_elasticity/linear_anisotropic_material.i +++ b/modules/combined/test/tests/linear_elasticity/linear_anisotropic_material.i @@ -23,16 +23,12 @@ [Variables] [./diffused] [../] - - [./disp_x] - [../] - [./disp_y] - [../] [] [Modules/TensorMechanics/Master/All] strain = SMALL incremental = true + add_variables = true [] [AuxVariables] diff --git a/modules/combined/test/tests/linear_elasticity/linear_elastic_material.i b/modules/combined/test/tests/linear_elasticity/linear_elastic_material.i index e2f812b90e68..686121c7b2be 100644 --- a/modules/combined/test/tests/linear_elasticity/linear_elastic_material.i +++ b/modules/combined/test/tests/linear_elasticity/linear_elastic_material.i @@ -23,11 +23,6 @@ type = RandomIC [../] [../] - - [./disp_x] - [../] - [./disp_y] - [../] [] [Modules/TensorMechanics/Master/All] diff --git a/modules/combined/test/tests/linear_elasticity/tensor.i b/modules/combined/test/tests/linear_elasticity/tensor.i index ce68b6378187..3049b56eabfc 100644 --- a/modules/combined/test/tests/linear_elasticity/tensor.i +++ b/modules/combined/test/tests/linear_elasticity/tensor.i @@ -27,11 +27,6 @@ type = RandomIC [../] [../] - - [./disp_x] - [../] - [./disp_y] - [../] [] [AuxVariables] diff --git a/modules/combined/test/tests/linear_elasticity/thermal_expansion.i b/modules/combined/test/tests/linear_elasticity/thermal_expansion.i index 2ac1ba6d23fe..e59058c8268a 100644 --- a/modules/combined/test/tests/linear_elasticity/thermal_expansion.i +++ b/modules/combined/test/tests/linear_elasticity/thermal_expansion.i @@ -22,13 +22,6 @@ elem_type = QUAD4 [] -[Variables] - [./disp_x] - [../] - [./disp_y] - [../] -[] - [Modules/TensorMechanics/Master/All] strain = SMALL eigenstrain_names = eigenstrain diff --git a/modules/tensor_mechanics/include/materials/ADComputeEigenstrain.h b/modules/tensor_mechanics/include/materials/ADComputeEigenstrain.h new file mode 100644 index 000000000000..d0de253a892c --- /dev/null +++ b/modules/tensor_mechanics/include/materials/ADComputeEigenstrain.h @@ -0,0 +1,42 @@ +//* 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 + +#ifndef ADADCOMPUTEEIGENSTRAIN_H +#define ADADCOMPUTEEIGENSTRAIN_H + +#include "ADComputeEigenstrainBase.h" + +#define usingADComputeEigenstrainMembers usingADComputeEigenstrainBaseMembers + +template +class ADComputeEigenstrain; + +declareADValidParams(ADComputeEigenstrain); + +/** + * ComputeEigenstrain computes an Eigenstrain that is a function of a single variable defined by a + * base tensor and a scalar function defined in a Derivative Material. + */ +template +class ADComputeEigenstrain : public ADComputeEigenstrainBase +{ +public: + ADComputeEigenstrain(const InputParameters & parameters); + +protected: + virtual void computeQpEigenstrain() override; + + const ADMaterialProperty(Real) & _prefactor; + + RankTwoTensor _eigen_base_tensor; + + usingADComputeEigenstrainBaseMembers; +}; + +#endif // ADADCOMPUTEEIGENSTRAIN_H diff --git a/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h b/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h new file mode 100644 index 000000000000..92d2bbf9553d --- /dev/null +++ b/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h @@ -0,0 +1,74 @@ +//* 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 + +#ifndef ADADCOMPUTEEIGENSTRAINBASE_H +#define ADADCOMPUTEEIGENSTRAINBASE_H + +#include "ADMaterial.h" + +#define adDeclareRestartableData this->template declareRestartableData + +#define usingADComputeEigenstrainBaseMembers \ + usingMaterialMembers; \ + using ADComputeEigenstrainBase::_eigenstrain + +// Forward Declarations +template +class ADComputeEigenstrainBase; + +template +class RankTwoTensorTempl; + +typedef RankTwoTensorTempl RankTwoTensor; +typedef RankTwoTensorTempl DualRankTwoTensor; + +declareADValidParams(ADComputeEigenstrainBase); + +/** + * ADComputeEigenstrainBase is the base class for eigenstrain tensors + */ +template +class ADComputeEigenstrainBase : public ADMaterial +{ +public: + ADComputeEigenstrainBase(const InputParameters & parameters); + +protected: + virtual void initQpStatefulProperties() override; + virtual void computeQpProperties() override; + + ///Compute the eigenstrain and store in _eigenstrain + virtual void computeQpEigenstrain() = 0; + + ///Base name prepended to material property name + std::string _base_name; + + ///Material property name for the eigenstrain tensor + std::string _eigenstrain_name; + + ///Stores the current total eigenstrain + ADMaterialProperty(RankTwoTensor) & _eigenstrain; + + /** + * Helper function for models that compute the eigenstrain based on a volumetric + * strain. This function computes the diagonal components of the eigenstrain tensor + * as logarithmic strains. + * @param volumetric_strain The current volumetric strain to be applied + * @return Current strain in one direction due to volumetric strain, expressed as a logarithmic + * strain + */ + ADReal computeVolumetricStrainComponent(const ADReal volumetric_strain) const; + + /// Restartable data to check for the zeroth and first time steps for thermal calculations + bool & _step_zero; + + usingMaterialMembers; +}; + +#endif // ADADCOMPUTEEIGENSTRAINBASE_H diff --git a/modules/tensor_mechanics/src/materials/ADComputeEigenstrain.C b/modules/tensor_mechanics/src/materials/ADComputeEigenstrain.C new file mode 100644 index 000000000000..dd7216fdde13 --- /dev/null +++ b/modules/tensor_mechanics/src/materials/ADComputeEigenstrain.C @@ -0,0 +1,39 @@ +//* 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 "ADComputeEigenstrain.h" + +#include "RankTwoTensor.h" + +registerADMooseObject("TensorMechanicsApp", ADComputeEigenstrain); + +defineADValidParams(ADComputeEigenstrain, + ADComputeEigenstrainBase, + params.addClassDescription("Computes a constant Eigenstrain"); + params.addRequiredParam>( + "eigen_base", + "Vector of values defining the constant base tensor for the Eigenstrain"); + params.addParam( + "prefactor", 1.0, "Name of material defining the variable dependence");); + +template +ADComputeEigenstrain::ADComputeEigenstrain(const InputParameters & parameters) + : ADComputeEigenstrainBase(parameters), + _prefactor(adGetADMaterialProperty("prefactor")) +{ + _eigen_base_tensor.fillFromInputVector(adGetParam>("eigen_base")); +} + +template +void +ADComputeEigenstrain::computeQpEigenstrain() +{ + // Define Eigenstrain + _eigenstrain[_qp] = _eigen_base_tensor * _prefactor[_qp]; +} diff --git a/modules/tensor_mechanics/src/materials/ADComputeEigenstrainBase.C b/modules/tensor_mechanics/src/materials/ADComputeEigenstrainBase.C new file mode 100644 index 000000000000..f6bc74b99dc6 --- /dev/null +++ b/modules/tensor_mechanics/src/materials/ADComputeEigenstrainBase.C @@ -0,0 +1,86 @@ +//* 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 "ADComputeEigenstrainBase.h" + +#include "RankTwoTensor.h" + +defineADValidParams( + ADComputeEigenstrainBase, + ADMaterial, + params.addParam("base_name", + "Optional parameter that allows the user to define " + "multiple mechanics material systems on the same " + "block, i.e. for multiple phases"); + params.addRequiredParam( + "eigenstrain_name", + "Material property name for the eigenstrain tensor computed " + "by this model. IMPORTANT: The name of this property must " + "also be provided to the strain calculator."); + params.addDeprecatedParam( + "incremental_form", + false, + "Should the eigenstrain be in incremental form (for incremental models)?", + "This parameter no longer has any effect. Simply remove it.");); + +template +ADComputeEigenstrainBase::ADComputeEigenstrainBase( + const InputParameters & parameters) + : ADMaterial(parameters), + _base_name(isParamValid("base_name") ? adGetParam("base_name") + "_" : ""), + _eigenstrain_name(_base_name + adGetParam("eigenstrain_name")), + _eigenstrain(adDeclareADProperty(_eigenstrain_name)), + _step_zero(adDeclareRestartableData("step_zero", true)) +{ +} + +template +void +ADComputeEigenstrainBase::initQpStatefulProperties() +{ + // This property can be promoted to be stateful by other models that use it, + // so it needs to be initalized. + _eigenstrain[_qp].zero(); +} + +template +void +ADComputeEigenstrainBase::computeQpProperties() +{ + if (_t_step >= 1) + _step_zero = false; + + // Skip the eigenstrain calculation in step zero because no solution is computed during + // the zeroth step, hence computing the eigenstrain in the zeroth step would result in + // an incorrect calculation of mechanical_strain, which is stateful. + if (!_step_zero) + computeQpEigenstrain(); +} + +template +ADReal +ADComputeEigenstrainBase::computeVolumetricStrainComponent( + const ADReal volumetric_strain) const +{ + // The engineering strain in a given direction is: + // epsilon_eng = cbrt(volumetric_strain + 1.0) - 1.0 + // + // We need to provide this as a logarithmic strain to be consistent with the strain measure + // used for finite strain: + // epsilon_log = log(1.0 + epsilon_eng) + // + // This can be simplified down to a more direct form: + // epsilon_log = log(cbrt(volumetric_strain + 1.0)) + // or: + // epsilon_log = (1/3) log(volumetric_strain + 1.0) + + return std::log(volumetric_strain + 1.0) / 3.0; +} + +adBaseClass(ADComputeEigenstrainBase); From 24292625a29a0e55fb772db4ea3be048258f6dbf Mon Sep 17 00:00:00 2001 From: tophmatthews Date: Fri, 22 Mar 2019 09:26:45 -0600 Subject: [PATCH 2/3] Doco and moved to TM module (#13091) --- .../gold/applied_strain_out.e | 1 - .../gold/linear_elastic_material_out.e | 1 - .../ad_linear_elasticity/gold/tensor_out.e | 1 - .../gold/thermal_expansion_out.e | 1 - .../test/tests/ad_linear_elasticity/tests | 27 -------- .../source/materials/ADComputeEigenstrain.md | 30 +++++++++ .../ad_linear_elasticity/applied_strain.i | 0 .../gold/applied_strain_out.e | 1 + .../gold/linear_elastic_material_out.e | 1 + .../ad_linear_elasticity/gold/tensor_out.e | 1 + .../gold/thermal_expansion_out.e | 1 + .../linear_elastic_material.i | 7 ++ .../test/tests/ad_linear_elasticity/tensor.i | 7 ++ .../test/tests/ad_linear_elasticity/tests | 65 +++++++++++++++++++ .../ad_linear_elasticity/thermal_expansion.i | 0 15 files changed, 113 insertions(+), 31 deletions(-) delete mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e delete mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e delete mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e delete mode 120000 modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e delete mode 100644 modules/combined/test/tests/ad_linear_elasticity/tests create mode 100644 modules/tensor_mechanics/doc/content/source/materials/ADComputeEigenstrain.md rename modules/{combined => tensor_mechanics}/test/tests/ad_linear_elasticity/applied_strain.i (100%) create mode 120000 modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/applied_strain_out.e create mode 120000 modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e create mode 120000 modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/tensor_out.e create mode 120000 modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e rename modules/{combined => tensor_mechanics}/test/tests/ad_linear_elasticity/linear_elastic_material.i (97%) rename modules/{combined => tensor_mechanics}/test/tests/ad_linear_elasticity/tensor.i (99%) create mode 100644 modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests rename modules/{combined => tensor_mechanics}/test/tests/ad_linear_elasticity/thermal_expansion.i (100%) diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e deleted file mode 120000 index a2bf365f2a6a..000000000000 --- a/modules/combined/test/tests/ad_linear_elasticity/gold/applied_strain_out.e +++ /dev/null @@ -1 +0,0 @@ -../../linear_elasticity/gold/applied_strain_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e deleted file mode 120000 index 2b54ddf9e546..000000000000 --- a/modules/combined/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e +++ /dev/null @@ -1 +0,0 @@ -../../linear_elasticity/gold/linear_elastic_material_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e deleted file mode 120000 index 69d44d75bb20..000000000000 --- a/modules/combined/test/tests/ad_linear_elasticity/gold/tensor_out.e +++ /dev/null @@ -1 +0,0 @@ -../../linear_elasticity/gold/tensor_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e b/modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e deleted file mode 120000 index b9ea11f869ac..000000000000 --- a/modules/combined/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e +++ /dev/null @@ -1 +0,0 @@ -../../linear_elasticity/gold/thermal_expansion_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/tests b/modules/combined/test/tests/ad_linear_elasticity/tests deleted file mode 100644 index ec3225505f39..000000000000 --- a/modules/combined/test/tests/ad_linear_elasticity/tests +++ /dev/null @@ -1,27 +0,0 @@ -[Tests] - [./linear_elastic_material] - type = 'Exodiff' - input = 'linear_elastic_material.i' - exodiff = 'linear_elastic_material_out.e' - max_parallel = 1 - [../] - - [./applied_strain] - type = 'Exodiff' - input = 'applied_strain.i' - exodiff = 'applied_strain_out.e' - [../] - - [./tensor] - type = 'Exodiff' - input = 'tensor.i' - exodiff = 'tensor_out.e' - max_parallel = 1 - [../] - - [./thermal_expansion] - type = 'Exodiff' - input = 'thermal_expansion.i' - exodiff = 'thermal_expansion_out.e' - [../] -[] diff --git a/modules/tensor_mechanics/doc/content/source/materials/ADComputeEigenstrain.md b/modules/tensor_mechanics/doc/content/source/materials/ADComputeEigenstrain.md new file mode 100644 index 000000000000..fa21b8357484 --- /dev/null +++ b/modules/tensor_mechanics/doc/content/source/materials/ADComputeEigenstrain.md @@ -0,0 +1,30 @@ +# ADComputeEigenstrain + +!syntax description /Materials/ADComputeEigenstrain + +## Description + +The class `ADComputeEigenstrain` allows the user to specify a constant value of an eigenstrain for a simulation. +The eigenstrain is added to the mechanical strain, which can be elastic or inelastic, before computing the corresponding stress measure: +\begin{equation} + \epsilon_{ij}^{total} = \epsilon_{ij}^{mechanical} + \epsilon_{ij}^{eigenstrain} +\end{equation} + +Eigenstrain is the term given to a strain which does not result directly from an applied force. +Chapter 3 of [cite!qu2006fundamentals] describes the relationship between total, elastic, and eigen- strains and provides examples using thermal expansion and dislocations. +Eigenstrains are also referred to as residual strains, stress-free strains, or intrinsic strains; translated from German, [Eigen](http://dict.tu-chemnitz.de/deutsch-englisch/Eigen....html) means own or intrinsic in English. +The term eigenstrain was introduced by [cite!mura1982general]. + +Based on the number and values of constants provided as the argument to the `eigen_base` parameter, `ADComputeEigenstrain` will build an isotropic, symmetric, or skew-symmetric Rank-2 eigenstrain tensor. + +## Example Input File Syntax + +!listing modules/tensor_mechanics/test/tests/visco/gen_kv_driving.i block=Materials/eigen + +!syntax parameters /Materials/ADComputeEigenstrain + +!syntax inputs /Materials/ADComputeEigenstrain + +!syntax children /Materials/ADComputeEigenstrain + +!bibtex bibliography diff --git a/modules/combined/test/tests/ad_linear_elasticity/applied_strain.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/applied_strain.i similarity index 100% rename from modules/combined/test/tests/ad_linear_elasticity/applied_strain.i rename to modules/tensor_mechanics/test/tests/ad_linear_elasticity/applied_strain.i diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/applied_strain_out.e b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/applied_strain_out.e new file mode 120000 index 000000000000..7c2454fd8ce5 --- /dev/null +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/applied_strain_out.e @@ -0,0 +1 @@ +../../../../../combined/test/tests/linear_elasticity/gold/applied_strain_out.e \ No newline at end of file diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e new file mode 120000 index 000000000000..89a7c841122a --- /dev/null +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/linear_elastic_material_out.e @@ -0,0 +1 @@ +../../../../../combined/test/tests/linear_elasticity/gold/linear_elastic_material_out.e \ No newline at end of file diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/tensor_out.e b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/tensor_out.e new file mode 120000 index 000000000000..3dc2d566ffde --- /dev/null +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/tensor_out.e @@ -0,0 +1 @@ +../../../../../combined/test/tests/linear_elasticity/gold/tensor_out.e \ No newline at end of file diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e new file mode 120000 index 000000000000..b9e464a84c79 --- /dev/null +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/gold/thermal_expansion_out.e @@ -0,0 +1 @@ +../../../../../combined/test/tests/linear_elasticity/gold/thermal_expansion_out.e \ No newline at end of file diff --git a/modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i similarity index 97% rename from modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i rename to modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i index 5c78cd61e03a..d447e878dfa2 100644 --- a/modules/combined/test/tests/ad_linear_elasticity/linear_elastic_material.i +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i @@ -189,6 +189,13 @@ [../] [] +[Preconditioning] + [./full] + type = SMP + full = true + [../] +[] + [Executioner] type = Steady solve_type = 'PJFNK' diff --git a/modules/combined/test/tests/ad_linear_elasticity/tensor.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i similarity index 99% rename from modules/combined/test/tests/ad_linear_elasticity/tensor.i rename to modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i index a6e74c107515..5f1220a0b162 100644 --- a/modules/combined/test/tests/ad_linear_elasticity/tensor.i +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i @@ -471,6 +471,13 @@ [../] [] +[Preconditioning] + [./full] + type = SMP + full = true + [../] +[] + [Executioner] type = Steady solve_type = 'PJFNK' diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests new file mode 100644 index 000000000000..76cc4fedbd9e --- /dev/null +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests @@ -0,0 +1,65 @@ +[Tests] + issues = '#13099' + design = 'jacobian_definitions.md' + [./linear_elastic_material] + type = 'Exodiff' + input = 'linear_elastic_material.i' + exodiff = 'linear_elastic_material_out.e' + max_parallel = 1 + requirement = 'We shall be able to reproduce linear elastic stress results of the hand-coded simulation using automatic differentiation.' + [../] + [./linear_elastic_material-jac] + type = 'PetscJacobianTester' + input = 'linear_elastic_material.i' + run_sim = 'True' + ratio_tol = 1e-7 + difference_tol = 1e-1 + requirement = 'The Jacobian for the AD linear elastic stress problem shall be perfect' + [../] + + [./applied_strain] + type = 'Exodiff' + input = 'applied_strain.i' + exodiff = 'applied_strain_out.e' + requirement = 'We shall be able to reproduce eigenstrain results of the hand-coded simulation using automatic differentiation.' + [../] + [./applied_strain-jac] + type = 'PetscJacobianTester' + input = 'applied_strain.i' + run_sim = 'True' + ratio_tol = 1e-7 + difference_tol = 1e-1 + requirement = 'The Jacobian for the AD eigenstrain problem shall be perfect' + [../] + + [./tensor] + type = 'Exodiff' + input = 'tensor.i' + exodiff = 'tensor_out.e' + max_parallel = 1 + requirement = 'We shall be able to reproduce small strain with specified tensors results of the hand-coded simulation using automatic differentiation.' + [../] + [./tensor-jac] + type = 'PetscJacobianTester' + input = 'tensor.i' + run_sim = 'True' + ratio_tol = 1e-7 + difference_tol = 1e-4 + requirement = 'The Jacobian for the AD small strain with specified tensors problem shall be perfect' + [../] + + [./thermal_expansion] + type = 'Exodiff' + input = 'thermal_expansion.i' + exodiff = 'thermal_expansion_out.e' + requirement = 'We shall be able to reproduce thermal eigenstrain results of the hand-coded simulation using automatic differentiation.' + [../] + [./thermal_expansion-jac] + type = 'PetscJacobianTester' + input = 'thermal_expansion.i' + run_sim = 'True' + ratio_tol = 1e-7 + difference_tol = 1e-4 + requirement = 'The Jacobian for the AD thermal eigenstrain problem shall be perfect' + [../] +[] diff --git a/modules/combined/test/tests/ad_linear_elasticity/thermal_expansion.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/thermal_expansion.i similarity index 100% rename from modules/combined/test/tests/ad_linear_elasticity/thermal_expansion.i rename to modules/tensor_mechanics/test/tests/ad_linear_elasticity/thermal_expansion.i From e1f1ec65f8c4d2f61d1e27cbd73928f3a03b5de1 Mon Sep 17 00:00:00 2001 From: tophmatthews Date: Fri, 22 Mar 2019 10:51:12 -0600 Subject: [PATCH 3/3] Fixed comments, moved macro to Restartable (#13091) --- framework/include/restart/Restartable.h | 2 ++ .../include/materials/ADComputeEigenstrainBase.h | 2 -- .../test/tests/ad_linear_elasticity/applied_strain.i | 2 +- .../test/tests/ad_linear_elasticity/linear_elastic_material.i | 2 +- .../tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i | 2 +- .../tensor_mechanics/test/tests/ad_linear_elasticity/tests | 4 ++++ .../test/tests/ad_linear_elasticity/thermal_expansion.i | 2 +- 7 files changed, 10 insertions(+), 6 deletions(-) diff --git a/framework/include/restart/Restartable.h b/framework/include/restart/Restartable.h index 35eb2d3a9b92..5ec83c7a3b98 100644 --- a/framework/include/restart/Restartable.h +++ b/framework/include/restart/Restartable.h @@ -14,6 +14,8 @@ #include "MooseTypes.h" #include "RestartableData.h" +#define adDeclareRestartableData this->template declareRestartableData + // Forward declarations class PostprocessorData; class SubProblem; diff --git a/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h b/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h index 92d2bbf9553d..379e3e2b25e0 100644 --- a/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h +++ b/modules/tensor_mechanics/include/materials/ADComputeEigenstrainBase.h @@ -12,8 +12,6 @@ #include "ADMaterial.h" -#define adDeclareRestartableData this->template declareRestartableData - #define usingADComputeEigenstrainBaseMembers \ usingMaterialMembers; \ using ADComputeEigenstrainBase::_eigenstrain diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/applied_strain.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/applied_strain.i index 7faf790bf39a..9837e51d0c12 100644 --- a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/applied_strain.i +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/applied_strain.i @@ -24,7 +24,7 @@ # generate_output = 'strain_xx strain_yy strain_xy' # [] -### Replaceable by action +### Everything between here and the next ### should be replaceable by future action availability [Variables] [./disp_x] [../] diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i index d447e878dfa2..58755d6956c2 100644 --- a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/linear_elastic_material.i @@ -31,7 +31,7 @@ # generate_output = 'stress_xx stress_yy stress_zz stress_xy stress_yz stress_zx' # [] -### Replaceable by action +### Everything between here and the next ### should be replaceable by future action availability [Variables] [./disp_x] [../] diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i index 5f1220a0b162..c77e01605671 100644 --- a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tensor.i @@ -122,7 +122,7 @@ # generate_output = 'stress_xx stress_yy stress_zz stress_xy stress_yz stress_zx' # [] -### Replaceable by action +### Everything between here and the next ### should be replaceable by future action availability [Variables] [./disp_x] [../] diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests index 76cc4fedbd9e..b647f8748598 100644 --- a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/tests @@ -12,6 +12,7 @@ type = 'PetscJacobianTester' input = 'linear_elastic_material.i' run_sim = 'True' + petsc_version = '>=3.9' ratio_tol = 1e-7 difference_tol = 1e-1 requirement = 'The Jacobian for the AD linear elastic stress problem shall be perfect' @@ -27,6 +28,7 @@ type = 'PetscJacobianTester' input = 'applied_strain.i' run_sim = 'True' + petsc_version = '>=3.9' ratio_tol = 1e-7 difference_tol = 1e-1 requirement = 'The Jacobian for the AD eigenstrain problem shall be perfect' @@ -43,6 +45,7 @@ type = 'PetscJacobianTester' input = 'tensor.i' run_sim = 'True' + petsc_version = '>=3.9' ratio_tol = 1e-7 difference_tol = 1e-4 requirement = 'The Jacobian for the AD small strain with specified tensors problem shall be perfect' @@ -58,6 +61,7 @@ type = 'PetscJacobianTester' input = 'thermal_expansion.i' run_sim = 'True' + petsc_version = '>=3.9' ratio_tol = 1e-7 difference_tol = 1e-4 requirement = 'The Jacobian for the AD thermal eigenstrain problem shall be perfect' diff --git a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/thermal_expansion.i b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/thermal_expansion.i index d12d87ef332d..4deca3613eaa 100644 --- a/modules/tensor_mechanics/test/tests/ad_linear_elasticity/thermal_expansion.i +++ b/modules/tensor_mechanics/test/tests/ad_linear_elasticity/thermal_expansion.i @@ -31,7 +31,7 @@ # [] -### Replaceable by action +### Everything between here and the next ### should be replaceable by future action availability [Variables] [./disp_x] [../]