https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
28public:
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>
74 dof_id_type elemId(const dof_id_type /*nx*/,
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 {
81 "elemId not implemented for this element type in DistributedRectilinearMeshGenerator");
82 }
83
95 template <typename T>
96 dof_id_type numNeighbors(const dof_id_type /*nx*/,
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 {
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 {
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 {
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 {
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>
310 void scaleNodalPositions(dof_id_type /*nx*/,
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
325protected:
328
330 dof_id_type &_nx, &_ny, &_nz;
331
333 Real &_xmin, &_xmax, &_ymin, &_ymax, &_zmin, &_zmax;
334
341 processor_id_type _num_cores_for_partition;
342
344 ElemType _elem_type;
345
352
354 std::string _part_package;
355
358
360 std::string _partition_method;
361
367};
368
369template <>
370dof_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
376template <>
377dof_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
383template <>
384dof_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
390template <>
391dof_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
398template <>
399dof_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
406template <>
407dof_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
414template <>
415void 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
424template <>
425void 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
434template <>
435void 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
444template <>
445dof_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
452template <>
453dof_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
460template <>
461dof_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
468template <>
469Node * 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
478template <>
479Node * 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
488template <>
489Node * 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
498template <>
499void 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
510template <>
511void 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
522template <>
523void 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
534template <>
535void 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
542template <>
543void 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
550template <>
551void 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
558template <>
559void 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
567template <>
568void 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
576template <>
577void 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
585template <>
586void 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
597template <>
598void 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
609template <>
610void 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
621template <>
622void DistributedRectilinearMeshGenerator::setBoundaryNames<Edge2>(BoundaryInfo & boundary_info);
623
624template <>
625void DistributedRectilinearMeshGenerator::setBoundaryNames<Quad4>(BoundaryInfo & boundary_info);
626
627template <>
628void DistributedRectilinearMeshGenerator::setBoundaryNames<Hex8>(BoundaryInfo & boundary_info);
629
630template <>
631void 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
640template <>
641void 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
650template <>
651void
652DistributedRectilinearMeshGenerator::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*/);
This class works by first creating a "distributed dual graph" of the element connectivity based on a ...
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.
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.
Real _bias_x
The amount by which to bias the cells in the x,y,z directions.
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.
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.
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.
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 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.
Real & _xmin
The min/max values for x,y,z component.
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.
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.
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.
std::string _partition_method
Which method is used to partition the mesh that is not built yet.
unsigned _num_side_layers
Number of element side neighbor layers While most of applications in moose require one layer of side ...
ElemType _elem_type
The type of element to build.
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.
void setBoundaryNames(BoundaryInfo &)
Set the boundary names for any added boundary ideas.
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.
dof_id_type & _nx
Number of elements in x, y, z direction.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
processor_id_type _num_parts_per_compute_node
Number of cores per compute node if hierarch partitioning is used.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
MeshGenerators are objects that can modify or add to an existing mesh.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
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:271
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55