From 4512c857eff09989e5f4a3609d956aa2de570f7c Mon Sep 17 00:00:00 2001 From: Lynn Munday Date: Mon, 23 Dec 2024 14:28:39 -0700 Subject: [PATCH] Daniel helped me move the property name to the derived class. closes #29575 --- .../CrackFrontNonlocalMaterialBase.h | 5 ++++- .../vectorpostprocessors/CrackFrontNonlocalStress.h | 4 ++-- .../CrackFrontNonlocalMaterialBase.C | 10 +++++----- .../CrackFrontNonlocalScalarMaterial.C | 13 +++++++++---- .../vectorpostprocessors/CrackFrontNonlocalStress.C | 6 ++++-- .../crack_front_nonlocal_materials.i | 4 ++-- .../userobjects/MeshCut2DFractureUserObject.md | 2 +- .../src/userobjects/MeshCut2DFractureUserObject.C | 13 ++++++------- .../crack_front_stress_function_growth.i | 2 +- .../kcrit_stress_based_meshCut_uo.i | 2 +- .../mesh_cut_2D_fracture/kvpp_based_meshCut_uo.i | 2 +- .../mesh_cut_2D_fracture/stress_based_meshCut_uo.i | 2 +- modules/xfem/test/tests/mesh_cut_2D_fracture/tests | 1 + 13 files changed, 38 insertions(+), 28 deletions(-) diff --git a/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalMaterialBase.h b/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalMaterialBase.h index 01e82230813c..eec9bc46bd21 100644 --- a/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalMaterialBase.h +++ b/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalMaterialBase.h @@ -23,7 +23,8 @@ class CrackFrontNonlocalMaterialBase : public ElementVectorPostprocessor public: static InputParameters validParams(); - CrackFrontNonlocalMaterialBase(const InputParameters & parameters); + CrackFrontNonlocalMaterialBase(const InputParameters & parameters, + const std::string & property_name); virtual void initialSetup() override; virtual void initialize() override; @@ -32,6 +33,8 @@ class CrackFrontNonlocalMaterialBase : public ElementVectorPostprocessor virtual void threadJoin(const UserObject & y) override; protected: + /// Material property name from derived class + const std::string _property_name; /** dimensions of the box in front of the crack tip that the stress is averaged over * The box is centered in front of the crack tip * _box_length distance box extends in front of the crack tip diff --git a/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalStress.h b/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalStress.h index 9e6f6f96963f..fb59f73f7245 100644 --- a/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalStress.h +++ b/modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalStress.h @@ -13,8 +13,8 @@ #include "RankTwoTensor.h" /** - * Computes the average stress magnitude in the direction normal to the crack front at points provided by the - * crack_front_definition vectorpostprocessor. + * Computes the average stress magnitude in the direction normal to the crack front at points + * provided by the crack_front_definition vectorpostprocessor. */ class CrackFrontNonlocalStress : public CrackFrontNonlocalMaterialBase diff --git a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalMaterialBase.C b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalMaterialBase.C index ae0d54b701b7..c446c87c90e4 100644 --- a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalMaterialBase.C +++ b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalMaterialBase.C @@ -19,8 +19,6 @@ CrackFrontNonlocalMaterialBase::validParams() params.addRequiredParam("box_length", "Distance in front of crack front."); params.addRequiredParam("box_height", "Distance normal to front of crack front."); params.addParam("box_width", "Distance tangent to front of crack front."); - params.addRequiredParam("material_name", - "Get name of material property to compute at crack front"); params.addParam("base_name", "Optional parameter that allows the user to define " "multiple mechanics material systems on the same " @@ -31,8 +29,10 @@ CrackFrontNonlocalMaterialBase::validParams() return params; } -CrackFrontNonlocalMaterialBase::CrackFrontNonlocalMaterialBase(const InputParameters & parameters) +CrackFrontNonlocalMaterialBase::CrackFrontNonlocalMaterialBase(const InputParameters & parameters, + const std::string & property_name) : ElementVectorPostprocessor(parameters), + _property_name(property_name), _box_length(getParam("box_length")), _box_width(isParamValid("box_width") ? getParam("box_width") : 1), _box_height(getParam("box_height")), @@ -41,8 +41,8 @@ CrackFrontNonlocalMaterialBase::CrackFrontNonlocalMaterialBase(const InputParame _y(declareVector("y")), _z(declareVector("z")), _position(declareVector("id")), - _avg_crack_tip_scalar( - declareVector("crack_tip_" + _base_name + getParam("material_name"))) + // get the property name instead of materialname + _avg_crack_tip_scalar(declareVector("crack_tip_" + _base_name + _property_name)) { if (_mesh.dimension() == 3 && !isParamSetByUser("box_width")) paramError("box_width", "Must define box_width in 3D problems."); diff --git a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalScalarMaterial.C b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalScalarMaterial.C index 21630ee23680..28d1ee4262c9 100644 --- a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalScalarMaterial.C +++ b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalScalarMaterial.C @@ -17,18 +17,23 @@ CrackFrontNonlocalScalarMaterial::validParams() InputParameters params = CrackFrontNonlocalMaterialBase::validParams(); params.addClassDescription("Computes the average material at points provided by the " "crack_front_definition vectorpostprocessor."); + params.addRequiredParam( + "property_name", "Get name of material property to compute at crack front"); + return params; } -CrackFrontNonlocalScalarMaterial::CrackFrontNonlocalScalarMaterial(const InputParameters & parameters) - : CrackFrontNonlocalMaterialBase(parameters), - _scalar(getMaterialProperty(_base_name + getParam("material_name"))) +CrackFrontNonlocalScalarMaterial::CrackFrontNonlocalScalarMaterial( + const InputParameters & parameters) + : CrackFrontNonlocalMaterialBase(parameters, + parameters.get("property_name")), + _scalar(getMaterialProperty(_base_name + _property_name)) { } Real CrackFrontNonlocalScalarMaterial::getQPCrackFrontScalar(const unsigned int qp, - const Point /*crack_face_normal*/) const + const Point /*crack_face_normal*/) const { return _scalar[qp]; } diff --git a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalStress.C b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalStress.C index 1edde8cf8c7c..d2a4c50960f8 100644 --- a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalStress.C +++ b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalStress.C @@ -17,12 +17,14 @@ CrackFrontNonlocalStress::validParams() { InputParameters params = CrackFrontNonlocalMaterialBase::validParams(); params.addClassDescription("Computes the average stress normal to the crack face."); + params.addRequiredParam( + "stress_name", "Get name of stress tensor to compute at crack front"); return params; } CrackFrontNonlocalStress::CrackFrontNonlocalStress(const InputParameters & parameters) - : CrackFrontNonlocalMaterialBase(parameters), - _stress(getMaterialProperty(_base_name + getParam("material_name"))) + : CrackFrontNonlocalMaterialBase(parameters, parameters.get("stress_name")), + _stress(getMaterialProperty(_base_name + _property_name)) { } diff --git a/modules/solid_mechanics/test/tests/crack_front_materials/crack_front_nonlocal_materials.i b/modules/solid_mechanics/test/tests/crack_front_materials/crack_front_nonlocal_materials.i index 3945d9f004dc..d7ece269e26e 100644 --- a/modules/solid_mechanics/test/tests/crack_front_materials/crack_front_nonlocal_materials.i +++ b/modules/solid_mechanics/test/tests/crack_front_materials/crack_front_nonlocal_materials.i @@ -45,7 +45,7 @@ [VectorPostprocessors] [CrackFrontNonlocalStress] type = CrackFrontNonlocalStress - material_name = stress + stress_name = stress base_name = generic crack_front_definition = crack box_length = 0.1 @@ -54,7 +54,7 @@ [] [CrackFrontNonlocalKcrit] type = CrackFrontNonlocalScalarMaterial - material_name = kcrit + property_name = kcrit base_name = scalar crack_front_definition = crack box_length = 0.1 diff --git a/modules/xfem/doc/content/source/userobjects/MeshCut2DFractureUserObject.md b/modules/xfem/doc/content/source/userobjects/MeshCut2DFractureUserObject.md index 68abd14d33f5..ef6ba08330b3 100644 --- a/modules/xfem/doc/content/source/userobjects/MeshCut2DFractureUserObject.md +++ b/modules/xfem/doc/content/source/userobjects/MeshCut2DFractureUserObject.md @@ -12,7 +12,7 @@ The crack propagates if the failure criterion is met, given by: K_c \le \sqrt{K^2_I+K^2_{II}} \end{equation} -where $K_I$ and $K_{II}$ are the mode I and II stress intensity factors provided by the fracture integral and the material property $K_c$ is defined in the input file with a constant value for the entire domain using [!param](/UserObjects/MeshCut2DFractureUserObject/k_critical) or from a [CrackFrontNonlocalScalar.md] VectorPostprocessor that samples a material property at each crack front point and is specified by [!param](/UserObjects/MeshCut2DFractureUserObject/k_critical_vectorpostprocessor) and [!param](/UserObjects/MeshCut2DFractureUserObject/k_critical_vector_name). The crack growth direction is given by the direction that maximizes the crack-tip hoop stress, given by Equation 5 in [!cite](jiang2020). The growth increment is a user provided input given by [!param](/UserObjects/MeshCut2DFractureUserObject/growth_increment). The fracture integrals $K_I$ and $K_{II}$ are obtained from the [InteractionIntegral.md] vectorpostprocessor specified in the input file by [!param](/UserObjects/MeshCut2DFractureUserObject/ki_vectorpostprocessor) and [!param](/UserObjects/MeshCut2DFractureUserObject/kii_vectorpostprocessor). Defaults for [!param](/UserObjects/MeshCut2DFractureUserObject/ki_vectorpostprocessor) and [!param](/UserObjects/MeshCut2DFractureUserObject/kii_vectorpostprocessor) use the names produced by the [/DomainIntegralAction.md] which is the standard way to set-up the [InteractionIntegral.md]. +where $K_I$ and $K_{II}$ are the mode I and II stress intensity factors provided by the fracture integral and the material property $K_c$ is defined in the input file with a constant value for the entire domain using [!param](/UserObjects/MeshCut2DFractureUserObject/k_critical) or from a [CrackFrontNonlocalScalarMaterial.md] VectorPostprocessor that samples a material property at each crack front point and is specified by [!param](/UserObjects/MeshCut2DFractureUserObject/k_critical_vectorpostprocessor) and [!param](/UserObjects/MeshCut2DFractureUserObject/k_critical_vector_name). The crack growth direction is given by the direction that maximizes the crack-tip hoop stress, given by Equation 5 in [!cite](jiang2020). The growth increment is a user provided input given by [!param](/UserObjects/MeshCut2DFractureUserObject/growth_increment). The fracture integrals $K_I$ and $K_{II}$ are obtained from the [InteractionIntegral.md] vectorpostprocessor specified in the input file by [!param](/UserObjects/MeshCut2DFractureUserObject/ki_vectorpostprocessor) and [!param](/UserObjects/MeshCut2DFractureUserObject/kii_vectorpostprocessor). Defaults for [!param](/UserObjects/MeshCut2DFractureUserObject/ki_vectorpostprocessor) and [!param](/UserObjects/MeshCut2DFractureUserObject/kii_vectorpostprocessor) use the names produced by the [/DomainIntegralAction.md] which is the standard way to set-up the [InteractionIntegral.md]. Near a free surface, the integration volumes of the rings used to compute the `InteractionIntegral` will intersect the surface, leading to a reduction in the fracture integral values. This can lead to cracks becoming unable to farther propagate as they approach free surfaces. For these cases, a maximum stress criterion computed using [CrackFrontNonlocalStress.md] vectorpostprocessor can be used for crack growth using an additional failure criterion given by: diff --git a/modules/xfem/src/userobjects/MeshCut2DFractureUserObject.C b/modules/xfem/src/userobjects/MeshCut2DFractureUserObject.C index 67dc19a7d262..4b00d5032e7e 100644 --- a/modules/xfem/src/userobjects/MeshCut2DFractureUserObject.C +++ b/modules/xfem/src/userobjects/MeshCut2DFractureUserObject.C @@ -131,13 +131,12 @@ MeshCut2DFractureUserObject::findActiveBoundaryGrowth() _original_and_current_front_node_ids.size()); if (_k_critical_vpp && ((_k_critical_vpp->size() != _original_and_current_front_node_ids.size()))) - mooseError( - "k_critical_vectorpostprocessor must have the same number of crack front points as " - "CrackFrontDefinition.", - "\n k_critical_vectorpostprocessor size = ", - _k_critical_vpp->size(), - "\n cracktips in MeshCut2DFractureUserObject = ", - _original_and_current_front_node_ids.size()); + mooseError("k_critical_vectorpostprocessor must have the same number of crack front points as " + "CrackFrontDefinition.", + "\n k_critical_vectorpostprocessor size = ", + _k_critical_vpp->size(), + "\n cracktips in MeshCut2DFractureUserObject = ", + _original_and_current_front_node_ids.size()); _active_front_node_growth_vectors.clear(); for (unsigned int i = 0; i < _original_and_current_front_node_ids.size(); ++i) diff --git a/modules/xfem/test/tests/mesh_cut_2D_fracture/crack_front_stress_function_growth.i b/modules/xfem/test/tests/mesh_cut_2D_fracture/crack_front_stress_function_growth.i index 1e1ea52e5938..b94f0c9b6536 100644 --- a/modules/xfem/test/tests/mesh_cut_2D_fracture/crack_front_stress_function_growth.i +++ b/modules/xfem/test/tests/mesh_cut_2D_fracture/crack_front_stress_function_growth.i @@ -119,7 +119,7 @@ [CrackFrontNonlocalStress] type = CrackFrontNonlocalStress base_name = generic - material_name = stress + stress_name = stress crack_front_definition = crack_tip box_length = 0.1 box_height = 0.05 diff --git a/modules/xfem/test/tests/mesh_cut_2D_fracture/kcrit_stress_based_meshCut_uo.i b/modules/xfem/test/tests/mesh_cut_2D_fracture/kcrit_stress_based_meshCut_uo.i index 3f82716f810a..1282236b043e 100644 --- a/modules/xfem/test/tests/mesh_cut_2D_fracture/kcrit_stress_based_meshCut_uo.i +++ b/modules/xfem/test/tests/mesh_cut_2D_fracture/kcrit_stress_based_meshCut_uo.i @@ -1,7 +1,7 @@ [VectorPostprocessors] [CrackFrontNonlocalStressVpp] type = CrackFrontNonlocalStress - material_name = stress + stress_name = stress crack_front_definition = crackFrontDefinition box_length = 0.05 box_height = 0.1 diff --git a/modules/xfem/test/tests/mesh_cut_2D_fracture/kvpp_based_meshCut_uo.i b/modules/xfem/test/tests/mesh_cut_2D_fracture/kvpp_based_meshCut_uo.i index 071c4f937c7a..a618552bd2fd 100644 --- a/modules/xfem/test/tests/mesh_cut_2D_fracture/kvpp_based_meshCut_uo.i +++ b/modules/xfem/test/tests/mesh_cut_2D_fracture/kvpp_based_meshCut_uo.i @@ -1,7 +1,7 @@ [VectorPostprocessors] [CrackFrontNonlocalScalarVpp] type = CrackFrontNonlocalScalarMaterial - material_name = k_crit_mat + property_name = k_crit_mat crack_front_definition = crackFrontDefinition box_length = 0.05 box_height = 0.1 diff --git a/modules/xfem/test/tests/mesh_cut_2D_fracture/stress_based_meshCut_uo.i b/modules/xfem/test/tests/mesh_cut_2D_fracture/stress_based_meshCut_uo.i index d34f08c47a87..1c2e68ecc24e 100644 --- a/modules/xfem/test/tests/mesh_cut_2D_fracture/stress_based_meshCut_uo.i +++ b/modules/xfem/test/tests/mesh_cut_2D_fracture/stress_based_meshCut_uo.i @@ -1,7 +1,7 @@ [VectorPostprocessors] [CrackFrontNonlocalStressVpp] type = CrackFrontNonlocalStress - material_name = stress + stress_name = stress crack_front_definition = crackFrontDefinition box_length = 0.05 box_height = 0.1 diff --git a/modules/xfem/test/tests/mesh_cut_2D_fracture/tests b/modules/xfem/test/tests/mesh_cut_2D_fracture/tests index 3bfcdfd6361a..aa496f718fdb 100644 --- a/modules/xfem/test/tests/mesh_cut_2D_fracture/tests +++ b/modules/xfem/test/tests/mesh_cut_2D_fracture/tests @@ -49,6 +49,7 @@ input = 'edge_crack_2d_propagation.i kvpp_based_meshCut_uo.i' cli_args = "UserObjects/cut_mesh2/k_critical=100" expect_err = 'Fracture toughness cannot be specified by both k_critical and k_critical_vectorpostprocessor.' + detail = ' and produce an error when fracture toughness is specified by more than one input source.'' [] [stress_check] type = CSVDiff