-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Implement generateCSG method for PinMeshGenerator #31782
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
base: next
Are you sure you want to change the base?
Changes from all commits
91b0fc5
a9d2d8c
c9a88ab
417d5f1
be4f91b
72abc59
1cce78b
3aaaecc
9336c3a
60f35e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -225,7 +225,17 @@ For all methods listed below, a unique pointer to the `CSGBase` object(s) create | |||||
| - `getCSGBaseByName`: get the `CSGBase` object given a `MeshGeneratorName` | ||||||
| - `getCSGBasesByName`: get all `CSGBase` objects given a list of `MeshGeneratorName`s | ||||||
|
|
||||||
| For example: | ||||||
| These functions should be called from the constructor of the MeshGenerator, so that the MeshGenerator system can properly define the dependency tree of all mesh generators in the input file. The returned CSGBase pointers can be stored in a member variable and updated in the `generateCSG()` method in order to make any changes to the CSGBase object. | ||||||
|
|
||||||
| For example, the following member variable stores the pointer to the CSGBase object that is generated by an input mesh geenerator: | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| !listing TestCSGAxialSurfaceMeshGenerator.h start=Holds the generated CSGBase object end=_build_csg include-end=true | ||||||
|
|
||||||
| This variable is initialized in the constructor as: | ||||||
|
|
||||||
| !listing TestCSGAxialSurfaceMeshGenerator.C start=getCSGBase end=getCSGBase include-end=true | ||||||
|
|
||||||
| Finally, in the `generateCSG()` method, `std::move` is called on the member variable to transfer ownership to the current mesh generator | ||||||
|
|
||||||
| !listing TestCSGAxialSurfaceMeshGenerator.C start=get the existing CSGBase end=csg_obj include-end=true | ||||||
|
|
||||||
|
|
@@ -306,4 +316,4 @@ To run the above example, use `--allow-test-objects`: | |||||
|
|
||||||
| ```shell | ||||||
| ./moose_test-opt --allow-test-objects --csg-only -i tests/csg/csg_only_chained.i | ||||||
| ``` | ||||||
| ``` | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -290,6 +290,6 @@ class MeshGeneratorSystem : public PerfGraphInterface, public libMesh::ParallelO | |||||
| /// Whether mesh generator system is running in CSG-only mode | ||||||
| bool _csg_only; | ||||||
|
|
||||||
| /// Holds the output CSGBase object for each mesh generator | ||||||
| std::map<std::string, std::unique_ptr<CSG::CSGBase>> _csg_base_output; | ||||||
| /// Holds the output CSGBase object for each mesh generator - including duplicates needed for downstream | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| std::map<std::string, std::list<std::unique_ptr<CSG::CSGBase>>> _csg_base_outputs; | ||||||
| }; | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -34,11 +34,19 @@ class CSGBase | |||||
| */ | ||||||
| CSGBase(); | ||||||
|
|
||||||
| /** | ||||||
| * Copy constructor | ||||||
| */ | ||||||
| CSGBase(const CSGBase & other_base); | ||||||
|
|
||||||
| /** | ||||||
| * Destructor | ||||||
| */ | ||||||
| ~CSGBase(); | ||||||
|
|
||||||
| /// Create a deep copy of this CSGBase instance | ||||||
| std::unique_ptr<CSGBase> clone() const { return std::make_unique<CSGBase>(*this); } | ||||||
|
|
||||||
| /** | ||||||
| * @brief add a unique surface pointer to this base instance | ||||||
| * | ||||||
|
|
@@ -335,21 +343,42 @@ class CSGBase | |||||
| std::vector<std::string> & linked_universe_names) const; | ||||||
|
|
||||||
| /** | ||||||
| * @brief Get the CSGSurfaceList object | ||||||
| * @brief Get a const reference to the CSGSurfaceList object | ||||||
| * | ||||||
| * @return CSGSurfaceList | ||||||
| */ | ||||||
| const CSGSurfaceList & getSurfaceList() const { return _surface_list; } | ||||||
|
|
||||||
| /** | ||||||
| * @brief Get a non-const reference to the CSGSurfaceList object | ||||||
| * | ||||||
| * @return CSGSurfaceList | ||||||
| */ | ||||||
| CSGSurfaceList & getSurfaceList() { return _surface_list; } | ||||||
|
|
||||||
| /** | ||||||
| * @brief Get the CSGCellList object | ||||||
| * @brief Get a const reference to the CSGCellList object | ||||||
| * | ||||||
| * @return CSGCellList | ||||||
| */ | ||||||
| const CSGCellList & getCellList() const { return _cell_list; } | ||||||
|
|
||||||
| /** | ||||||
| * @brief Get a non-const reference to the CSGCellList object | ||||||
| * | ||||||
| * @return CSGCellList | ||||||
| */ | ||||||
| CSGCellList & getCellList() { return _cell_list; } | ||||||
|
|
||||||
| /** | ||||||
| * @brief Get the CSGUniverseList object | ||||||
| * @brief Get a const reference to the CSGUniverseList object | ||||||
| * | ||||||
| * @return CSGUniverseList | ||||||
| */ | ||||||
| const CSGUniverseList & getUniverseList() const { return _universe_list; } | ||||||
|
|
||||||
| /** | ||||||
| * @brief Get a non-const reference to the CSGUniverseList object | ||||||
| * | ||||||
| * @return CSGUniverseList | ||||||
| */ | ||||||
|
|
@@ -412,6 +441,22 @@ class CSGBase | |||||
| // check that universe being accessed is a part of this CSGBase instance | ||||||
| bool checkUniverseInBase(const CSGUniverse & universe) const; | ||||||
|
|
||||||
| /** | ||||||
| * @brief Add a new cell to the cell list based on a cell reference. | ||||||
| * This method is called by the copy constructor of CSGBase | ||||||
| * | ||||||
| * @param cell reference to CSGCell that should be added to cell list | ||||||
| */ | ||||||
| const CSGCell & addCellToList(const CSGCell & cell); | ||||||
|
|
||||||
| /** | ||||||
| * @brief Add a new universe to the universe list based on a universe reference. | ||||||
| * This method is called by the copy constructor of CSGBase | ||||||
| * | ||||||
| * @param cell reference to CSGCell that should be added to universe list | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| */ | ||||||
| const CSGUniverse & addUniverseToList(const CSGUniverse & univ); | ||||||
|
|
||||||
| /// List of surfaces associated with CSG object | ||||||
| CSGSurfaceList _surface_list; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -67,9 +67,22 @@ class CSGPlane : public CSGSurface | |||||
| virtual Real evaluateSurfaceEquationAtPoint(const Point & p) const override; | ||||||
|
|
||||||
| protected: | ||||||
| /** | ||||||
| * @brief create clone of CSGPlane object | ||||||
| * | ||||||
| * @return std::unordered_map<CSGSurface> unique_ptr to cloned plane | ||||||
| */ | ||||||
| virtual std::unique_ptr<CSGSurface> clone() const override | ||||||
| { | ||||||
| return std::make_unique<CSGPlane>(_name, _a, _b, _c, _d); | ||||||
| } | ||||||
|
|
||||||
| // calculate the equivalent coeffients (aX + bY + cZ = d) from 3 points on a plane | ||||||
| void coeffsFromPoints(const Point & p1, const Point & p2, const Point & p3); | ||||||
|
|
||||||
| // Normalize plane coefficients so that a^2 + b^2 + c^2 = 1 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
// is for comments, /// is for docstring |
||||||
| void normalizePlaneCoefficients(); | ||||||
|
|
||||||
| /// Value of a in equation of plane | ||||||
| Real _a; | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,28 @@ | ||||||
| //* This file is part of the MOOSE framework | ||||||
| //* https://mooseframework.inl.gov | ||||||
| //* | ||||||
| //* 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 "CSGBase.h" | ||||||
|
|
||||||
| namespace CSGUtils | ||||||
| { | ||||||
|
|
||||||
| /** | ||||||
| * Get inner region of given surfaces, defined as the intersection | ||||||
| * of halfspaces of each surface. Here, the halfspace direction is determined based on the origin. | ||||||
| * @param radial_surfaces List of references to surfaces used to define inner region. This should | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
in this context, may not be radial |
||||||
| * be defined with the minimum number of surfaces to enclose the region | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * @param origin Point used to determine halfspace direction when defining intersected region | ||||||
| * @return inner region defined by surfaces | ||||||
| */ | ||||||
| CSG::CSGRegion | ||||||
| getInnerRegion(const std::vector<std::reference_wrapper<const CSG::CSGSurface>> & radial_surfaces, | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| const libMesh::Point & origin = Point(0, 0, 0)); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
defaults just lead to mistakes |
||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.