Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Guillaume Giudicelli <[email protected]>
  • Loading branch information
miaoyinb and GiudGiud committed Jan 27, 2025
1 parent 0a8efbf commit 8771a00
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# CutMeshByPlaneGenerator
# CutMeshByLevelSetGenerator

!syntax description /Mesh/CutMeshByLevelSetGenerator

## Overview

The `CutMeshByLevelSetGenerator` is an extended version of [`CutMeshByPlaneGenerator`](/CutMeshByPlaneGenerator.md). It is used to trim a 3D input mesh based on a given level set `f(x,y,z)`. The portion of the input mesh that is within the level set (i.e., `f(x,y,z)<=0`) is retained, while the portion of the input mesh that is outside the level set (i.e., `f(x,y,z)>0`) is discarded. The input mesh, given by [!param](/Mesh/CutMeshByLevelSetGenerator/input), must be 3D and contain only first-order elements. The level set is specified by [!param](/Mesh/CutMeshByLevelSetGenerator/level_set), which can be interpreted by `FParser` as a function of `x`, `y`, and `z` (i.e., `f(x,y,z)`). The mesh is then smoothed to avert a "zigzag" cut along element boundaries.

Using this mesh generator, a 3D structured mesh defined by a bounding box (e.g., generated by [`GeneratedMeshGenerator`](/GeneratedMeshGenerator.md)) can be subtracted into a 3D mesh with its shape define by a given level set. Such a 3D mesh could be further used as an input of [`XYZDelaunayGenerator`](/XYZDelaunayGenerator.md).
Using this mesh generator, a 3D structured mesh defined by a bounding box (e.g., generated by [`GeneratedMeshGenerator`](/GeneratedMeshGenerator.md)) can be subtracted into a 3D mesh with its shape define by a given level set.

## Methods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class CutMeshByLevelSetGeneratorBase : public MeshGenerator, public FunctionPars
SymFunctionPtr _func_level_set;

/**
* Evaluate the whether a point is on the level set, inside or outside the level set.
* Evaluate whether a point is on the level set, inside or outside the level set.
* @param point The point at which the level set function is to be evaluated
* @return the relation of the point to the level set
*/
Expand All @@ -63,8 +63,8 @@ class CutMeshByLevelSetGeneratorBase : public MeshGenerator, public FunctionPars
Point pointPairLevelSetInterception(const Point & point1, const Point & point2);

/**
* For a TET4 elements crossed by the cutting plane, keep the part of the element on the retaining
* side of the plane using a number of TET4 elements.
* For a TET4 elements crossed by the level set, keep the part of the element on the retaining
* side of the level set using a number of TET4 elements.
* @param mesh The mesh to be modified
* @param bdry_side_list A list that contains the boundary information of the original mesh
* @param elem_id The id of the element to be cut
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ CutMeshByLevelSetGeneratorBase::validParams()

params.addClassDescription(
"This CutMeshByLevelSetGeneratorBase object is designed to be the base class of mesh "
"generator that cuts a 3D mesh based on a analytic level set function. The level set "
"generator that cuts a 3D mesh based on an analytic level set function. The level set "
"function could be provided explicitly or indirectly.");

return params;
Expand Down Expand Up @@ -189,6 +189,7 @@ CutMeshByLevelSetGeneratorBase::pointPairLevelSetInterception(const Point & poin
Real dist = abs(dist1) + abs(dist2);
Point mid_point;

// Bisection method to find midpoint
while (MooseUtils::absoluteFuzzyGreaterThan(dist, 0.0))
{
mid_point = 0.5 * (p1 + p2);
Expand Down
2 changes: 1 addition & 1 deletion framework/src/meshgenerators/CutMeshByPlaneGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CutMeshByPlaneGenerator::CutMeshByPlaneGenerator(const InputParameters & paramet
_func_level_set = std::make_shared<SymFunction>();
// set FParser internal feature flags
setParserFeatureFlags(_func_level_set);
// The plance is (x - x0) * n_x + (y - y0) * n_y + (z - z0) * n_z = 0
// The plane is (x - x0) * n_x + (y - y0) * n_y + (z - z0) * n_z = 0
std::stringstream level_set_ss;
// Let's be conservative about precision here
level_set_ss << std::fixed << std::setprecision(15) << _plane_normal(0) << "*(x-"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
csvdiff = 'cut_xyzd_out.csv'
mesh_mode = 'REPLICATED'
recover = false
detail ='cut a 3D mesh to generator a raw level set mesh that can be used for 3D delaunay mesh generation.'
detail ='cut a 3D mesh to generate a raw level set mesh that can be used for 3D Delaunay mesh generation.'
[]
[]
# Does not need error tests as they have been covered by CutMeshByPlaneGenerator
Expand Down

0 comments on commit 8771a00

Please sign in to comment.