https://mooseframework.inl.gov
MeshGenerator.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "MeshGenerator.h"
11 #include "MooseMesh.h"
12 #include "MooseApp.h"
13 
14 #include "Exodus.h"
15 #include "Nemesis.h"
16 
17 #include "libmesh/exodusII_io.h"
18 #include "libmesh/nemesis_io.h"
19 
20 const std::string MeshGenerator::data_only_param = "_data_only";
21 
24 {
26 
27  params.addParam<bool>("show_info",
28  false,
29  "Whether or not to show mesh info after generating the mesh "
30  "(bounding box, element types, sidesets, nodesets, subdomains, etc)");
31  params.addParam<std::string>(
32  "save_with_name",
33  std::string(),
34  "Keep the mesh from this mesh generator in memory with the name specified");
35 
36  params.addParam<bool>(
37  "output", false, "Whether or not to output the mesh file after generating the mesh");
38  params.addParam<bool>("nemesis",
39  false,
40  "Whether or not to output the mesh file in the nemesis"
41  "format (only if output = true)");
42 
43  params.addParamNamesToGroup("show_info output nemesis", "Debugging");
44  params.addParamNamesToGroup("save_with_name", "Advanced");
45  params.registerBase("MeshGenerator");
46 
47  params.addPrivateParam<bool>("_has_generate_data", false);
48  params.addPrivateParam<bool>("_has_generate_csg", false);
49  params.addPrivateParam<MooseMesh *>("_moose_mesh", nullptr);
50  params.addPrivateParam<bool>(data_only_param, false);
51  // Controls are not created early enough
52  params.suppressParameter<std::vector<std::string>>("control_tags");
53 
54  return params;
55 }
56 
58  : MooseObject(parameters),
60  _mesh(getParam<MooseMesh *>("_moose_mesh") ? getParam<MooseMesh *>("_moose_mesh")
61  : _app.actionWarehouse().mesh().get()),
62  _save_with_name(getParam<std::string>("save_with_name")),
63  _data_only(getParam<bool>(data_only_param))
64 {
65  const auto & system = _app.getMeshGeneratorSystem();
66  if (isDataOnly())
67  {
68  // Skip the requirement for generateData() if we are generating CSG object
69  if (!hasGenerateCSG() && !hasGenerateData())
70  system.dataDrivenError(*this, "does not support data-driven generation");
71  if (hasSaveMesh())
72  system.dataDrivenError(*this, "has 'save_with_name' set");
73  }
74  if (_save_with_name == system.mainMeshGeneratorName())
75  paramError(
76  "save_with_name", "The user-defined mesh name: '", _save_with_name, "' is a reserved name");
77  if (getParam<bool>("nemesis") && !getParam<bool>("output"))
78  paramError("nemesis", "Should only be set to true if 'output=true'");
79 }
80 
81 void
83 {
84  params.set<bool>("_has_generate_data") = true;
85 }
86 
87 bool
89 {
90  return params.get<bool>("_has_generate_data");
91 }
92 
93 void
95 {
96  params.set<bool>("_has_generate_csg") = true;
97 }
98 
99 bool
101 {
102  return params.get<bool>("_has_generate_csg");
103 }
104 
105 const MeshGeneratorName *
106 MeshGenerator::getMeshGeneratorNameFromParam(const std::string & param_name,
107  const bool allow_invalid) const
108 {
109  const auto valid_param = isParamValid(param_name);
110  if (!allow_invalid)
111  {
112  if (!valid_param)
113  mooseError("Failed to get a parameter with the name \"",
114  param_name,
115  "\" when getting a MeshGenerator.",
116  "\n\nKnown parameters:\n",
117  _pars);
118  if (!_pars.isType<MeshGeneratorName>(param_name))
119  paramError(param_name,
120  "Parameter of type \"",
121  _pars.type(param_name),
122  "\" is not an expected type for getting a MeshGenerator (should be of type "
123  "\"MeshGeneratorName\")");
124  }
125  else if (!valid_param)
126  return nullptr;
127 
128  const auto & name = getParam<MeshGeneratorName>(param_name);
129  checkGetMesh(name, param_name);
130 
131  return &name;
132 }
133 
134 const std::vector<MeshGeneratorName> &
135 MeshGenerator::getMeshGeneratorNamesFromParam(const std::string & param_name) const
136 {
137  if (!isParamValid(param_name))
138  mooseError("Failed to get a parameter with the name \"",
139  param_name,
140  "\" when getting MeshGenerators.",
141  "\n\nKnown parameters:\n",
142  _pars);
143  if (!_pars.isType<std::vector<MeshGeneratorName>>(param_name))
144  paramError(param_name,
145  "Parameter of type \"",
146  _pars.type(param_name),
147  "\" is not an expected type for getting MeshGenerators (should be of type "
148  "\"std::vector<MeshGeneratorName>\")");
149 
150  const auto & names = getParam<std::vector<MeshGeneratorName>>(param_name);
151  for (const auto & name : names)
152  checkGetMesh(name, param_name);
153 
154  return names;
155 }
156 
157 void
158 MeshGenerator::checkGetMesh(const MeshGeneratorName & mesh_generator_name,
159  const std::string & param_name) const
160 {
161  mooseAssert(!mesh_generator_name.empty(), "Empty name");
162  const auto & mg_sys = _app.getMeshGeneratorSystem();
164  mooseError("Cannot get a mesh outside of construction");
165  if (!mg_sys.hasMeshGenerator(mesh_generator_name) && !isNullMeshName(mesh_generator_name))
166  {
167  std::stringstream error;
168  error << "The requested MeshGenerator with name '" << mesh_generator_name << "' ";
169  if (mg_sys.hasMeshGeneratorParams(mesh_generator_name))
170  error << "was found, but has not been constructed yet.\n\nThis can occur when your "
171  "dependencies are not properly defined and we cannot infer the proper construction "
172  "order of your MeshGenerators.\n\nThe most likely case is a sub generator whose "
173  "input(s) are not declared as a sub dependency in the generator creating them.";
174  else
175  error << "was not found.\nMesh generators that can be found: "
176  << Moose::stringify(mg_sys.getMeshGeneratorNames());
177 
178  if (param_name.size())
179  paramError(param_name, error.str());
180  else
181  mooseError(error.str());
182  }
183 }
184 
185 std::unique_ptr<MeshBase> &
186 MeshGenerator::getMesh(const std::string & param_name, const bool allow_invalid /* = false */)
187 {
188  const MeshGeneratorName * name = getMeshGeneratorNameFromParam(param_name, allow_invalid);
189  if (!name)
190  return _null_mesh;
191  return getMeshByName(*name);
192 }
193 
194 std::vector<std::unique_ptr<MeshBase> *>
195 MeshGenerator::getMeshes(const std::string & param_name)
196 {
198 }
199 
200 std::unique_ptr<MeshBase> &
201 MeshGenerator::getMeshByName(const MeshGeneratorName & mesh_generator_name)
202 {
203  checkGetMesh(mesh_generator_name, "");
204  if (isNullMeshName(mesh_generator_name))
205  return _null_mesh;
206 
207  _requested_mesh_generators.insert(mesh_generator_name);
208  auto & mesh = _app.getMeshGeneratorSystem().getMeshGeneratorOutput(mesh_generator_name);
209  _requested_meshes.emplace_back(mesh_generator_name, &mesh);
210  return mesh;
211 }
212 
213 std::vector<std::unique_ptr<MeshBase> *>
214 MeshGenerator::getMeshesByName(const std::vector<MeshGeneratorName> & mesh_generator_names)
215 {
216  std::vector<std::unique_ptr<MeshBase> *> meshes;
217  for (const auto & name : mesh_generator_names)
218  meshes.push_back(&getMeshByName(name));
219  return meshes;
220 }
221 
222 std::unique_ptr<CSG::CSGBase> &
223 MeshGenerator::getCSGBase(const std::string & param_name)
224 {
225  const MeshGeneratorName * name = getMeshGeneratorNameFromParam(param_name, false);
226  if (!name)
227  return _null_csg_base;
228  return getCSGBaseByName(*name);
229 }
230 
231 std::unique_ptr<CSG::CSGBase> &
232 MeshGenerator::getCSGBaseByName(const MeshGeneratorName & mesh_generator_name)
233 {
234  checkGetMesh(mesh_generator_name, "");
235  if (isNullMeshName(mesh_generator_name))
236  return _null_csg_base;
237 
238  auto & csg_base = _app.getMeshGeneratorSystem().getCSGBaseGeneratorOutput(mesh_generator_name);
239  _requested_csg_bases.emplace_back(mesh_generator_name, &csg_base);
240  return csg_base;
241 }
242 
243 std::vector<std::unique_ptr<CSG::CSGBase> *>
244 MeshGenerator::getCSGBases(const std::string & param_name)
245 {
247 }
248 
249 std::vector<std::unique_ptr<CSG::CSGBase> *>
250 MeshGenerator::getCSGBasesByName(const std::vector<MeshGeneratorName> & mesh_generator_names)
251 {
252  std::vector<std::unique_ptr<CSG::CSGBase> *> csg_bases;
253  for (const auto & name : mesh_generator_names)
254  csg_bases.push_back(&getCSGBaseByName(name));
255  return csg_bases;
256 }
257 
258 void
259 MeshGenerator::declareMeshForSub(const std::string & param_name)
260 {
262 }
263 
264 void
265 MeshGenerator::declareMeshesForSub(const std::string & param_name)
266 {
268 }
269 
270 void
271 MeshGenerator::declareMeshForSubByName(const MeshGeneratorName & mesh_generator_name)
272 {
273  checkGetMesh(mesh_generator_name, "");
274  if (isNullMeshName(mesh_generator_name))
275  return;
276 
277  _requested_mesh_generators_for_sub.insert(mesh_generator_name);
278 }
279 
280 void
282  const std::vector<MeshGeneratorName> & mesh_generator_names)
283 {
284  for (const auto & name : mesh_generator_names)
286 }
287 
288 std::unique_ptr<MeshBase>
290 {
291  mooseAssert(_mesh, "Need a MooseMesh object");
292  return _mesh->buildMeshBaseObject(dim);
293 }
294 
295 std::unique_ptr<ReplicatedMesh>
297 {
298  mooseAssert(_mesh, "Need a MooseMesh object");
299  return _mesh->buildTypedMesh<ReplicatedMesh>(dim);
300 }
301 
302 std::unique_ptr<DistributedMesh>
304 {
305  mooseAssert(_mesh, "Need a MooseMesh object");
306  return _mesh->buildTypedMesh<DistributedMesh>(dim);
307 }
308 
309 std::unique_ptr<MeshBase>
311 {
312  libmesh_parallel_only(comm());
313  mooseAssert(comm().verify(type() + name()), "Inconsistent execution ordering");
314 
315  if (hasGenerateData())
316  generateData();
317 
318  if (isDataOnly())
319  return nullptr;
320 
321  auto mesh = generate();
322  if (!mesh)
323  mooseError("A mesh was not generated by this generator (it was nullptr).");
324 
325  for (const auto & [requested_name, requested_mesh] : _requested_meshes)
326  if (*requested_mesh)
327  mooseError(
328  "The mesh from input ",
329  _app.getMeshGenerator(requested_name).type(),
330  " '",
331  _app.getMeshGenerator(requested_name).name(),
332  "' was not moved.\n\nThe MeshGenerator system requires that the memory from all input "
333  "meshes\nare managed by the requesting MeshGenerator during the generate phase.\n\nThis "
334  "is achieved with a std::move() operation within the generate() method.");
335 
336  if (getParam<bool>("show_info"))
337  {
338  if (!mesh->is_prepared())
339  mesh->prepare_for_use();
340 
341  const auto mesh_info = mesh->get_info(/* verbosity = */ 2);
342 
343  // We will prefix all information with "type() 'name()':" because this could potentially
344  // output a ton of information and looks a bit better with a prefix
345  std::stringstream oss;
346  const auto split = MooseUtils::split(mesh_info, "\n");
347  if (split.size())
348  for (std::size_t i = 0; i < split.size() - 1; ++i) // ignore the last line break
349  oss << COLOR_CYAN << "" << type() << " '" << name() << "': " << COLOR_DEFAULT << split[i]
350  << std::endl;
351  _console << oss.str() << std::flush;
352  }
353 
354  // output the current mesh block to file
355  if (hasOutput())
356  {
357  if (!mesh->is_prepared())
358  mesh->prepare_for_use();
359 
360  if (!getParam<bool>("nemesis"))
361  {
362  libMesh::ExodusII_IO exio(*mesh);
363 
364  if (mesh->mesh_dimension() == 1)
365  exio.write_as_dimension(3);
366 
367  // Avoid truncating names
368  exio.set_max_name_length(80);
369 
370  // Default to non-HDF5 output for wider compatibility
371  exio.set_hdf5_writing(false);
372 
373  exio.write(name() + "_in.e");
374  }
375  else
376  {
377  libMesh::Nemesis_IO nemesis_io(*mesh);
378 
379  // Default to non-HDF5 output for wider compatibility
380  nemesis_io.set_hdf5_writing(false);
381 
382  nemesis_io.write(name() + "_in.e");
383  }
384  }
385 
386  return mesh;
387 }
388 
389 std::unique_ptr<CSG::CSGBase>
391 {
392  mooseAssert(isDataOnly(), "Trying to use csg-only mode while not in data-driven mode");
393  auto csg_obj = generateCSG();
394  mooseAssert(csg_obj, "Null CSG object");
395  for (const auto & [requested_name, requested_csg] : _requested_csg_bases)
396  if (*requested_csg)
397  mooseError(
398  "The CSGBase object from input ",
399  _app.getMeshGenerator(requested_name).type(),
400  " '",
401  _app.getMeshGenerator(requested_name).name(),
402  "' was not moved.\n\nThe MeshGenerator system requires that the memory from all input "
403  "meshes\nare managed by the requesting MeshGenerator during the generate phase.\n\nThis "
404  "is achieved with a std::move() operation within the generateCSG() method.");
405 
406  return csg_obj;
407 }
408 
409 void
410 MeshGenerator::addMeshSubgenerator(const std::string & type,
411  const std::string & name,
412  InputParameters params)
413 {
415  mooseError("Can only call addMeshSubgenerator() during MeshGenerator construction");
416 
417  // In case the user forgot it
418  params.set<MooseApp *>(MooseBase::app_param) = &_app;
419 
420  // Set this to be data-only if this generator is data only
421  params.set<bool>(data_only_param) = isDataOnly();
422 
423  _app.addMeshGenerator(type, name, params);
424  _sub_mesh_generators.insert(&std::as_const(_app).getMeshGenerator(name));
425 }
426 
428 MeshGenerator::setMeshPropertyHelper(const std::string & data_name)
429 {
431 }
432 
433 void
435 {
436  mooseAssert(_app.constructingMeshGenerators(), "Should only be called at construction");
437  _parent_mesh_generators.insert(&mg);
438 }
439 
440 void
442 {
443  mooseAssert(_app.constructingMeshGenerators(), "Should only be called at construction");
444  _child_mesh_generators.insert(&mg);
445 }
446 
447 bool
448 MeshGenerator::isParentMeshGenerator(const MeshGeneratorName & name,
449  const bool direct /* = true */) const
450 {
451  return std::find_if(getParentMeshGenerators().begin(),
452  getParentMeshGenerators().end(),
453  [&name, &direct](const auto & mg)
454  {
455  return mg->name() == name ||
456  (!direct && mg->isParentMeshGenerator(name, /* direct = */ false));
457  }) != getParentMeshGenerators().end();
458 }
459 
460 bool
461 MeshGenerator::isChildMeshGenerator(const MeshGeneratorName & name,
462  const bool direct /* = true */) const
463 {
464  return std::find_if(getChildMeshGenerators().begin(),
465  getChildMeshGenerators().end(),
466  [&name, &direct](const auto & mg)
467  {
468  return mg->name() == name ||
469  (!direct && mg->isChildMeshGenerator(name, /* direct = */ false));
470  }) != getChildMeshGenerators().end();
471 }
472 
473 void
474 MeshGenerator::declareNullMeshName(const MeshGeneratorName & name)
475 {
476  mooseAssert(_app.constructingMeshGenerators(), "Should only be called at construction");
477  mooseAssert(!_null_mesh_names.count(name), "Already declared");
478  _null_mesh_names.insert(name);
479 }
480 
481 bool
483 {
484  return _save_with_name.size();
485 }
486 
487 bool
489 {
490  return getParam<bool>("output");
491 }
492 
493 const std::string &
495 {
496  return _save_with_name;
497 }
498 
499 void
501 {
502  mooseAssert(!hasGenerateData(), "Inconsistent flag");
503  mooseError("This MeshGenerator does not have a generateData() implementation.");
504 }
505 
506 [[nodiscard]] std::unique_ptr<CSG::CSGBase>
508 {
509  mooseAssert(!hasGenerateCSG(), "Inconsistent flag");
510  mooseError("This MeshGenerator does not have a generateCSG() implementation.");
511 }
virtual bool constructingMeshGenerators() const
Whether this app is constructing mesh generators.
Definition: MooseApp.C:3221
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::unique_ptr< CSG::CSGBase > & getCSGBaseGeneratorOutput(const MeshGeneratorName &name)
Returns the output CSGBase object associated with a particular mesh generator name.
static const std::string app_param
The name of the parameter that contains the MooseApp.
Definition: MooseBase.h:59
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.
Definition: MeshGenerator.h:76
const MeshGenerator & getMeshGenerator(const std::string &name) const
Definition: MooseApp.h:894
bool isChildMeshGenerator(const MeshGeneratorName &name, const bool direct=true) const
const InputParameters & _pars
The object&#39;s parameters.
Definition: MooseBase.h:394
void write_as_dimension(unsigned dim)
std::unique_ptr< ReplicatedMesh > buildReplicatedMesh(unsigned int dim=libMesh::invalid_uint)
Build a replicated mesh.
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.
void paramError(const std::string &param, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
Definition: MooseBase.h:467
std::vector< std::unique_ptr< CSG::CSGBase > * > getCSGBases(const std::string &param_name)
Like getCSGBase(), but for multiple generators.
const std::string & _save_with_name
A user-defined name to save the mesh.
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
bool hasSaveMesh() const
Return whether or not to save the current mesh.
std::vector< std::pair< R1, R2 > > get(const std::string &param1, const std::string &param2) const
Combine two vector parameters into a single vector of pairs.
static const RestartableDataMapName MESH_META_DATA
Definition: MooseApp.h:135
void set_max_name_length(unsigned int max_length)
virtual void generateData()
Generate the mesh data.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
MeshBase & mesh
Base class for MOOSE-based applications.
Definition: MooseApp.h:108
static std::string meshPropertyName(const std::string &data_name, const std::string &prefix)
bool hasOutput() const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
static constexpr std::size_t dim
This is the dimension of all vector and tensor datastructures used in MOOSE.
Definition: Moose.h:163
const Parallel::Communicator & comm() const
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&#39;t specified.
MeshGenerator(const InputParameters &parameters)
Definition: MeshGenerator.C:57
std::unique_ptr< CSG::CSGBase > _null_csg_base
A nullptr to use for when inputs aren&#39;t specified.
bool hasGenerateData() const
std::set< const MeshGenerator *, Comparator > _child_mesh_generators
The MeshGenerators that are children to this MeshGenerator.
bool isNullMeshName(const MeshGeneratorName &name) const
MooseMesh *const _mesh
Pointer to the owning mesh.
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
void addChildMeshGenerator(const MeshGenerator &mg, const AddParentChildKey)
Adds the MeshGenerator mg as a child.
void declareMeshForSub(const std::string &param_name)
Declares that a MeshGenerator referenced in the InputParameters is to be used as a dependency of a su...
void registerBase(const std::string &value)
This method must be called from every base "Moose System" to create linkage with the Action System...
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.
Definition: MooseBase.h:103
RestartableDataValue & getRestartableMetaData(const std::string &name, const RestartableDataMapName &metaname, THREAD_ID tid)
Definition: MooseApp.C:2238
std::unique_ptr< T > buildTypedMesh(unsigned int dim=libMesh::invalid_uint)
Shortcut method to construct a unique pointer to a libMesh mesh instance.
Definition: MooseMesh.h:2249
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.
Definition: MooseObject.h:28
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
Method to construct a libMesh::MeshBase object that is normally set and used by the MooseMesh object ...
Definition: MooseMesh.C:2944
void declareMeshesForSubByName(const std::vector< MeshGeneratorName > &mesh_generator_names)
Like declareMeshForSubByName(), but for multiple generators.
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 &param_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...
Definition: MooseMesh.h:93
virtual std::unique_ptr< MeshBase > generate()=0
Generate / modify the mesh.
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:93
std::set< MeshGeneratorName > _requested_mesh_generators
The names of the MeshGenerators that were requested in the getMesh methods.
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 &param_name)
Like getMesh(), but for multiple generators.
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:385
static InputParameters validParams()
Definition: MeshGenerator.C:23
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
std::unique_ptr< MeshBase > generateInternal()
Internal generation method - this is what is actually called within MooseApp to execute the MeshGener...
static void setHasGenerateCSG(InputParameters &params)
Sets that a mesh generator has a generateCSG() implementation.
Definition: MeshGenerator.C:94
bool hasGenerateCSG() const
std::set< const MeshGenerator *, Comparator > _sub_mesh_generators
The sub MeshGenerators constructed by this MeshGenerator.
tbb::split split
bool isType(const std::string &name) const
void 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.
Definition: MooseApp.h:876
virtual void write(const std::string &fname) override
Class that is used as a parameter to add[Parent/Child]() that allows only MeshGeneratorSystem methods...
std::string type(const std::string &name) const
Prints the type of the requested parameter by name.
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 &param_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...
Definition: MooseBase.h:281
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 &param_name)
Takes the name of a MeshGeneratorName parameter and then gets a pointer to the CSGBase object that Me...
static void setHasGenerateData(InputParameters &params)
Sets that a mesh generator has a generateData() implementation.
Definition: MeshGenerator.C:82
virtual void write(const std::string &base_filename) override
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an optional parameter and a documentation string to the InputParameters object...
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 w...
The Interface used to retrieve mesh meta data (attributes) set by the MeshGenerator system...
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
Definition: MooseBase.h:209
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
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 isDataOnly() const
MeshGeneratorSystem & getMeshGeneratorSystem()
Gets the system that manages the MeshGenerators.
Definition: MooseApp.h:860
static InputParameters validParams()
Definition: MooseObject.C:25
void declareMeshesForSub(const std::string &param_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 ...
std::vector< std::string > split(const std::string &str, const std::string &delimiter, std::size_t max_count)
Definition: MooseUtils.C:1020
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.
void set_hdf5_writing(bool write_hdf5)
void set_hdf5_writing(bool write_hdf5)
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:33
const std::vector< MeshGeneratorName > & getMeshGeneratorNamesFromParam(const std::string &param_name) const
Helper for getting a std::vector<MeshGeneratorName> parameter.
const Elem & get(const ElemType type_in)
Abstract definition of a RestartableData value.
const MeshGeneratorName * getMeshGeneratorNameFromParam(const std::string &param_name, const bool allow_invalid) const
Helper for getting a MeshGeneratorName parameter.
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.
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...