Skip to content

Commit

Permalink
Daniel helped me move the property name to the derived class
Browse files Browse the repository at this point in the history
  • Loading branch information
lynnmunday committed Dec 23, 2024
1 parent 78c7bb5 commit 1c83119
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ CrackFrontNonlocalMaterialBase::validParams()
params.addRequiredParam<Real>("box_length", "Distance in front of crack front.");
params.addRequiredParam<Real>("box_height", "Distance normal to front of crack front.");
params.addParam<Real>("box_width", "Distance tangent to front of crack front.");
params.addRequiredParam<std::string>("material_name",
"Get name of material property to compute at crack front");
params.addParam<std::string>("base_name",
"Optional parameter that allows the user to define "
"multiple mechanics material systems on the same "
Expand All @@ -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<Real>("box_length")),
_box_width(isParamValid("box_width") ? getParam<Real>("box_width") : 1),
_box_height(getParam<Real>("box_height")),
Expand All @@ -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<std::string>("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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MaterialPropertyName>(
"property_name", "Get name of material property to compute at crack front");

return params;
}

CrackFrontNonlocalScalarMaterial::CrackFrontNonlocalScalarMaterial(const InputParameters & parameters)
: CrackFrontNonlocalMaterialBase(parameters),
_scalar(getMaterialProperty<Real>(_base_name + getParam<std::string>("material_name")))
CrackFrontNonlocalScalarMaterial::CrackFrontNonlocalScalarMaterial(
const InputParameters & parameters)
: CrackFrontNonlocalMaterialBase(parameters,
parameters.get<MaterialPropertyName>("property_name")),
_scalar(getMaterialProperty<Real>(_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];
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@ CrackFrontNonlocalStress::validParams()
{
InputParameters params = CrackFrontNonlocalMaterialBase::validParams();
params.addClassDescription("Computes the average stress normal to the crack face.");
params.addRequiredParam<MaterialPropertyName>(
"stress_name", "Get name of stress tensor to compute at crack front");
return params;
}

CrackFrontNonlocalStress::CrackFrontNonlocalStress(const InputParameters & parameters)
: CrackFrontNonlocalMaterialBase(parameters),
_stress(getMaterialProperty<RankTwoTensor>(_base_name + getParam<std::string>("material_name")))
: CrackFrontNonlocalMaterialBase(parameters, parameters.get<MaterialPropertyName>("stress_name")),
_stress(getMaterialProperty<RankTwoTensor>(_base_name + _property_name))
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -54,7 +54,7 @@
[]
[CrackFrontNonlocalKcrit]
type = CrackFrontNonlocalScalarMaterial
material_name = kcrit
property_name = kcrit
base_name = scalar
crack_front_definition = crack
box_length = 0.1
Expand Down
13 changes: 6 additions & 7 deletions modules/xfem/src/userobjects/MeshCut2DFractureUserObject.C
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1c83119

Please sign in to comment.