20 #include "libmesh/mesh_base.h" 21 #include "libmesh/parameters.h" 27 class DistributedMesh;
83 virtual std::unique_ptr<MeshBase>
generate() = 0;
226 virtual std::unique_ptr<CSG::CSGBase>
generateCSG();
232 template <
typename T,
typename... Args>
235 template <
typename T>
238 return declareMeshProperty<T, const T &>(data_name, data_value);
247 template <
typename T,
typename... Args>
250 template <
typename T>
253 return setMeshProperty<T, const T &>(data_name, data_value);
262 template <
typename T>
264 const std::string & source_data_name,
265 const std::string & source_mesh)
267 return declareMeshProperty(target_data_name, getMeshProperty<T>(source_data_name, source_mesh));
275 template <
typename T>
276 T &
copyMeshProperty(
const std::string & source_data_name,
const std::string & source_mesh)
278 return copyMeshProperty<T>(source_data_name, source_data_name, source_mesh);
295 [[nodiscard]] std::unique_ptr<MeshBase> &
getMesh(
const std::string & param_name,
296 const bool allow_invalid =
false);
302 [[nodiscard]] std::vector<std::unique_ptr<MeshBase> *>
getMeshes(
const std::string & param_name);
310 [[nodiscard]] std::unique_ptr<MeshBase> &
311 getMeshByName(
const MeshGeneratorName & mesh_generator_name);
317 [[nodiscard]] std::vector<std::unique_ptr<MeshBase> *>
318 getMeshesByName(
const std::vector<MeshGeneratorName> & mesh_generator_names);
329 [[nodiscard]] std::unique_ptr<CSG::CSGBase> &
getCSGBase(
const std::string & param_name);
339 [[nodiscard]] std::unique_ptr<CSG::CSGBase> &
350 [[nodiscard]] std::vector<std::unique_ptr<CSG::CSGBase> *>
361 [[nodiscard]] std::vector<std::unique_ptr<CSG::CSGBase> *>
395 [[nodiscard]] std::unique_ptr<MeshBase>
404 [[nodiscard]] std::unique_ptr<ReplicatedMesh>
414 [[nodiscard]] std::unique_ptr<DistributedMesh>
435 template <
typename... Ts>
437 const std::string &
name,
438 Ts... extra_input_parameters);
479 void checkGetMesh(
const MeshGeneratorName & mesh_generator_name,
480 const std::string & param_name)
const;
486 const bool allow_invalid)
const;
490 const std::vector<MeshGeneratorName> &
530 template <
typename T,
typename... Args>
535 mooseError(
"Can only call declareMeshProperty() during MeshGenerator construction");
542 MooseUtils::prettyCppType<T>(),
543 "',\nsaid property has already been declared with type '",
549 std::make_unique<RestartableData<T>>(full_name,
nullptr, std::forward<Args>(args)...);
552 mooseAssert(
value->declared(),
"Should be declared");
555 mooseAssert(T_value,
"Bad cast");
557 return T_value->set();
560 template <
typename T,
typename... Args>
565 mooseError(
"Updating mesh meta data with setMeshProperty() can only be called during " 566 "MeshGenerator::generate()");
569 mooseError(
"Failed to get the mesh property '", data_name,
"'");
573 mooseError(
"While retrieving mesh property '",
576 MooseUtils::prettyCppType<T>(),
577 "',\nthe property was found with type '",
582 if constexpr (
sizeof...(args) > 0)
583 T_value->
set() = T(std::forward<Args>(args)...);
585 return T_value->
set();
588 template <
typename... Ts>
591 const std::string & name,
592 Ts... extra_input_parameters)
596 subgenerator_params.
setParameters(extra_input_parameters...);
virtual bool constructingMeshGenerators() const
Whether this app is constructing mesh generators.
std::unique_ptr< DistributedMesh > buildDistributedMesh(unsigned int dim=libMesh::invalid_uint)
Build a distributed mesh that has correct remote element removal behavior and geometric ghosting func...
std::unique_ptr< MeshBase > & getMeshByName(const MeshGeneratorName &mesh_generator_name)
Like getMesh(), but takes the name of another MeshGenerator directly.
std::set< std::string > _null_mesh_names
The declared "null" mesh names that will not represent a mesh in input; see declareNullMeshName() ...
RestartableDataValue & setMeshPropertyHelper(const std::string &data_name)
Helper for getting a writable reference to a mesh property, used in declareMeshProperty and setMeshPr...
static const std::string data_only_param
The name of the private parameter for setting data only.
bool isChildMeshGenerator(const MeshGeneratorName &name, const bool direct=true) const
const InputParameters & _pars
The object's parameters.
T & setMeshProperty(const std::string &data_name, Args &&... args)
Method for updating attributes to the mesh meta-data store, which can only be invoked in the MeshGene...
const unsigned int invalid_uint
T & copyMeshProperty(const std::string &source_data_name, const std::string &source_mesh)
Method for copying attribute from input mesh meta-data store to current mesh meta-data store...
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh(unsigned int dim=libMesh::invalid_uint)
Build a replicated mesh.
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBases(const std::string ¶m_name)
Like getCSGBase(), but for multiple generators.
Comparator for MeshGenerators that sorts by name.
const bool _data_only
Whether or not this mesh generator will run in data only mode.
const std::string & _save_with_name
A user-defined name to save the mesh.
bool hasSaveMesh() const
Return whether or not to save the current mesh.
static const RestartableDataMapName MESH_META_DATA
const InputParameters & parameters() const
Get the parameters of the object.
virtual void generateData()
Generate the mesh data.
InputParameters getValidParams(const std::string &name) const
Get valid parameters for the object.
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
const std::set< const MeshGenerator *, Comparator > & getChildMeshGenerators() const
Gets the MeshGenerators that are children to this MeshGenerator.
std::unique_ptr< MeshBase > _null_mesh
A nullptr to use for when inputs aren't specified.
T & setMeshProperty(const std::string &data_name, const T &data_value)
MeshGenerator(const InputParameters ¶meters)
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
bool hasGenerateData() const
std::set< const MeshGenerator *, Comparator > _child_mesh_generators
The MeshGenerators that are children to this MeshGenerator.
Factory & getFactory()
Retrieve a writable reference to the Factory associated with this App.
bool isNullMeshName(const MeshGeneratorName &name) const
MooseMesh *const _mesh
Pointer to the owning mesh.
void addChildMeshGenerator(const MeshGenerator &mg, const AddParentChildKey)
Adds the MeshGenerator mg as a child.
void declareMeshForSub(const std::string ¶m_name)
Declares that a MeshGenerator referenced in the InputParameters is to be used as a dependency of a su...
std::vector< std::pair< std::string, std::unique_ptr< MeshBase > * > > _requested_meshes
The meshes that were requested by this MeshGenerator; used to verify that any input meshes that are r...
void addParentMeshGenerator(const MeshGenerator &mg, const AddParentChildKey)
Adds the MeshGenerator mg as a parent.
bool isParentMeshGenerator(const MeshGeneratorName &name, const bool direct=true) const
const std::string & name() const
Get the name of the class.
const std::set< MeshGeneratorName > & getRequestedMeshGeneratorsForSub() const
Real value(unsigned n, unsigned alpha, unsigned beta, Real x)
void addMeshSubgenerator(const std::string &type, const std::string &name, Ts... extra_input_parameters)
Construct a "subgenerator", a different MeshGenerator subclass that will be added to the same MooseAp...
Every object that can be built by the factory should be derived from this class.
virtual std::string meshPropertyPrefix(const std::string &) const override final
Override of the default prefix to use when getting mesh properties.
void declareMeshesForSubByName(const std::vector< MeshGeneratorName > &mesh_generator_names)
Like declareMeshForSubByName(), but for multiple generators.
RestartableDataValue & registerRestartableData(std::unique_ptr< RestartableDataValue > data, THREAD_ID tid, bool read_only, const RestartableDataMapName &metaname="")
std::set< MeshGeneratorName > _requested_mesh_generators_for_sub
The names of the MeshGenerators that were requested in the declareMeshForSub methods.
std::unique_ptr< MeshBase > & getMesh(const std::string ¶m_name, const bool allow_invalid=false)
Takes the name of a MeshGeneratorName parameter and then gets a pointer to the Mesh that MeshGenerato...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
virtual std::unique_ptr< MeshBase > generate()=0
Generate / modify the mesh.
const std::string & type() const
Get the type of this class.
std::set< MeshGeneratorName > _requested_mesh_generators
The names of the MeshGenerators that were requested in the getMesh methods.
ActionWarehouse & actionWarehouse()
Return a writable reference to the ActionWarehouse associated with this app.
std::vector< std::unique_ptr< MeshBase > * > getMeshesByName(const std::vector< MeshGeneratorName > &mesh_generator_names)
Like getMeshByName(), but for multiple generators.
std::vector< std::pair< std::string, std::unique_ptr< CSG::CSGBase > * > > _requested_csg_bases
The CSGBase objects that were requested by this MeshGenerator; used to verify that any input meshes t...
std::vector< std::unique_ptr< MeshBase > * > getMeshes(const std::string ¶m_name)
Like getMesh(), but for multiple generators.
MooseApp & _app
The MOOSE application this is associated with.
static InputParameters validParams()
std::unique_ptr< MeshBase > generateInternal()
Internal generation method - this is what is actually called within MooseApp to execute the MeshGener...
static void setHasGenerateCSG(InputParameters ¶ms)
Sets that a mesh generator has a generateCSG() implementation.
bool hasGenerateCSG() const
virtual std::string type() const =0
String identifying the type of parameter stored.
const std::string & getCurrentTaskName() const
std::set< const MeshGenerator *, Comparator > _sub_mesh_generators
The sub MeshGenerators constructed by this MeshGenerator.
const std::set< const MeshGenerator *, Comparator > & getSubMeshGenerators() const
Gets the MeshGenerators that are children to this MeshGenerator.
Concrete definition of a parameter value for a specified type.
Class that is used as a parameter to add[Parent/Child]() that allows only MeshGeneratorSystem methods...
const std::set< const MeshGenerator *, Comparator > & getParentMeshGenerators() const
Gets the MeshGenerators that are parents to this MeshGenerator.
void checkGetMesh(const MeshGeneratorName &mesh_generator_name, const std::string ¶m_name) const
Helper for performing error checking in the getMesh methods.
std::set< const MeshGenerator *, Comparator > _parent_mesh_generators
The MeshGenerators that are parents to this MeshGenerator.
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
std::unique_ptr< CSG::CSGBase > & getCSGBaseByName(const MeshGeneratorName &mesh_generator_name)
Like getCSGBase(), but takes the name of another MeshGenerator directly.
std::unique_ptr< CSG::CSGBase > & getCSGBase(const std::string ¶m_name)
Takes the name of a MeshGeneratorName parameter and then gets a pointer to the CSGBase object that Me...
static void setHasGenerateData(InputParameters ¶ms)
Sets that a mesh generator has a generateData() implementation.
T & declareMeshProperty(const std::string &data_name, Args &&... args)
Methods for writing out attributes to the mesh meta-data store, which can be retrieved from most othe...
T & declareMeshProperty(const std::string &data_name, const T &data_value)
System that manages MeshGenerators.
std::unique_ptr< CSG::CSGBase > generateInternalCSG()
Internal generation method for CSG object generation.
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
Build a MeshBase object whose underlying type will be determined by the Mesh input file block...
bool operator()(const MeshGenerator *const &a, const MeshGenerator *const &b) const
void declareMeshesForSub(const std::string ¶m_name)
Like declareMeshForSub(), but for multiple generators.
void declareNullMeshName(const MeshGeneratorName &name)
Registers the name name as a "null" mesh, which is a MeshGenerator used in InputParameters that will ...
T & copyMeshProperty(const std::string &target_data_name, const std::string &source_data_name, const std::string &source_mesh)
Method for copying attribute from input mesh meta-data store to current mesh meta-data store...
const std::string & getSavedMeshName() const
Return the name of the saved mesh.
void declareMeshForSubByName(const MeshGeneratorName &mesh_generator_name)
Like declareMeshForSub(), but takes the name of another MeshGenerator directly.
MeshGenerators are objects that can modify or add to an existing mesh.
const std::vector< MeshGeneratorName > & getMeshGeneratorNamesFromParam(const std::string ¶m_name) const
Helper for getting a std::vector<MeshGeneratorName> parameter.
Abstract definition of a RestartableData value.
const MeshGeneratorName * getMeshGeneratorNameFromParam(const std::string ¶m_name, const bool allow_invalid) const
Helper for getting a MeshGeneratorName parameter.
AddParentChildKey(const AddParentChildKey &)
virtual std::unique_ptr< CSG::CSGBase > generateCSG()
Generate the CSG representation of the mesh (or meshing operation) created by this mesh generator...
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBasesByName(const std::vector< MeshGeneratorName > &mesh_generator_names)
Like getCSGBaseByName(), but for multiple generators.
const std::set< MeshGeneratorName > & getRequestedMeshGenerators() const