https://mooseframework.inl.gov
DistributedRectilinearMeshGenerator.h
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 #pragma once
11 
12 #include "MeshGenerator.h"
13 
14 #include "libmesh/face_quad4.h"
15 #include "libmesh/cell_hex8.h"
16 #include "libmesh/edge_edge2.h"
17 
27 {
28 public:
30 
32 
33  std::unique_ptr<MeshBase> generate() override;
34 
50  template <typename T>
51  void buildCube(UnstructuredMesh & /*mesh*/,
52  const unsigned int /*nx*/,
53  unsigned int /*ny*/,
54  unsigned int /*nz*/,
55  const Real /*xmin*/,
56  const Real /*xmax*/,
57  const Real /*ymin*/,
58  const Real /*ymax*/,
59  const Real /*zmin*/,
60  const Real /*zmax*/,
61  const ElemType /*type*/);
62 
73  template <typename T>
75  const dof_id_type /*ny*/,
76  const dof_id_type /*i*/,
77  const dof_id_type /*j*/,
78  const dof_id_type /*k*/)
79  {
80  mooseError(
81  "elemId not implemented for this element type in DistributedRectilinearMeshGenerator");
82  }
83 
95  template <typename T>
97  const dof_id_type /*ny*/,
98  const dof_id_type /*nz*/,
99  const dof_id_type /*i*/,
100  const dof_id_type /*j*/,
101  const dof_id_type /*k*/)
102  {
103  mooseError("numNeighbors not implemented for this element type in "
104  "DistributedRectilinearMeshGenerator");
105  }
106 
119  template <typename T>
120  void getNeighbors(const dof_id_type /*nx*/,
121  const dof_id_type /*ny*/,
122  const dof_id_type /*nz*/,
123  const dof_id_type /*i*/,
124  const dof_id_type /*j*/,
125  const dof_id_type /*k*/,
126  std::vector<dof_id_type> & /*neighbors*/,
127  const bool /*corner = false*/)
128  {
129  mooseError("getNeighbors not implemented for this element type in "
130  "DistributedRectilinearMeshGenerator");
131  }
132 
144  template <typename T>
145  dof_id_type nodeId(const ElemType /*type*/,
146  const dof_id_type /*nx*/,
147  const dof_id_type /*ny*/,
148  const dof_id_type /*i*/,
149  const dof_id_type /*j*/,
150  const dof_id_type /*k*/)
151  {
152  mooseError(
153  "nodeId not implemented for this element type in DistributedRectilinearMeshGenerator");
154  }
155 
168  template <typename T>
169  Node * addPoint(const dof_id_type /*nx*/,
170  const dof_id_type /*ny*/,
171  const dof_id_type /*nz*/,
172  const dof_id_type /*i*/,
173  const dof_id_type /*j*/,
174  const dof_id_type /*k*/,
175  const ElemType /*type*/,
176  MeshBase & /*mesh*/)
177  {
178  mooseError(
179  "addPoint not implemented for this element type in DistributedRectilinearMeshGenerator");
180  }
181 
196  template <typename T>
197  void addElement(const dof_id_type /*nx*/,
198  const dof_id_type /*ny*/,
199  const dof_id_type /*nz*/,
200  const dof_id_type /*i*/,
201  const dof_id_type /*j*/,
202  const dof_id_type /*k*/,
203  const dof_id_type /*elem_id*/,
204  const processor_id_type /*pid*/,
205  const ElemType /*type*/,
206  MeshBase & /*mesh*/)
207  {
208  mooseError(
209  "addElement not implemented for this element type in DistributedRectilinearMeshGenerator");
210  }
211 
227  template <typename T>
228  void paritionSquarely(const dof_id_type /*nx*/,
229  const dof_id_type /*ny*/,
230  const dof_id_type /*nz*/,
231  const processor_id_type /*num_procs*/,
232  std::vector<dof_id_type> & /*istarts*/,
233  std::vector<dof_id_type> & /*jstarts*/,
234  std::vector<dof_id_type> & /*kstarts*/)
235  {
236  mooseError("paritionSquarely not implemented for this element type in "
237  "DistributedRectilinearMeshGenerator");
238  }
239 
250  template <typename T>
251  void getIndices(const dof_id_type /*nx*/,
252  const dof_id_type /*ny*/,
253  const dof_id_type /*elem_id*/,
254  dof_id_type & /*i*/,
255  dof_id_type & /*j*/,
256  dof_id_type & /*k*/)
257  {
258  mooseError(
259  "getIndices not implemented for this element type in DistributedRectilinearMeshGenerator");
260  }
261 
270  template <typename T>
271  void getGhostNeighbors(const dof_id_type /*nx*/,
272  const dof_id_type /*ny*/,
273  const dof_id_type /*nz*/,
274  const MeshBase & /*mesh*/,
275  const std::set<dof_id_type> & /*current_elems*/,
276  std::set<dof_id_type> & /*ghost_elems*/)
277  {
278  mooseError("getGhostNeighbors not implemented for this element type in "
279  "DistributedRectilinearMeshGenerator");
280  }
281 
287  template <typename T>
288  void setBoundaryNames(BoundaryInfo & /*boundary_info*/)
289  {
290  mooseError("setBoundaryNames not implemented for this element type in "
291  "DistributedRectilinearMeshGenerator");
292  }
293 
309  template <typename T>
311  dof_id_type /*ny*/,
312  dof_id_type /*nz*/,
313  Real /*xmin*/,
314  Real /*xmax*/,
315  Real /*ymin*/,
316  Real /*ymax*/,
317  Real /*zmin*/,
318  Real /*zmax*/,
319  MeshBase & /*mesh*/)
320  {
321  mooseError("scaleNodalPositions not implemented for this element type in "
322  "DistributedRectilinearMeshGenerator");
323  }
324 
325 protected:
328 
331 
334 
342 
345 
352 
354  std::string _part_package;
355 
358 
360  std::string _partition_method;
361 
367 };
368 
369 template <>
370 dof_id_type DistributedRectilinearMeshGenerator::elemId<Edge2>(const dof_id_type nx,
371  const dof_id_type ny,
372  const dof_id_type i,
373  const dof_id_type j,
374  const dof_id_type k);
375 
376 template <>
377 dof_id_type DistributedRectilinearMeshGenerator::elemId<Quad4>(const dof_id_type nx,
378  const dof_id_type ny,
379  const dof_id_type i,
380  const dof_id_type j,
381  const dof_id_type k);
382 
383 template <>
384 dof_id_type DistributedRectilinearMeshGenerator::elemId<Hex8>(const dof_id_type nx,
385  const dof_id_type ny,
386  const dof_id_type i,
387  const dof_id_type j,
388  const dof_id_type k);
389 
390 template <>
391 dof_id_type DistributedRectilinearMeshGenerator::numNeighbors<Edge2>(const dof_id_type nx,
392  const dof_id_type ny,
393  const dof_id_type nz,
394  const dof_id_type i,
395  const dof_id_type j,
396  const dof_id_type k);
397 
398 template <>
399 dof_id_type DistributedRectilinearMeshGenerator::numNeighbors<Quad4>(const dof_id_type nx,
400  const dof_id_type ny,
401  const dof_id_type nz,
402  const dof_id_type i,
403  const dof_id_type j,
404  const dof_id_type k);
405 
406 template <>
407 dof_id_type DistributedRectilinearMeshGenerator::numNeighbors<Hex8>(const dof_id_type nx,
408  const dof_id_type ny,
409  const dof_id_type nz,
410  const dof_id_type i,
411  const dof_id_type j,
412  const dof_id_type k);
413 
414 template <>
415 void DistributedRectilinearMeshGenerator::getNeighbors<Edge2>(const dof_id_type nx,
416  const dof_id_type ny,
417  const dof_id_type nz,
418  const dof_id_type i,
419  const dof_id_type j,
420  const dof_id_type k,
421  std::vector<dof_id_type> & neighbors,
422  const bool corner);
423 
424 template <>
425 void DistributedRectilinearMeshGenerator::getNeighbors<Quad4>(const dof_id_type nx,
426  const dof_id_type ny,
427  const dof_id_type nz,
428  const dof_id_type i,
429  const dof_id_type j,
430  const dof_id_type k,
431  std::vector<dof_id_type> & neighbors,
432  const bool corner);
433 
434 template <>
435 void DistributedRectilinearMeshGenerator::getNeighbors<Hex8>(const dof_id_type nx,
436  const dof_id_type ny,
437  const dof_id_type nz,
438  const dof_id_type i,
439  const dof_id_type j,
440  const dof_id_type k,
441  std::vector<dof_id_type> & neighbors,
442  const bool corner);
443 
444 template <>
445 dof_id_type DistributedRectilinearMeshGenerator::nodeId<Edge2>(const ElemType type,
446  const dof_id_type nx,
447  const dof_id_type ny,
448  const dof_id_type i,
449  const dof_id_type j,
450  const dof_id_type k);
451 
452 template <>
453 dof_id_type DistributedRectilinearMeshGenerator::nodeId<Quad4>(const ElemType type,
454  const dof_id_type nx,
455  const dof_id_type ny,
456  const dof_id_type i,
457  const dof_id_type j,
458  const dof_id_type k);
459 
460 template <>
461 dof_id_type DistributedRectilinearMeshGenerator::nodeId<Hex8>(const ElemType type,
462  const dof_id_type nx,
463  const dof_id_type ny,
464  const dof_id_type i,
465  const dof_id_type j,
466  const dof_id_type k);
467 
468 template <>
469 Node * DistributedRectilinearMeshGenerator::addPoint<Edge2>(const dof_id_type nx,
470  const dof_id_type ny,
471  const dof_id_type nz,
472  const dof_id_type i,
473  const dof_id_type j,
474  const dof_id_type k,
475  const ElemType type,
476  MeshBase & mesh);
477 
478 template <>
479 Node * DistributedRectilinearMeshGenerator::addPoint<Quad4>(const dof_id_type nx,
480  const dof_id_type ny,
481  const dof_id_type nz,
482  const dof_id_type i,
483  const dof_id_type j,
484  const dof_id_type k,
485  const ElemType type,
486  MeshBase & mesh);
487 
488 template <>
489 Node * DistributedRectilinearMeshGenerator::addPoint<Hex8>(const dof_id_type nx,
490  const dof_id_type ny,
491  const dof_id_type nz,
492  const dof_id_type i,
493  const dof_id_type j,
494  const dof_id_type k,
495  const ElemType type,
496  MeshBase & mesh);
497 
498 template <>
499 void DistributedRectilinearMeshGenerator::addElement<Edge2>(const dof_id_type nx,
500  const dof_id_type ny,
501  const dof_id_type nz,
502  const dof_id_type i,
503  const dof_id_type j,
504  const dof_id_type k,
505  const dof_id_type elem_id,
506  const processor_id_type pid,
507  const ElemType type,
508  MeshBase & mesh);
509 
510 template <>
511 void DistributedRectilinearMeshGenerator::addElement<Quad4>(const dof_id_type nx,
512  const dof_id_type ny,
513  const dof_id_type nz,
514  const dof_id_type i,
515  const dof_id_type j,
516  const dof_id_type k,
517  const dof_id_type elem_id,
518  const processor_id_type pid,
519  const ElemType type,
520  MeshBase & mesh);
521 
522 template <>
523 void DistributedRectilinearMeshGenerator::addElement<Hex8>(const dof_id_type nx,
524  const dof_id_type ny,
525  const dof_id_type nz,
526  const dof_id_type i,
527  const dof_id_type j,
528  const dof_id_type k,
529  const dof_id_type elem_id,
530  const processor_id_type pid,
531  const ElemType type,
532  MeshBase & mesh);
533 
534 template <>
535 void DistributedRectilinearMeshGenerator::getIndices<Edge2>(const dof_id_type nx,
536  const dof_id_type ny,
537  const dof_id_type elem_id,
538  dof_id_type & i,
539  dof_id_type & j,
540  dof_id_type & k);
541 
542 template <>
543 void DistributedRectilinearMeshGenerator::getIndices<Quad4>(const dof_id_type nx,
544  const dof_id_type ny,
545  const dof_id_type elem_id,
546  dof_id_type & i,
547  dof_id_type & j,
548  dof_id_type & k);
549 
550 template <>
551 void DistributedRectilinearMeshGenerator::getIndices<Hex8>(const dof_id_type nx,
552  const dof_id_type ny,
553  const dof_id_type elem_id,
554  dof_id_type & i,
555  dof_id_type & j,
556  dof_id_type & k);
557 
558 template <>
559 void DistributedRectilinearMeshGenerator::getGhostNeighbors<Edge2>(
560  const dof_id_type nx,
561  const dof_id_type ny,
562  const dof_id_type nz,
563  const MeshBase & mesh,
564  const std::set<dof_id_type> & current_elems,
565  std::set<dof_id_type> & ghost_elems);
566 
567 template <>
568 void DistributedRectilinearMeshGenerator::getGhostNeighbors<Quad4>(
569  const dof_id_type nx,
570  const dof_id_type ny,
571  const dof_id_type nz,
572  const MeshBase & mesh,
573  const std::set<dof_id_type> & current_elems,
574  std::set<dof_id_type> & ghost_elems);
575 
576 template <>
577 void DistributedRectilinearMeshGenerator::getGhostNeighbors<Hex8>(
578  const dof_id_type nx,
579  const dof_id_type ny,
580  const dof_id_type nz,
581  const MeshBase & mesh,
582  const std::set<dof_id_type> & current_elems,
583  std::set<dof_id_type> & ghost_elems);
584 
585 template <>
586 void DistributedRectilinearMeshGenerator::scaleNodalPositions<Edge2>(dof_id_type nx,
587  dof_id_type ny,
588  dof_id_type nz,
589  Real xmin,
590  Real xmax,
591  Real ymin,
592  Real ymax,
593  Real zmin,
594  Real zmax,
595  MeshBase & mesh);
596 
597 template <>
598 void DistributedRectilinearMeshGenerator::scaleNodalPositions<Quad4>(dof_id_type nx,
599  dof_id_type ny,
600  dof_id_type nz,
601  Real xmin,
602  Real xmax,
603  Real ymin,
604  Real ymax,
605  Real zmin,
606  Real zmax,
607  MeshBase & mesh);
608 
609 template <>
610 void DistributedRectilinearMeshGenerator::scaleNodalPositions<Hex8>(dof_id_type nx,
611  dof_id_type ny,
612  dof_id_type nz,
613  Real xmin,
614  Real xmax,
615  Real ymin,
616  Real ymax,
617  Real zmin,
618  Real zmax,
619  MeshBase & mesh);
620 
621 template <>
622 void DistributedRectilinearMeshGenerator::setBoundaryNames<Edge2>(BoundaryInfo & boundary_info);
623 
624 template <>
625 void DistributedRectilinearMeshGenerator::setBoundaryNames<Quad4>(BoundaryInfo & boundary_info);
626 
627 template <>
628 void DistributedRectilinearMeshGenerator::setBoundaryNames<Hex8>(BoundaryInfo & boundary_info);
629 
630 template <>
631 void DistributedRectilinearMeshGenerator::paritionSquarely<Edge2>(
632  const dof_id_type /*nx*/,
633  const dof_id_type /*ny*/,
634  const dof_id_type /*nz*/,
635  const processor_id_type /*num_procs*/,
636  std::vector<dof_id_type> & /*istarts*/,
637  std::vector<dof_id_type> & /*jstarts*/,
638  std::vector<dof_id_type> & /*kstarts*/);
639 
640 template <>
641 void DistributedRectilinearMeshGenerator::paritionSquarely<Quad4>(
642  const dof_id_type /*nx*/,
643  const dof_id_type /*ny*/,
644  const dof_id_type /*nz*/,
645  const processor_id_type /*num_procs*/,
646  std::vector<dof_id_type> & /*istarts*/,
647  std::vector<dof_id_type> & /*jstarts*/,
648  std::vector<dof_id_type> & /*kstarts*/);
649 
650 template <>
651 void
652 DistributedRectilinearMeshGenerator::paritionSquarely<Hex8>(const dof_id_type /*nx*/,
653  const dof_id_type /*ny*/,
654  const dof_id_type /*nz*/,
655  const processor_id_type /*num_procs*/,
656  std::vector<dof_id_type> & /*istarts*/,
657  std::vector<dof_id_type> & /*jstarts*/,
658  std::vector<dof_id_type> & /*kstarts*/);
processor_id_type _num_parts_per_compute_node
Number of cores per compute node if hierarch partitioning is used.
void getNeighbors(const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, std::vector< dof_id_type > &, const bool)
Get the IDs of the neighbors of a given element.
ElemType
void scaleNodalPositions(dof_id_type, dof_id_type, dof_id_type, Real, Real, Real, Real, Real, Real, MeshBase &)
All meshes are generated on the unit square.
dof_id_type & _nx
Number of elements in x, y, z direction.
processor_id_type _num_cores_for_partition
Number of cores for partitioning the graph The number of cores for the graph partition can be differe...
void getIndices(const dof_id_type, const dof_id_type, const dof_id_type, dof_id_type &, dof_id_type &, dof_id_type &)
Compute the i,j,k indices of a given element ID.
void getGhostNeighbors(const dof_id_type, const dof_id_type, const dof_id_type, const MeshBase &, const std::set< dof_id_type > &, std::set< dof_id_type > &)
Find the elements and sides that need ghost elements.
MeshBase & mesh
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
ElemType _elem_type
The type of element to build.
DistributedRectilinearMeshGenerator(const InputParameters &parameters)
This class works by first creating a "distributed dual graph" of the element connectivity based on a ...
void paritionSquarely(const dof_id_type, const dof_id_type, const dof_id_type, const processor_id_type, std::vector< dof_id_type > &, std::vector< dof_id_type > &, std::vector< dof_id_type > &)
Partition mesh squarely.
uint8_t processor_id_type
void addElement(const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const processor_id_type, const ElemType, MeshBase &)
Adds an element to the mesh.
Node * addPoint(const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const ElemType, MeshBase &)
Add a node to the mesh.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:33
void setBoundaryNames(BoundaryInfo &)
Set the boundary names for any added boundary ideas.
Real & _xmin
The min/max values for x,y,z component.
void buildCube(UnstructuredMesh &, const unsigned int, unsigned int, unsigned int, const Real, const Real, const Real, const Real, const Real, const Real, const ElemType)
Build a cube mesh.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
dof_id_type numNeighbors(const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type)
Get the number of neighbors this element will have.
const InputParameters & parameters() const
Get the parameters of the object.
Real _bias_x
The amount by which to bias the cells in the x,y,z directions.
unsigned _num_side_layers
Number of element side neighbor layers While most of applications in moose require one layer of side ...
dof_id_type nodeId(const ElemType, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type)
The ID of the i,j,k node.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
MeshGenerators are objects that can modify or add to an existing mesh.
Definition: MeshGenerator.h:32
uint8_t dof_id_type
dof_id_type elemId(const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type, const dof_id_type)
Get the element ID for a given hex.
std::string _partition_method
Which method is used to partition the mesh that is not built yet.