System that manages MeshGenerators. More...
#include <MeshGeneratorSystem.h>
Public Member Functions | |
MeshGeneratorSystem (MooseApp &app) | |
void | executeMeshGenerators () |
Execute and clear the Mesh Generators data structure. More... | |
void | addMeshGenerator (const std::string &type, const std::string &name, const InputParameters ¶ms) |
Add a mesh generator that will act on the meshes in the system. More... | |
const MeshGenerator & | appendMeshGenerator (const std::string &type, const std::string &name, InputParameters params) |
Append a mesh generator that will act on the current final mesh generator in the system. More... | |
std::unique_ptr< libMesh::MeshBase > & | getMeshGeneratorOutput (const MeshGeneratorName &name) |
Get a reference to a pointer that will be the output of the MeshGenerator named name. More... | |
void | createAddedMeshGenerators () |
Creates (constructs) all of the MeshGenerators that have been declared using addMeshGenerator(). More... | |
std::vector< std::string > | getMeshGeneratorNames () const |
Get names of all mesh generators Note: This function should be called after all mesh generators are added with the 'add_mesh_generator' task. More... | |
std::unique_ptr< libMesh::MeshBase > | getSavedMesh (const std::string &name) |
Get the saved mesh by name. More... | |
std::vector< std::string > | getSavedMeshNames () const |
Get all user-defined saved meshes except main and main_displaced. More... | |
bool | hasMeshGenerator (const MeshGeneratorName &name) const |
const MeshGenerator & | getMeshGenerator (const std::string &name) const |
bool | hasMeshGeneratorParams (const MeshGeneratorName &name) const |
Whether or not we know about the parameters for a MeshGenerator with the given name. More... | |
bool | appendingMeshGenerators () const |
Whether or not mesh generators are currently being appended (append_mesh_generator task) More... | |
bool | hasBreakMeshByBlockGenerator () const |
bool | hasDataDrivenAllowed () const |
void | dataDrivenError (const MeshGenerator &generator, const std::string &message) const |
Reports an error with the context of the data driven parameter, coming from the generator generator with message message . More... | |
MeshGeneratorName | getFinalMeshGeneratorName () const |
Get the name of the final mesh generator. More... | |
void | setVerbose (const bool verbose) |
Set the verbose flag. More... | |
PerfGraph & | perfGraph () |
Get the PerfGraph. More... | |
const Parallel::Communicator & | comm () const |
processor_id_type | n_processors () const |
processor_id_type | processor_id () const |
Static Public Member Functions | |
static std::string | mainMeshGeneratorName () |
The name reserved for the "main" mesh generator which is the one used for the numerical solver downstream. More... | |
static InputParameters | validParams () |
Static Public Attributes | |
static const std::string | data_driven_generator_param = "data_driven_generator" |
The name of the string parameter that sets the data driven generator. More... | |
static const std::string | allow_data_driven_param |
The name of the boolean parameter on the MooseApp that will enable data driven generation. More... | |
Protected Member Functions | |
PerfID | registerTimedSection (const std::string §ion_name, const unsigned int level) const |
Call to register a named section for timing. More... | |
PerfID | registerTimedSection (const std::string §ion_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const |
Call to register a named section for timing. More... | |
std::string | timedSectionName (const std::string §ion_name) const |
Protected Attributes | |
MooseApp & | _pg_moose_app |
The MooseApp that owns the PerfGraph. More... | |
const std::string | _prefix |
A prefix to use for all sections. More... | |
const Parallel::Communicator & | _communicator |
Private Member Functions | |
std::vector< std::pair< std::string, MeshGeneratorName > > | getMeshGeneratorParamDependencies (const InputParameters ¶ms, const bool allow_empty=false) const |
Gets the MeshGeneratorNames that are referenced in an object's parameters. More... | |
void | createMeshGeneratorOrder () |
Order all of the _mesh_generators into _ordered_mesh_generators for later execution in executeMeshGenerators. More... | |
std::shared_ptr< MeshGenerator > | createMeshGenerator (const std::string &name) |
Internal method for actually constructing a mesh generator after it has been declared externally in addMeshGenerator (in Actions). More... | |
MeshGenerator & | getMeshGeneratorInternal (const std::string &name) |
Get a MeshGenerator with the name name . More... | |
const std::string & | getDataDrivenGeneratorName () const |
Private Attributes | |
MooseApp & | _app |
The MooseApp that owns this system. More... | |
std::unordered_map< std::string, std::pair< std::string, InputParameters > > | _mesh_generator_params |
The MeshGenerators declared using addMeshGenerator(), cleared after createMeshGenerators() Key is the name, pair contains the type and the params. More... | |
std::map< std::string, std::shared_ptr< MeshGenerator > > | _mesh_generators |
Owning storage for mesh generators, map of name -> MeshGenerator. More... | |
std::vector< std::vector< MeshGenerator * > > | _ordered_mesh_generators |
Holds the ordered mesh generators from createMeshGeneratorOrder() until they are executed in executeMeshGenerators() More... | |
std::map< std::string, std::list< std::unique_ptr< libMesh::MeshBase > > > | _mesh_generator_outputs |
Holds the output for each mesh generator - including duplicates needed downstream. More... | |
std::string | _final_generator_name |
The final mesh generator name to use. More... | |
std::map< std::string, std::unique_ptr< libMesh::MeshBase > > | _save_in_meshes |
Holds the map of save in mesh -> name. More... | |
std::optional< std::string > | _data_driven_generator_name |
The name of the data driven generator, if any. More... | |
bool | _has_bmbb |
Whether any of the mesh generators are a BreakMeshByBlockGenerator . More... | |
bool | _verbose |
Whether to print the names of the mesh generators being executed or not. More... | |
System that manages MeshGenerators.
To be owned by the MooseApp.
Definition at line 27 of file MeshGeneratorSystem.h.
MeshGeneratorSystem::MeshGeneratorSystem | ( | MooseApp & | app | ) |
Definition at line 24 of file MeshGeneratorSystem.C.
void MeshGeneratorSystem::addMeshGenerator | ( | const std::string & | type, |
const std::string & | name, | ||
const InputParameters & | params | ||
) |
Add a mesh generator that will act on the meshes in the system.
type | The type of MeshGenerator |
name | The name of the MeshGenerator |
params | The params used to construct the MeshGenerator |
Internally, this will store the parameters for future construction during the "add_mesh_generator" task. When called during the "create_mesh_generator" task (i.e., when creating mesh subgenerators), it will also construct the generator.
We don't construct them yet because we want to create them in order during createMeshGenerators() as much as possible so that we don't need lazy construction for things like mesh properties.
Definition at line 34 of file MeshGeneratorSystem.C.
Referenced by CombineComponentsMeshes::act(), MooseApp::addMeshGenerator(), ComponentMeshTransformHelper::addMeshGenerators(), CylinderComponent::addMeshGenerators(), and BatchMeshGeneratorAction::addMeshGenerators().
bool MeshGeneratorSystem::appendingMeshGenerators | ( | ) | const |
Whether or not mesh generators are currently being appended (append_mesh_generator task)
Definition at line 639 of file MeshGeneratorSystem.C.
Referenced by appendMeshGenerator(), and MooseApp::constructingMeshGenerators().
const MeshGenerator & MeshGeneratorSystem::appendMeshGenerator | ( | const std::string & | type, |
const std::string & | name, | ||
InputParameters | params | ||
) |
Append a mesh generator that will act on the current final mesh generator in the system.
type | The type of MeshGenerator |
name | The name of the MeshGenerator |
params | The params used to construct the MeshGenerator |
This MeshGenerator must have a parameter "input" of type MeshGeneratorName for this to work, as said parameter is set to the current final generator
Note: This function must be called during the append_mesh_generator task.
Definition at line 52 of file MeshGeneratorSystem.C.
Referenced by CombineComponentsMeshes::act(), and MooseApp::appendMeshGenerator().
void MeshGeneratorSystem::createAddedMeshGenerators | ( | ) |
Creates (constructs) all of the MeshGenerators that have been declared using addMeshGenerator().
This parses the input parameters of type <MeshGenerator> and std::vector<MeshGeneratorName> to build the execution tree for the generators, and constructs them in dependency order
Sub generators are also generated within this phase, although the dependency resolution described above is only for the dependencies that we can parse using InputParameters. However, we require that sub generators be constructed within their dependency order (except for the last one, which may be coupled to via the generator creating said sub generator).
Should only be called by the CreateAddedMeshGenerator action during the create_added_mesh_generators task.
Definition at line 136 of file MeshGeneratorSystem.C.
Referenced by CreateAddedMeshGenerators::act().
|
private |
Internal method for actually constructing a mesh generator after it has been declared externally in addMeshGenerator (in Actions).
Definition at line 461 of file MeshGeneratorSystem.C.
Referenced by addMeshGenerator(), appendMeshGenerator(), and createAddedMeshGenerators().
|
private |
Order all of the _mesh_generators into _ordered_mesh_generators for later execution in executeMeshGenerators.
Definition at line 237 of file MeshGeneratorSystem.C.
Referenced by appendMeshGenerator(), and executeMeshGenerators().
void MeshGeneratorSystem::dataDrivenError | ( | const MeshGenerator & | generator, |
const std::string & | message | ||
) | const |
Reports an error with the context of the data driven parameter, coming from the generator generator
with message message
.
Should be used to throw errors from within a MeshGenerator with more context.
Definition at line 658 of file MeshGeneratorSystem.C.
Referenced by MeshGenerator::MeshGenerator().
void MeshGeneratorSystem::executeMeshGenerators | ( | ) |
Execute and clear the Mesh Generators data structure.
Definition at line 372 of file MeshGeneratorSystem.C.
Referenced by ExecuteMeshGenerators::act().
|
private |
Definition at line 651 of file MeshGeneratorSystem.C.
Referenced by createAddedMeshGenerators(), and dataDrivenError().
|
inline |
Get the name of the final mesh generator.
Definition at line 173 of file MeshGeneratorSystem.h.
Referenced by CombineComponentsMeshes::act().
const MeshGenerator & MeshGeneratorSystem::getMeshGenerator | ( | const std::string & | name | ) | const |
name
. Definition at line 595 of file MeshGeneratorSystem.C.
Referenced by createAddedMeshGenerators(), and MooseApp::getMeshGenerator().
|
inlineprivate |
Get a MeshGenerator with the name name
.
We add the "internal" here so that we allow objects that have non-const access to MooseApp to call getMeshGenerator without a const_cast. If the name was the same, you'd get an error about trying to access a private method.
Definition at line 210 of file MeshGeneratorSystem.h.
Referenced by createMeshGenerator(), and createMeshGeneratorOrder().
std::vector< std::string > MeshGeneratorSystem::getMeshGeneratorNames | ( | ) | const |
Get names of all mesh generators Note: This function should be called after all mesh generators are added with the 'add_mesh_generator' task.
The returned value will be undefined and depends on the ordering that mesh generators are added by MOOSE if the function is called during the 'add_mesh_generator' task.
Definition at line 605 of file MeshGeneratorSystem.C.
Referenced by CombineComponentsMeshes::act(), and MooseApp::getMeshGeneratorNames().
std::unique_ptr< MeshBase > & MeshGeneratorSystem::getMeshGeneratorOutput | ( | const MeshGeneratorName & | name | ) |
Get a reference to a pointer that will be the output of the MeshGenerator named name.
Definition at line 570 of file MeshGeneratorSystem.C.
Referenced by executeMeshGenerators(), and MeshGenerator::getMeshByName().
|
private |
Gets the MeshGeneratorNames that are referenced in an object's parameters.
The result is returned as a pair of param name -> MeshGeneratorName in order to provide context.
The allow_empty
param sets whether or not to report names that are empty.
Definition at line 106 of file MeshGeneratorSystem.C.
Referenced by appendMeshGenerator(), createAddedMeshGenerators(), and createMeshGenerator().
std::unique_ptr< MeshBase > MeshGeneratorSystem::getSavedMesh | ( | const std::string & | name | ) |
Get the saved mesh by name.
Definition at line 623 of file MeshGeneratorSystem.C.
Referenced by SetupMeshAction::act(), MooseApp::getMeshGeneratorMesh(), and MeshGeneratorComponent::setupComponent().
std::vector< std::string > MeshGeneratorSystem::getSavedMeshNames | ( | ) | const |
Get all user-defined saved meshes except main and main_displaced.
Definition at line 614 of file MeshGeneratorSystem.C.
|
inline |
BreakMeshByBlockGenerator
Definition at line 157 of file MeshGeneratorSystem.h.
Referenced by ExtraNodesetGenerator::generate(), and SideSetsFromNormalsGenerator::generate().
bool MeshGeneratorSystem::hasDataDrivenAllowed | ( | ) | const |
Definition at line 645 of file MeshGeneratorSystem.C.
Referenced by createAddedMeshGenerators().
bool MeshGeneratorSystem::hasMeshGenerator | ( | const MeshGeneratorName & | name | ) | const |
name
. Definition at line 583 of file MeshGeneratorSystem.C.
Referenced by appendMeshGenerator(), createAddedMeshGenerators(), createMeshGenerator(), createMeshGeneratorOrder(), and MooseApp::hasMeshGenerator().
bool MeshGeneratorSystem::hasMeshGeneratorParams | ( | const MeshGeneratorName & | name | ) | const |
Whether or not we know about the parameters for a MeshGenerator with the given name.
This is primarily for error checking. If MeshGenerator dependencies are screwed up, someone could be looking for a MeshGenerator that hasn't been constructed yet. With this, at least we can give the user some context that we know the generator exists, just that the dependencies are hosed.
Definition at line 589 of file MeshGeneratorSystem.C.
|
inlinestatic |
The name reserved for the "main" mesh generator which is the one used for the numerical solver downstream.
Definition at line 152 of file MeshGeneratorSystem.h.
Referenced by executeMeshGenerators(), and MooseApp::getMeshGeneratorMesh().
|
inherited |
Get the PerfGraph.
Definition at line 78 of file PerfGraphInterface.C.
Referenced by CommonOutputAction::act(), PerfGraphData::finalize(), and PerfGraphOutput::output().
|
protectedinherited |
Call to register a named section for timing.
section_name | The name of the code section to be timed |
level | The importance of the timer - lower is more important (0 will always come out) |
Definition at line 53 of file PerfGraphInterface.C.
|
protectedinherited |
Call to register a named section for timing.
section_name | The name of the code section to be timed |
level | The importance of the timer - lower is more important (0 will always come out) |
live_message | The message to be printed to the screen during execution |
print_dots | Whether or not progress dots should be printed for this section |
Definition at line 64 of file PerfGraphInterface.C.
|
inline |
Set the verbose flag.
Definition at line 176 of file MeshGeneratorSystem.h.
Referenced by SetupDebugAction::SetupDebugAction().
|
protectedinherited |
section_name
.Optionally adds a prefix if one is defined.
Definition at line 47 of file PerfGraphInterface.C.
Referenced by PerfGraphInterface::registerTimedSection().
|
staticinherited |
Definition at line 16 of file PerfGraphInterface.C.
Referenced by Convergence::validParams().
|
private |
The MooseApp that owns this system.
Definition at line 221 of file MeshGeneratorSystem.h.
Referenced by addMeshGenerator(), appendingMeshGenerators(), createAddedMeshGenerators(), createMeshGenerator(), createMeshGeneratorOrder(), dataDrivenError(), executeMeshGenerators(), getMeshGeneratorOutput(), and hasDataDrivenAllowed().
|
private |
The name of the data driven generator, if any.
Definition at line 243 of file MeshGeneratorSystem.h.
Referenced by createAddedMeshGenerators(), and getDataDrivenGeneratorName().
|
private |
The final mesh generator name to use.
Definition at line 237 of file MeshGeneratorSystem.h.
Referenced by appendMeshGenerator(), createAddedMeshGenerators(), createMeshGeneratorOrder(), executeMeshGenerators(), and getFinalMeshGeneratorName().
|
private |
Whether any of the mesh generators are a BreakMeshByBlockGenerator
.
Definition at line 246 of file MeshGeneratorSystem.h.
Referenced by addMeshGenerator(), executeMeshGenerators(), and hasBreakMeshByBlockGenerator().
|
private |
Holds the output for each mesh generator - including duplicates needed downstream.
Definition at line 234 of file MeshGeneratorSystem.h.
Referenced by createMeshGenerator(), executeMeshGenerators(), and getMeshGeneratorOutput().
|
private |
The MeshGenerators declared using addMeshGenerator(), cleared after createMeshGenerators() Key is the name, pair contains the type and the params.
Definition at line 225 of file MeshGeneratorSystem.h.
Referenced by addMeshGenerator(), appendMeshGenerator(), createAddedMeshGenerators(), createMeshGenerator(), and hasMeshGeneratorParams().
|
private |
Owning storage for mesh generators, map of name -> MeshGenerator.
Definition at line 228 of file MeshGeneratorSystem.h.
Referenced by appendMeshGenerator(), createMeshGenerator(), createMeshGeneratorOrder(), executeMeshGenerators(), getMeshGenerator(), getMeshGeneratorNames(), and hasMeshGenerator().
|
private |
Holds the ordered mesh generators from createMeshGeneratorOrder() until they are executed in executeMeshGenerators()
Definition at line 231 of file MeshGeneratorSystem.h.
Referenced by appendMeshGenerator(), createMeshGeneratorOrder(), and executeMeshGenerators().
|
protectedinherited |
The MooseApp that owns the PerfGraph.
Definition at line 124 of file PerfGraphInterface.h.
Referenced by PerfGraphInterface::perfGraph().
|
protectedinherited |
A prefix to use for all sections.
Definition at line 127 of file PerfGraphInterface.h.
Referenced by PerfGraphInterface::timedSectionName().
|
private |
Holds the map of save in mesh -> name.
Definition at line 240 of file MeshGeneratorSystem.h.
Referenced by createMeshGenerator(), executeMeshGenerators(), getSavedMesh(), and getSavedMeshNames().
|
private |
Whether to print the names of the mesh generators being executed or not.
Definition at line 249 of file MeshGeneratorSystem.h.
Referenced by executeMeshGenerators(), and setVerbose().
|
static |
The name of the boolean parameter on the MooseApp that will enable data driven generation.
Definition at line 35 of file MeshGeneratorSystem.h.
Referenced by createAddedMeshGenerators(), hasDataDrivenAllowed(), and MooseApp::validParams().
|
static |
The name of the string parameter that sets the data driven generator.
Definition at line 33 of file MeshGeneratorSystem.h.
Referenced by createAddedMeshGenerators(), dataDrivenError(), and MeshGeneratorMesh::validParams().