Skip to content

Commit

Permalink
Merge pull request #28298 from roystgnr/XYZDelaunay
Browse files Browse the repository at this point in the history
XYZDelaunayMeshGenerator
  • Loading branch information
roystgnr authored Sep 18, 2024
2 parents 32a5a5b + 22fc62f commit bd14992
Show file tree
Hide file tree
Showing 16 changed files with 947 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ vertices. Additional interior vertices can be automatically generated
by specifying a desired triangle area (either as a constant or as a
function of triangle center location that can be specified or
automatically generated). Additional interior boundary "holes" can
be meshed by the mesh generators specified in the [!param](/Mesh/XYDelaunayGenerator/holes) vector parameter.
be specified by the mesh generators specified in the [!param](/Mesh/XYDelaunayGenerator/holes) vector parameter.

Each input mesh, as specified in the
[!param](/Mesh/XYDelaunayGenerator/boundary) parameter and optionally
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# XYZDelaunayGenerator

!syntax description /Mesh/XYZDelaunayGenerator

An input mesh will be used to define the outer boundary of a
generated tetrahedral output mesh. Additional interior vertices can
be automatically generated by specifying a desired tetrahedral volume.
Additional interior boundary "holes" can be specified by the mesh
generators specified in the [!param](/Mesh/XYZDelaunayGenerator/holes)
vector parameter.

Each input mesh, as specified in the
[!param](/Mesh/XYZDelaunayGenerator/boundary) parameter and optionally
in the [!param](/Mesh/XYZDelaunayGenerator/holes) parameter,
can define a closed manifold of boundary triangles either by including
Tri3 elements for each triangle or by including volume elements whose
external faces comprise the boundary manifold.

If multiple disconnected manifolds exist in a boundary mesh, only the
manifold enclosing the rest of the mesh is considered to be "the"
boundary. Input meshes which are not connected, which therefore have
multiple outer boundary manifolds, are not yet supported.

Nodes internal to the boundary mesh are currently ignored. Future
expansions of this class may allow such nodes to be retained as nodes
in the output tetrahedralization.

Using stitching options, meshes used as "holes" can subsequently be
stitched into those portions of the output mesh.

Interior vertices can be adjusted after mesh generation using the
[!param](/Mesh/XYZDelaunayGenerator/smooth_triangulation) parameter,
to produce a more "smooth" mesh, but currently the only mesh smoother
option is a simple Laplacian smoother; this can have unwanted
side-effects on meshes with concave boundaries or poor nodal valences,
and so it is disabled by default for robustness.

The elements generated by `XYZDelaunayGenerator` can be refined according
to a given uniform element volume specified as
[!param](/Mesh/XYZDelaunayGenerator/desired_volume).
This refinement is currently controlled by the third-party Netgen
code.

!syntax parameters /Mesh/XYZDelaunayGenerator

!syntax inputs /Mesh/XYZDelaunayGenerator


52 changes: 52 additions & 0 deletions framework/include/meshgenerators/XYZDelaunayGenerator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
//* 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 "MeshGenerator.h"

/**
* Generates a tetrahedral mesh, based on an input mesh defining the
* outer boundary and an optional set of input meshes defining inner
* hole boundaries.
*/
class XYZDelaunayGenerator : public MeshGenerator
{
public:
static InputParameters validParams();

XYZDelaunayGenerator(const InputParameters & parameters);

std::unique_ptr<MeshBase> generate() override;

protected:
/// Input mesh defining the boundary to triangulate within
std::unique_ptr<MeshBase> & _bdy_ptr;

/// Desired volume of output tetrahedra
const Real _desired_volume;

/// What subdomain_id to set on the generated tetrahedra
SubdomainID _output_subdomain_id;

/// Whether to do Laplacian mesh smoothing on the generated triangles
const bool _smooth_tri;

/// Holds pointers to the pointers to input meshes defining holes
const std::vector<std::unique_ptr<MeshBase> *> _hole_ptrs;

/// Whether to stitch to the mesh defining each hole
const std::vector<bool> _stitch_holes;

/// Type of algorithm used to find matching nodes (binary or exhaustive)
const MooseEnum _algorithm;

/// Whether mesh stitching should have verbose output
const bool _verbose_stitching;
};
16 changes: 8 additions & 8 deletions framework/src/meshgenerators/XYDelaunayGenerator.C
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ XYDelaunayGenerator::XYDelaunayGenerator(const InputParameters & parameters)
for (auto hole_i : index_range(_stitch_holes))
if (_stitch_holes[hole_i] && (hole_i >= _refine_holes.size() || _refine_holes[hole_i]))
paramError("refine_holes", "Disable auto refine of any hole boundary to be stitched.");

if (isParamValid("hole_boundaries"))
{
auto & hole_boundaries = getParam<std::vector<BoundaryName>>("hole_boundaries");
if (hole_boundaries.size() != _hole_ptrs.size())
paramError("hole_boundaries", "Need one hole_boundaries entry per hole, if specified.");
}
}

std::unique_ptr<MeshBase>
Expand Down Expand Up @@ -340,10 +347,6 @@ XYDelaunayGenerator::generate()
}
}

// Assign new subdomain name, if provided
if (isParamValid("output_subdomain_name"))
mesh->subdomain_name(_output_subdomain_id) = getParam<SubdomainName>("output_subdomain_name");

const bool use_binary_search = (_algorithm == "BINARY");

// The hole meshes are specified by the user, so they could have any
Expand Down Expand Up @@ -391,9 +394,6 @@ XYDelaunayGenerator::generate()
auto hole_boundaries = getParam<std::vector<BoundaryName>>("hole_boundaries");
auto hole_boundary_ids = MooseMeshUtils::getBoundaryIDs(*mesh, hole_boundaries, true);

if (hole_boundary_ids.size() != hole_ptrs.size())
paramError("hole_boundary_ids", "Need one hole_boundary_ids entry per hole, if specified.");

for (auto h : index_range(hole_ptrs))
libMesh::MeshTools::Modification::change_boundary_id(
*mesh, h + 1 + free_boundary_id, h + 1 + free_boundary_id + end_bcid);
Expand Down Expand Up @@ -547,6 +547,6 @@ XYDelaunayGenerator::generate()
if (main_subdomain_map.size() != main_subdomain_map_name_list.size())
paramError("holes", "The hole meshes contain subdomain name maps with conflicts.");

mesh->prepare_for_use();
mesh->set_isnt_prepared();
return mesh;
}
Loading

0 comments on commit bd14992

Please sign in to comment.