Skip to content

Commit

Permalink
Address Logan's review
Browse files Browse the repository at this point in the history
- Remove stitching from symmetry generator
- more constness
- use paramError over mooseError when possible
  • Loading branch information
GiudGiud committed Jan 12, 2023
1 parent eaad1af commit 48111e4
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 38 deletions.
Expand Up @@ -5,11 +5,6 @@
!alert note
Only the plane or mirror symmetry is currently implemented in the `SymmetryTransformGenerator`. Point or rotational symmetries are not implemented.

!alert warning
If using the [!param](/Mesh/SymmetryTransformGenerator/symmetry_stitch_sideset) parameter,
the name of the output mesh generator is not the name of the `SymmetryTransformGenerator`!
It is that name suffixed with `_stitchedMeshGenerator`.

## Overview

The `SymmetryTransformGenerator` makes a mirror reflection of a mesh across an arbitrary plane (or line in 2D) supplied by the user.
Expand Down
4 changes: 3 additions & 1 deletion framework/include/meshgenerators/MeshGenerator.h
Expand Up @@ -156,7 +156,9 @@ class MeshGenerator : public MooseObject, public MeshMetaDataInterface
/**
* Construct a "subgenerator", as above. User code is responsible
* for constructing valid InputParameters.
*
* @param generator_name the name of the class, also known as the type, of the subgenerator
* @param name the object name of the subgenerator
* @param params the input parameters for the subgenerator
* @return The Mesh generated by the new MeshGenerator subgenerator
*/
std::unique_ptr<MeshBase> & addMeshSubgenerator(const std::string & generator_name,
Expand Down
3 changes: 0 additions & 3 deletions framework/include/meshgenerators/SymmetryTransformGenerator.h
Expand Up @@ -32,7 +32,4 @@ class SymmetryTransformGenerator : public MeshGenerator

/// The normal of the mirror plane from which to transform the mesh
RealEigenVector _mirror_normal_vector;

/// The boundaries to stitch together
std::vector<std::vector<std::string>> _stitch_boundaries_pairs;
};
33 changes: 6 additions & 27 deletions framework/src/meshgenerators/SymmetryTransformGenerator.C
Expand Up @@ -28,31 +28,26 @@ SymmetryTransformGenerator::validParams()
"mirror_normal_vector",
"A vector normal to (perpendicular/orthogonal to) the plane/line over which the "
"reflection operation will be done");
params.addParam<std::vector<std::vector<std::string>>>(
"symmetry_stitch_sideset",
std::vector<std::vector<std::string>>(),
"Pairs of boundaries to be stitched together between the 1st mesh in inputs and each "
"consecutive mesh. This parameter will often be the name of the sideset on the symmetry axis"
". If not provided, the stitching is not performed.");

return params;
}

SymmetryTransformGenerator::SymmetryTransformGenerator(const InputParameters & parameters)
: MeshGenerator(parameters),
_input(getMesh("input")),
_mirror_point_vector(getParam<RealEigenVector>("mirror_point")),
_mirror_normal_vector(getParam<RealEigenVector>("mirror_normal_vector")),
_stitch_boundaries_pairs(
getParam<std::vector<std::vector<std::string>>>("symmetry_stitch_sideset"))
_mirror_normal_vector(getParam<RealEigenVector>("mirror_normal_vector"))
{
// enforce 3D coordinates
if (_mirror_point_vector.size() != 3)
mooseError("mirror_point should be a 3d vector, but only ",
paramError("mirror_point",
"mirror_point should be a 3d vector, but only ",
_mirror_point_vector.size(),
"components were specified.");

if (_mirror_normal_vector.size() != 3)
mooseError(" mirror_normal_vector should be a 3d vector, but only ",
paramError("mirror_point",
" mirror_normal_vector should be a 3d vector, but only ",
_mirror_normal_vector.size(),
"components were specified.");

Expand All @@ -61,22 +56,6 @@ SymmetryTransformGenerator::SymmetryTransformGenerator(const InputParameters & p
if (!MooseUtils::absoluteFuzzyEqual(norm, 1))
mooseInfo("Input normal plane vector was not normalized, normalization was performed");
_mirror_normal_vector = _mirror_normal_vector / norm;

// Add stitch sub mesh generator if stitching is requested
if (_stitch_boundaries_pairs.size() > 0)
{
auto params = _app.getFactory().getValidParams("StitchedMeshGenerator");

// order of vector elements matters for this generator
// here order by: original mesh first, our custom mesh second
params.set<std::vector<MeshGeneratorName>>("inputs") = {getParam<MeshGeneratorName>("input"),
name()};
params.set<std::vector<std::vector<std::string>>>("stitch_boundaries_pairs") =
_stitch_boundaries_pairs;

// stitch the mirrored mesh and the original mesh
addMeshSubgenerator("StitchedMeshGenerator", name() + "_stitchedMeshGenerator", params);
}
}

std::unique_ptr<MeshBase>
Expand Down
@@ -1,5 +1,4 @@
[Mesh]
# The stitching is performed by the SymmetryTransformGenerator
inactive = 'stitch'
[file]
type = GeneratedMeshGenerator
Expand Down
Expand Up @@ -4,7 +4,7 @@

[plane_symmetry]
type = 'Exodiff'
input = '.i'
input = 'simple.i'
exodiff = 'simple_in.e'
requirement = "The system shall include the ability to mirror a finite element mesh and stitch the mirrored mesh with the starting mesh."
cli_args = '--mesh-only'
Expand Down

0 comments on commit 48111e4

Please sign in to comment.