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 91b45b9
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 17 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 @@ -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,12 +17,17 @@ 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))
{
}

Expand Down
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
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 91b45b9

Please sign in to comment.