From 1c8311995ff8b8c30b8fa40620f2ed032388df0f 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 --- .../CrackFrontNonlocalMaterialBase.h | 5 ++++- .../CrackFrontNonlocalStress.h | 4 ++-- .../CrackFrontNonlocalMaterialBase.C | 10 +++++----- .../CrackFrontNonlocalScalarMaterial.C | 16 ++++++++++------ .../CrackFrontNonlocalStress.C | 6 ++++-- .../crack_front_nonlocal_materials.i | 4 ++-- .../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 +- .../stress_based_meshCut_uo.i | 2 +- 11 files changed, 37 insertions(+), 29 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..e3b67129db32 100644 --- a/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalScalarMaterial.C +++ b/modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalScalarMaterial.C @@ -17,18 +17,22 @@ 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 +Real CrackFrontNonlocalScalarMaterial::getQPCra +ckFrontScalar(const unsigned int qp, 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/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