-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nonlocal cracktip material #29576
Open
lynnmunday
wants to merge
14
commits into
idaholab:next
Choose a base branch
from
lynnmunday:nonlocal_cracktip_matl
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Nonlocal cracktip material #29576
Changes from 11 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2e89488
Creating base class for nonlocal material averaged vector postprocess…
lynnmunday 5f0f10e
adding scalar material output at crack tip
lynnmunday 1adaba9
fixing tests for changes to CrackFrontNonlocalStress vpp input format…
lynnmunday 407b5fa
adding k_critical_vpp to MeshCut2D object
lynnmunday ab7fe50
adding k_critical_material and vpp to sample this material at the cra…
lynnmunday 8903f82
adding test for CrackFrontNonlocalScalar to solid_mechanics closes #2…
lynnmunday 21d16da
adding parameter error if kcritical is defined with both a vpp and si…
lynnmunday 908a049
clean up function signatures and doxygen
lynnmunday ac56eb7
adding documentation
lynnmunday 3740102
removed paramWarning that caused tests to fail
lynnmunday 22a9519
Fixing MeshCut2DFractureUserObject to use just stress based or consta…
lynnmunday dfffda7
Apply suggestions from code review
lynnmunday 78c7bb5
addressing user comments about name change
lynnmunday ad6bdcc
Daniel helped me move the property name to the derived class. closes …
lynnmunday File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...d_mechanics/doc/content/source/vectorpostprocessors/CrackFrontNonlocalScalar.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# CrackFrontNonlocalScalar | ||
|
||
!syntax description /VectorPostprocessors/CrackFrontNonlocalScalar | ||
|
||
## Description | ||
|
||
This object computes the average scalar material property at the crack front points defined by [CrackFrontDefinition.md]. The main use case for this `VectorPostprocessor` is to compute an average fracture toughness or $K_c$ at the crack front for use with the `MeshCut2DFractureUserObject` to grow cracks. This allows for spatially varying $K_c$ values defined by a `Material`. | ||
|
||
`CrackFrontNonlocalScalar` computes an average of the material property over a box-shaped domain at each crack tip point that is centered on the crack tip and extends [!param](/VectorPostprocessors/CrackFrontNonlocalScalar/box_length) in front of the crack tip. The [!param](/VectorPostprocessors/CrackFrontNonlocalScalar/box_height) is the dimension normal to the crack face, and [!param](/VectorPostprocessors/CrackFrontNonlocalScalar/box_width) is the dimension tangential to the crack face. [!param](/VectorPostprocessors/CrackFrontNonlocalScalar/box_width) is not used in 2D problems. | ||
|
||
In the following input file example, the mesh consists of a 3D plate with a hole in the middle. The CrackFrontDefinition defines crack points around the center line of the hole, `boundary=1001`. This `CrackFrontNonlocalScalar` averages a material property named `scalar_kcrit` over each 3D box at each crack front point. | ||
|
||
!listing crack_front_nonlocal_materials.i block=UserObjects VectorPostprocessors/CrackFrontNonlocalKcrit | ||
|
||
!syntax parameters /VectorPostprocessors/CrackFrontNonlocalScalar | ||
|
||
!syntax inputs /VectorPostprocessors/CrackFrontNonlocalScalar | ||
|
||
!syntax children /VectorPostprocessors/CrackFrontNonlocalScalar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalMaterialBase.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "ElementVectorPostprocessor.h" | ||
|
||
// Forward Declarations | ||
class CrackFrontDefinition; | ||
/** | ||
* Computes the average material property at points provided by the | ||
* crack_front_definition vectorpostprocessor. | ||
lynnmunday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
*/ | ||
|
||
class CrackFrontNonlocalMaterialBase : public ElementVectorPostprocessor | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
CrackFrontNonlocalMaterialBase(const InputParameters & parameters); | ||
|
||
virtual void initialSetup() override; | ||
virtual void initialize() override; | ||
virtual void execute() override; | ||
virtual void finalize() override; | ||
virtual void threadJoin(const UserObject & y) override; | ||
|
||
protected: | ||
/** 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 | ||
* _box_width is tangent to the crack tip, centered on the crack point | ||
* _box_height is normal to the crack tip, centered on the crack point | ||
*/ | ||
///@{ | ||
Real _box_length; | ||
Real _box_width; | ||
Real _box_height; | ||
///@} | ||
|
||
/// used to transform local coordinates to crack front coordinates | ||
const CrackFrontDefinition * _crack_front_definition; | ||
|
||
/// Base name of the material system | ||
const std::string _base_name; | ||
|
||
// volume being integrated over for each crack front | ||
std::vector<Real> _volume; | ||
|
||
/// Vectors computed by this VectorPostprocessor: | ||
/// x,y,z coordinates, and position of nodes along crack front, and crack tip average scalar stress | ||
///@{ | ||
VectorPostprocessorValue & _x; | ||
VectorPostprocessorValue & _y; | ||
VectorPostprocessorValue & _z; | ||
VectorPostprocessorValue & _position; | ||
VectorPostprocessorValue & _avg_crack_tip_scalar; | ||
///@} | ||
|
||
/** | ||
* Determine whether a point is located within a specified crack front oriented box | ||
* @param crack_front_point_index Index of the point on the crack front that the box is based on | ||
* @param qp_coord Point object to determine whether it is inside the box | ||
* @return 1 if point is within the box, 0 otherwise | ||
*/ | ||
Real BoxWeightingFunction(std::size_t crack_front_point_index, const Point & qp_coord) const; | ||
/** | ||
* Determine whether a point is located within a specified crack front oriented box | ||
* @param qp quardature point to get material properties at | ||
* @param crack_face_normal normal direction to crack face | ||
* @return Value of material property at this qp and direction | ||
*/ | ||
virtual Real getQPCrackFrontScalar(const unsigned int qp, | ||
const Point crack_face_normal) const = 0; | ||
}; |
31 changes: 31 additions & 0 deletions
31
modules/solid_mechanics/include/vectorpostprocessors/CrackFrontNonlocalScalar.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "CrackFrontNonlocalMaterialBase.h" | ||
|
||
/** | ||
* Computes the average material at points provided by the crack_front_definition | ||
* vectorpostprocessor. | ||
*/ | ||
class CrackFrontNonlocalScalar : public CrackFrontNonlocalMaterialBase | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
CrackFrontNonlocalScalar(const InputParameters & parameters); | ||
|
||
protected: | ||
/// The scalar material property | ||
const MaterialProperty<Real> & _scalar; | ||
|
||
Real getQPCrackFrontScalar(const unsigned int qp, | ||
const Point /*crack_face_normal*/) const override; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
modules/solid_mechanics/src/vectorpostprocessors/CrackFrontNonlocalMaterialBase.C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#include "CrackFrontNonlocalMaterialBase.h" | ||
#include "CrackFrontDefinition.h" | ||
|
||
InputParameters | ||
CrackFrontNonlocalMaterialBase::validParams() | ||
{ | ||
InputParameters params = ElementVectorPostprocessor::validParams(); | ||
params.addRequiredParam<UserObjectName>("crack_front_definition", | ||
"The CrackFrontDefinition user object name"); | ||
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 " | ||
"block, i.e. for multiple phases"); | ||
params.set<bool>("use_displaced_mesh") = false; | ||
// EXEC_NONLINEAR to work with xfem_udpates | ||
lynnmunday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
params.set<ExecFlagEnum>("execute_on") = {EXEC_TIMESTEP_BEGIN}; | ||
params.addClassDescription("Computes the average material property at a crack front."); | ||
return params; | ||
} | ||
|
||
CrackFrontNonlocalMaterialBase::CrackFrontNonlocalMaterialBase(const InputParameters & parameters) | ||
: ElementVectorPostprocessor(parameters), | ||
_box_length(getParam<Real>("box_length")), | ||
_box_width(isParamValid("box_width") ? getParam<Real>("box_width") : 1), | ||
_box_height(getParam<Real>("box_height")), | ||
_base_name(isParamValid("base_name") ? getParam<std::string>("base_name") + "_" : ""), | ||
_x(declareVector("x")), | ||
_y(declareVector("y")), | ||
_z(declareVector("z")), | ||
_position(declareVector("id")), | ||
_avg_crack_tip_scalar( | ||
declareVector("crack_tip_" + _base_name + getParam<std::string>("material_name"))) | ||
{ | ||
if (_mesh.dimension() == 3 && !isParamSetByUser("box_width")) | ||
paramError("box_width", "Must define box_width in 3D problems."); | ||
// add user object dependencies by name (the UOs do not need to exist yet for this) | ||
_depend_uo.insert(getParam<UserObjectName>("crack_front_definition")); | ||
} | ||
|
||
void | ||
CrackFrontNonlocalMaterialBase::initialSetup() | ||
{ | ||
// gather coupled user objects late to ensure they are constructed. Do not add them as | ||
// dependencies (that's already done in the constructor). | ||
const auto uo_name = getParam<UserObjectName>("crack_front_definition"); | ||
_crack_front_definition = | ||
&(getUserObjectByName<CrackFrontDefinition>(uo_name, /*is_dependency = */ false)); | ||
} | ||
|
||
void | ||
CrackFrontNonlocalMaterialBase::initialize() | ||
{ | ||
std::size_t num_pts = _crack_front_definition->getNumCrackFrontPoints(); | ||
|
||
_volume.assign(num_pts, 0.0); | ||
_x.assign(num_pts, 0.0); | ||
_y.assign(num_pts, 0.0); | ||
_z.assign(num_pts, 0.0); | ||
_position.assign(num_pts, 0.0); | ||
_avg_crack_tip_scalar.assign(num_pts, 0.0); | ||
} | ||
|
||
void | ||
CrackFrontNonlocalMaterialBase::execute() | ||
{ | ||
// icfp crack front point index | ||
for (std::size_t icfp = 0; icfp < _avg_crack_tip_scalar.size(); icfp++) | ||
{ | ||
Point crack_face_normal = _crack_front_definition->getCrackFrontNormal(icfp); | ||
lynnmunday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (unsigned int qp = 0; qp < _qrule->n_points(); qp++) | ||
{ | ||
Real q = BoxWeightingFunction(icfp, _q_point[qp]); | ||
if (q == 0) | ||
continue; | ||
|
||
Real scalar = getQPCrackFrontScalar(qp, crack_face_normal); | ||
lynnmunday marked this conversation as resolved.
Show resolved
Hide resolved
|
||
_avg_crack_tip_scalar[icfp] += _JxW[qp] * _coord[qp] * scalar * q; | ||
_volume[icfp] += _JxW[qp] * _coord[qp] * q; | ||
} | ||
} | ||
} | ||
|
||
void | ||
CrackFrontNonlocalMaterialBase::finalize() | ||
{ | ||
gatherSum(_avg_crack_tip_scalar); | ||
gatherSum(_volume); | ||
|
||
for (std::size_t icfp = 0; icfp < _avg_crack_tip_scalar.size(); ++icfp) | ||
{ | ||
if (_volume[icfp] != 0) | ||
_avg_crack_tip_scalar[icfp] = _avg_crack_tip_scalar[icfp] / _volume[icfp]; | ||
else | ||
_avg_crack_tip_scalar[icfp] = 0; | ||
|
||
const auto cfp = _crack_front_definition->getCrackFrontPoint(icfp); | ||
_x[icfp] = (*cfp)(0); | ||
_y[icfp] = (*cfp)(1); | ||
_z[icfp] = (*cfp)(2); | ||
_position[icfp] = _crack_front_definition->getDistanceAlongFront(icfp); | ||
} | ||
} | ||
|
||
void | ||
CrackFrontNonlocalMaterialBase::threadJoin(const UserObject & y) | ||
{ | ||
const auto & uo = static_cast<const CrackFrontNonlocalMaterialBase &>(y); | ||
|
||
for (auto i = beginIndex(_avg_crack_tip_scalar); i < _avg_crack_tip_scalar.size(); ++i) | ||
{ | ||
_volume[i] += uo._volume[i]; | ||
_avg_crack_tip_scalar[i] += uo._avg_crack_tip_scalar[i]; | ||
} | ||
} | ||
|
||
Real | ||
CrackFrontNonlocalMaterialBase::BoxWeightingFunction(std::size_t crack_front_point_index, | ||
const Point & qp_coord) const | ||
{ | ||
const Point * cf_pt = _crack_front_definition->getCrackFrontPoint(crack_front_point_index); | ||
RealVectorValue crack_node_to_current_node = qp_coord - *cf_pt; | ||
|
||
// crackfront coordinates are: | ||
// crack_node_to_current_node_rot[0]= crack direction | ||
// crack_node_to_current_node_rot[1]= normal to crack face | ||
// crack_node_to_current_node_rot[2]= tangent to crack face along crack front (not used in 2D) | ||
RealVectorValue crack_node_to_current_node_rot = | ||
_crack_front_definition->rotateToCrackFrontCoords(crack_node_to_current_node, | ||
crack_front_point_index); | ||
Real q = 0.0; | ||
if ((crack_node_to_current_node_rot(0) > 0) && | ||
(crack_node_to_current_node_rot(0) <= _box_length) && | ||
(std::abs(crack_node_to_current_node_rot(1)) <= _box_height / 2) && | ||
(std::abs(crack_node_to_current_node_rot(2)) <= _box_width / 2)) | ||
{ | ||
q = 1.0; | ||
} | ||
|
||
return q; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe something like
CrackFrontNonlocalScalarMaterial
would be more descriptive?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed