Skip to content

Commit

Permalink
Merge pull request #25203 from BoZeng1997/strainenergydensity_stressname
Browse files Browse the repository at this point in the history
Allow user-defined stress name in StrainEnergyDensity
  • Loading branch information
recuero authored Aug 16, 2023
2 parents 13120f9 + 1f93c98 commit e0c47c2
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ class StrainEnergyDensityTempl : public DerivativeMaterialInterface<Material>
/// Base name of the material system
const std::string _base_name;

/// stress name, for different stresses on the same material system
const std::string _stress_name;

/// The strain energy density material property
MaterialProperty<Real> & _strain_energy_density;
const MaterialProperty<Real> & _strain_energy_density_old;
Expand Down
12 changes: 10 additions & 2 deletions modules/tensor_mechanics/src/materials/StrainEnergyDensity.C
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ StrainEnergyDensityTempl<is_ad>::validParams()
"Optional parameter that allows the user to define "
"multiple mechanics material systems on the same "
"block, i.e. for multiple phases");
params.addParam<std::string>("stress_name",
"stress",
"Optional parameter that allows the user to use "
"different stresses on the same material system. "
"For example, when we have a degraded_stress and an intact_stress, "
"we want to compute the degraded strain energy density and "
"the intact strain energy density.");
params.addParam<bool>(
"incremental",
"Optional flag for error checking if an incremental or total model should be used.");
Expand All @@ -36,10 +43,11 @@ template <bool is_ad>
StrainEnergyDensityTempl<is_ad>::StrainEnergyDensityTempl(const InputParameters & parameters)
: DerivativeMaterialInterface<Material>(parameters),
_base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""),
_stress_name(getParam<std::string>("stress_name")),
_strain_energy_density(declareProperty<Real>(_base_name + "strain_energy_density")),
_strain_energy_density_old(getMaterialPropertyOld<Real>(_base_name + "strain_energy_density")),
_stress(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "stress")),
_stress_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + "stress")),
_stress(getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + _stress_name)),
_stress_old(getMaterialPropertyOld<RankTwoTensor>(_base_name + _stress_name)),
_mechanical_strain(
getGenericMaterialProperty<RankTwoTensor, is_ad>(_base_name + "mechanical_strain")),
_strain_increment(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
time,epxx,epyy,epzz,sigxx,sigyy,sigzz,test_SED
0,0,0,0,0,0,0,0
1,-1.2999983100025e-06,3.0333293900057e-06,0,-3.8440362004621e-12,99.999870000185,29.999961000054,-6.4999915499772e-05
10 changes: 10 additions & 0 deletions modules/tensor_mechanics/test/tests/strain_energy_density/tests
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,14 @@
requirement = 'The system shall be capable of calculating strain energy rate density when using '
'hand-coded Jacobian and weak plane stress.'
[]
[tot_elas_stress_name]
type = 'CSVDiff'
issues = '#25202'
input = 'tot_model_stress_name.i'
csvdiff = 'tot_model_stress_name_out.csv'
rel_err = 1e-6
design = 'StrainEnergyDensity.md'
requirement = 'The system shall be capable of calculating strain energy density for materials with '
'a user-specified stress by name and small strain.'
[]
[]
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Single element test to check the strain energy density calculation

[GlobalParams]
displacements = 'disp_x disp_y'
volumetric_locking_correction = true
[]

[Mesh]
type = GeneratedMesh
dim = 2
nx = 1
ny = 1
xmin = 0
xmax = 1
ymin = 0
ymax = 2
[]

[AuxVariables]
[SED]
order = CONSTANT
family = MONOMIAL
[]
[]

[Functions]
[rampConstantUp]
type = PiecewiseLinear
x = '0. 1.'
y = '0. 1.'
scale_factor = -100
[]
[]

[Modules/TensorMechanics/Master]
[master]
strain = SMALL
add_variables = true
incremental = false
generate_output = 'stress_xx stress_yy stress_zz vonmises_stress strain_xx strain_yy strain_zz'
planar_formulation = PLANE_STRAIN
[]
[]

[AuxKernels]
[SED]
type = MaterialRealAux
variable = SED
property = strain_energy_density
execute_on = timestep_end
[]
[]

[BCs]
[no_x]
type = DirichletBC
variable = disp_x
boundary = 'left'
value = 0.0
[]
[no_y]
type = DirichletBC
variable = disp_y
boundary = 'bottom'
value = 0.0
[]
[Pressure]
[top]
boundary = 'top'
function = rampConstantUp
[]
[]
[]

[Materials]
[elasticity_tensor]
type = ComputeIsotropicElasticityTensor
youngs_modulus = 30e+6
poissons_ratio = 0.3
[]
[elastic_stress]
type = ComputeLinearElasticStress
[]
[tensor]
type = GenericConstantRankTwoTensor
tensor_name = test_stress
tensor_values = '100 0 0 100 0 0 0 0 0'
[]
[strain_energy_density]
type = StrainEnergyDensity
incremental = false
stress_name = 'test_stress'
[]
[]

[Executioner]
type = Transient

petsc_options_iname = '-ksp_gmres_restart -pc_type -pc_hypre_type -pc_hypre_boomeramg_max_iter'
petsc_options_value = '201 hypre boomeramg 4'

line_search = 'none'

l_max_its = 50
nl_max_its = 20
nl_abs_tol = 3e-7
nl_rel_tol = 1e-12
l_tol = 1e-2

start_time = 0.0
dt = 1

end_time = 1
num_steps = 1
[]

[Postprocessors]
[epxx]
type = ElementalVariableValue
variable = strain_xx
elementid = 0
[]
[epyy]
type = ElementalVariableValue
variable = strain_yy
elementid = 0
[]
[epzz]
type = ElementalVariableValue
variable = strain_zz
elementid = 0
[]
[sigxx]
type = ElementAverageValue
variable = stress_xx
[]
[sigyy]
type = ElementAverageValue
variable = stress_yy
[]
[sigzz]
type = ElementAverageValue
variable = stress_zz
[]
[test_SED]
type = ElementAverageValue
variable = SED
[]
[]

[Outputs]
csv = true
[]

0 comments on commit e0c47c2

Please sign in to comment.