19 #include "libmesh/mesh_base.h" 20 #include "libmesh/parameters.h" 26 class DistributedMesh;
69 virtual std::unique_ptr<MeshBase>
generate() = 0;
202 template <
typename T,
typename... Args>
205 template <
typename T>
208 return declareMeshProperty<T, const T &>(data_name, data_value);
217 template <
typename T,
typename... Args>
220 template <
typename T>
223 return setMeshProperty<T, const T &>(data_name, data_value);
232 template <
typename T>
234 const std::string & source_data_name,
235 const std::string & source_mesh)
237 return declareMeshProperty(target_data_name, getMeshProperty<T>(source_data_name, source_mesh));
245 template <
typename T>
246 T &
copyMeshProperty(
const std::string & source_data_name,
const std::string & source_mesh)
248 return copyMeshProperty<T>(source_data_name, source_data_name, source_mesh);
265 [[nodiscard]] std::unique_ptr<MeshBase> &
getMesh(
const std::string & param_name,
266 const bool allow_invalid =
false);
272 [[nodiscard]] std::vector<std::unique_ptr<MeshBase> *>
getMeshes(
const std::string & param_name);
280 [[nodiscard]] std::unique_ptr<MeshBase> &
281 getMeshByName(
const MeshGeneratorName & mesh_generator_name);
287 [[nodiscard]] std::vector<std::unique_ptr<MeshBase> *>
288 getMeshesByName(
const std::vector<MeshGeneratorName> & mesh_generator_names);
321 [[nodiscard]] std::unique_ptr<MeshBase>
330 [[nodiscard]] std::unique_ptr<ReplicatedMesh>
340 [[nodiscard]] std::unique_ptr<DistributedMesh>
361 template <
typename... Ts>
363 const std::string &
name,
364 Ts... extra_input_parameters);
405 void checkGetMesh(
const MeshGeneratorName & mesh_generator_name,
406 const std::string & param_name)
const;
412 const bool allow_invalid)
const;
416 const std::vector<MeshGeneratorName> &
453 template <
typename T,
typename... Args>
458 mooseError(
"Can only call declareMeshProperty() during MeshGenerator construction");
465 MooseUtils::prettyCppType<T>(),
466 "',\nsaid property has already been declared with type '",
472 std::make_unique<RestartableData<T>>(full_name,
nullptr, std::forward<Args>(args)...);
475 mooseAssert(
value->declared(),
"Should be declared");
478 mooseAssert(T_value,
"Bad cast");
480 return T_value->set();
483 template <
typename T,
typename... Args>
488 mooseError(
"Updating mesh meta data with setMeshProperty() can only be called during " 489 "MeshGenerator::generate()");
492 mooseError(
"Failed to get the mesh property '", data_name,
"'");
496 mooseError(
"While retrieving mesh property '",
499 MooseUtils::prettyCppType<T>(),
500 "',\nthe property was found with type '",
505 if constexpr (
sizeof...(args) > 0)
506 T_value->
set() = T(std::forward<Args>(args)...);
508 return T_value->
set();
511 template <
typename... Ts>
514 const std::string & name,
515 Ts... extra_input_parameters)
519 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
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.
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
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
virtual const std::string & name() const
Get the name of the class.
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::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::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...
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.
const InputParameters & _pars
Parameters of this object, references the InputParameters stored in the InputParametersWarehouse.
static void setHasGenerateData(InputParameters ¶ms)
Sets that a mesh generator has a generateData() implementation.
const InputParameters & parameters() const
Get the parameters of the object.
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< 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 &)
const std::set< MeshGeneratorName > & getRequestedMeshGenerators() const