Cardinal
NekRSMesh.h
Go to the documentation of this file.
1 /********************************************************************/
2 /* SOFTWARE COPYRIGHT NOTIFICATION */
3 /* Cardinal */
4 /* */
5 /* (c) 2021 UChicago Argonne, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by UChicago Argonne, LLC */
9 /* Under Contract No. DE-AC02-06CH11357 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* Prepared by Battelle Energy Alliance, LLC */
13 /* Under Contract No. DE-AC07-05ID14517 */
14 /* With the U. S. Department of Energy */
15 /* */
16 /* See LICENSE for full restrictions */
17 /********************************************************************/
18 
19 #pragma once
20 
21 #include "MooseMesh.h"
22 #include "MooseApp.h"
23 #include "CardinalEnums.h"
24 #include "NekBoundaryCoupling.h"
25 #include "NekVolumeCoupling.h"
26 #include "NekInterface.h"
27 #include "NekUtility.h"
28 
50 class NekRSMesh : public MooseMesh
51 {
52 public:
53  NekRSMesh(const InputParameters & parameters);
54  static InputParameters validParams();
55 
56  NekRSMesh(const NekRSMesh & /* other_mesh */) = default;
57 
58  NekRSMesh & operator=(const NekRSMesh & other_mesh) = delete;
59  virtual std::unique_ptr<MooseMesh> safeClone() const override;
60 
62  void saveInitialVolMesh();
63 
66 
71  int nekPolynomialOrder() const { return _nek_polynomial_order; }
72 
78 
84 
89  const std::vector<double> & nek_initial_x() const { return _initial_x; }
90 
95  const std::vector<double> & nek_initial_y() const { return _initial_y; }
96 
101  const std::vector<double> & nek_initial_z() const { return _initial_z; }
102 
107  std::vector<double> & prev_disp_x() { return _prev_disp_x; }
108 
113  std::vector<double> & prev_disp_y() { return _prev_disp_y; }
114 
119  std::vector<double> & prev_disp_z() { return _prev_disp_z; }
120 
126 
132 
134  virtual void addElems();
135 
140  const order::NekOrderEnum & order() const { return _order; }
141 
146  int numQuadraturePoints1D() const;
147 
152  int nekNumQuadraturePoints1D() const;
153 
161  const int & numElems() const { return _n_elems; }
162 
170  const int & numVerticesPerElem() const { return _n_vertices_per_elem; }
171 
180  int nodeIndex(const int gll_index) const { return (*_node_index)[gll_index]; }
181 
186  const int & numSurfaceElems() const { return _n_surface_elems; }
187 
192  const int & nekNumSurfaceElems() const { return _nek_n_surface_elems; }
193 
198  const int & numVerticesPerSurface() const { return _n_vertices_per_surface; }
199 
204  const int & numVolumeElems() const { return _n_volume_elems; }
205 
210  const int & nekNumVolumeElems() const { return _nek_n_volume_elems; }
211 
216  const int & numVerticesPerVolume() const { return _n_vertices_per_volume; }
217 
222  const std::vector<int> * boundary() const { return _boundary; }
223 
228  const bool & volume() const { return _volume; }
229 
231  Elem * boundaryElem() const;
232 
234  Elem * volumeElem() const;
235 
236  virtual void buildMesh() override;
237 
242  virtual void buildDummyMesh();
243 
248  virtual void extractSurfaceMesh();
249 
254  virtual void extractVolumeMesh();
255 
261  int boundaryNodeIndex(const int gll_index) const { return _bnd_node_index[gll_index]; }
262 
268  int volumeNodeIndex(const int gll_index) const { return _vol_node_index[gll_index]; }
269 
274  const Real & scaling() const { return _scaling; }
275 
277  virtual void printMeshInfo() const;
278 
283  int boundaryElemProcessorID(const int elem_id);
284 
289  int volumeElemProcessorID(const int elem_id);
290 
296  int facesOnBoundary(const int elem_id) const;
297 
302  bool exactMirror() const { return _exact; }
303 
308  std::vector<std::vector<int>> cornerIndices() const { return _corner_indices; }
309 
314  int nMoosePerNek() const { return _n_moose_per_nek; }
315 
322  void updateDisplacement(const int e, const double * src, const field::NekWriteEnum field);
323 
324 protected:
326  void storeVolumeCoupling();
327 
332  void storeBoundaryCoupling();
333 
340  int boundary_id(const int elem_id, const int face_id);
341 
346  void faceVertices();
347 
352  void volumeVertices();
353 
355  void initializeMeshParams();
356 
365  const bool & _volume;
366 
368  const std::vector<int> * _boundary;
369 
381 
392  const bool & _exact;
393 
396 
399 
413  const Real & _scaling;
414 
416  const unsigned int & _fluid_block_id;
417 
419  const unsigned int & _solid_block_id;
420 
423 
429 
432 
438 
441 
446  int _n_elems;
447 
453 
455  int (NekRSMesh::*_elem_processor_id)(const int elem_id);
456 
459 
461  std::vector<int> * _node_index;
462 
465 
468 
476  std::vector<int> _phase;
477 
484  std::vector<double> _x;
485 
492  std::vector<double> _y;
493 
500  std::vector<double> _z;
501 
508  std::vector<double> _initial_x;
509 
516  std::vector<double> _initial_y;
517 
524  std::vector<double> _initial_z;
525 
527 
531  std::vector<double> _prev_disp_x;
532  std::vector<double> _prev_disp_y;
533  std::vector<double> _prev_disp_z;
535 
544  std::vector<int> _bnd_node_index;
545 
555  std::vector<int> _vol_node_index;
556 
565  std::vector<int> _side_index;
566 
568  Elem * (NekRSMesh::*_new_elem)() const;
569 
572 
575 
577  mesh_t * _nek_internal_mesh = nullptr;
578 
580  std::vector<std::vector<int>> _corner_indices;
581 };
NekRSMesh::storeBoundaryCoupling
void storeBoundaryCoupling()
order::NekOrderEnum
NekOrderEnum
Enumeration of possible surface order reconstructions for nekRS solution transfer.
Definition: CardinalEnums.h:68
NekRSMesh::order
const order::NekOrderEnum & order() const
Definition: NekRSMesh.h:140
NekRSMesh::volumeElemProcessorID
int volumeElemProcessorID(const int elem_id)
NekRSMesh::_volume_coupling
NekVolumeCoupling _volume_coupling
Data structure holding mapping information for volume coupling.
Definition: NekRSMesh.h:574
NekRSMesh::_initial_x
std::vector< double > _initial_x
coordinates of the initial GLL points, for this rank
Definition: NekRSMesh.h:508
NekRSMesh::_z
std::vector< double > _z
coordinates of the current GLL points (which can move in time), for this rank
Definition: NekRSMesh.h:500
NekRSMesh::boundaryNodeIndex
int boundaryNodeIndex(const int gll_index) const
Definition: NekRSMesh.h:261
NekRSMesh::nekNumQuadraturePoints1D
int nekNumQuadraturePoints1D() const
NekRSMesh::_initial_y
std::vector< double > _initial_y
coordinates of the initial GLL points, for this rank
Definition: NekRSMesh.h:516
NekRSMesh::_n_vertices_per_elem
int _n_vertices_per_elem
Number of vertices per element, which depends on whether building a boundary/volume mesh.
Definition: NekRSMesh.h:458
field::NekWriteEnum
NekWriteEnum
Enumeration of possible fields to write in nekRS.
Definition: CardinalEnums.h:104
NekBoundaryCoupling
Definition: NekBoundaryCoupling.h:29
NekRSMesh::_side_index
std::vector< int > _side_index
Mapping of side indices to libMesh side indices.
Definition: NekRSMesh.h:565
NekRSMesh::prev_disp_y
std::vector< double > & prev_disp_y()
Definition: NekRSMesh.h:113
NekRSMesh::_n_elems
int _n_elems
Definition: NekRSMesh.h:446
NekRSMesh::_boundary
const std::vector< int > * _boundary
Boundary ID(s) through which to couple Nek to MOOSE.
Definition: NekRSMesh.h:368
field
Definition: CardinalEnums.h:85
NekRSMesh::numVolumeElems
const int & numVolumeElems() const
Definition: NekRSMesh.h:204
NekRSMesh::exactMirror
bool exactMirror() const
Definition: NekRSMesh.h:302
NekRSMesh::_volume
const bool & _volume
Whether nekRS is coupled through volumes to MOOSE.
Definition: NekRSMesh.h:365
NekRSMesh::extractSurfaceMesh
virtual void extractSurfaceMesh()
NekRSMesh::prev_disp_z
std::vector< double > & prev_disp_z()
Definition: NekRSMesh.h:119
NekRSMesh::_n_vertices_per_surface
int _n_vertices_per_surface
Number of vertices per surface.
Definition: NekRSMesh.h:395
NekVolumeCoupling.h
NekRSMesh::_elem_processor_id
int(NekRSMesh::* _elem_processor_id)(const int elem_id)
Function returning the processor id which should own each element.
Definition: NekRSMesh.h:455
NekRSMesh::nBuildPerVolumeElem
int nBuildPerVolumeElem() const
Definition: NekRSMesh.h:77
NekRSMesh::addElems
virtual void addElems()
Add all the elements in the mesh to the MOOSE data structures.
NekRSMesh::_n_build_per_volume_elem
int _n_build_per_volume_elem
Number of MOOSE volume elements to build per NekRS volume element.
Definition: NekRSMesh.h:440
NekRSMesh::_prev_disp_x
std::vector< double > _prev_disp_x
Definition: NekRSMesh.h:531
NekRSMesh::_node_index
std::vector< int > * _node_index
Mapping of GLL nodes to libMesh nodes, which depends on whether building a boundary/volume mesh.
Definition: NekRSMesh.h:461
NekRSMesh::nek_initial_x
const std::vector< double > & nek_initial_x() const
Definition: NekRSMesh.h:89
NekRSMesh::cornerIndices
std::vector< std::vector< int > > cornerIndices() const
Definition: NekRSMesh.h:308
NekRSMesh::prev_disp_x
std::vector< double > & prev_disp_x()
Definition: NekRSMesh.h:107
NekRSMesh::boundaryElem
Elem * boundaryElem() const
Create a new element for a boundary mesh.
NekRSMesh::nek_initial_y
const std::vector< double > & nek_initial_y() const
Definition: NekRSMesh.h:95
NekRSMesh::_order
const order::NekOrderEnum _order
Order of the surface interpolation between nekRS and MOOSE.
Definition: NekRSMesh.h:380
NekRSMesh::_x
std::vector< double > _x
coordinates of the current GLL points (which can move in time), for this rank
Definition: NekRSMesh.h:484
NekRSMesh::_new_elem
Elem *(NekRSMesh::* _new_elem)() const
Function pointer to the type of new element to add.
Definition: NekRSMesh.h:568
NekRSMesh::scaling
const Real & scaling() const
Definition: NekRSMesh.h:274
NekRSMesh::nMoosePerNek
int nMoosePerNek() const
Definition: NekRSMesh.h:314
NekRSMesh::extractVolumeMesh
virtual void extractVolumeMesh()
NekRSMesh::_prev_disp_z
std::vector< double > _prev_disp_z
Definition: NekRSMesh.h:533
NekRSMesh
Definition: NekRSMesh.h:50
NekRSMesh::nodeIndex
int nodeIndex(const int gll_index) const
Get the libMesh node index from nekRS's GLL index ordering.
Definition: NekRSMesh.h:180
NekRSMesh::buildMesh
virtual void buildMesh() override
NekRSMesh::numVerticesPerElem
const int & numVerticesPerElem() const
Get the number of vertices per element in MOOSE's representation of nekRS's mesh.
Definition: NekRSMesh.h:170
NekRSMesh::_boundary_coupling
NekBoundaryCoupling _boundary_coupling
Data structure holding mapping information for boundary coupling.
Definition: NekRSMesh.h:571
NekRSMesh::volume
const bool & volume() const
Definition: NekRSMesh.h:228
CardinalEnums.h
NekRSMesh::volumeElem
Elem * volumeElem() const
Create a new element for a volume mesh.
NekRSMesh::_nek_n_surface_elems
int _nek_n_surface_elems
Total number of surface elements in the nekRS problem.
Definition: NekRSMesh.h:464
NekRSMesh::_nek_polynomial_order
int _nek_polynomial_order
Order of the nekRS solution.
Definition: NekRSMesh.h:422
NekRSMesh::volumeCoupling
const NekVolumeCoupling & volumeCoupling() const
Definition: NekRSMesh.h:131
NekRSMesh::boundary
const std::vector< int > * boundary() const
Definition: NekRSMesh.h:222
NekRSMesh::operator=
NekRSMesh & operator=(const NekRSMesh &other_mesh)=delete
NekRSMesh::faceVertices
void faceVertices()
NekRSMesh::_phase
std::vector< int > _phase
"Phase" for each element (fluid = 0, solid = 1)
Definition: NekRSMesh.h:476
NekRSMesh::boundaryElemProcessorID
int boundaryElemProcessorID(const int elem_id)
NekRSMesh::_prev_disp_y
std::vector< double > _prev_disp_y
Definition: NekRSMesh.h:532
NekRSMesh::_solid_block_id
const unsigned int & _solid_block_id
Block ID for the solid portion of the mesh mirror.
Definition: NekRSMesh.h:419
NekRSMesh::initializeMeshParams
void initializeMeshParams()
Initialize members for the mesh and determine the GLL-to-node mapping.
NekRSMesh::numElems
const int & numElems() const
Get the number of NekRS elements we rebuild in the MOOSE mesh.
Definition: NekRSMesh.h:161
NekRSMesh::_y
std::vector< double > _y
coordinates of the current GLL points (which can move in time), for this rank
Definition: NekRSMesh.h:492
NekRSMesh::numQuadraturePoints1D
int numQuadraturePoints1D() const
NekVolumeCoupling
Definition: NekVolumeCoupling.h:29
NekRSMesh::nekPolynomialOrder
int nekPolynomialOrder() const
Definition: NekRSMesh.h:71
NekRSMesh::volumeVertices
void volumeVertices()
NekRSMesh::NekRSMesh
NekRSMesh(const InputParameters &parameters)
NekRSMesh::boundary_id
int boundary_id(const int elem_id, const int face_id)
NekRSMesh::volumeNodeIndex
int volumeNodeIndex(const int gll_index) const
Definition: NekRSMesh.h:268
NekRSMesh::nBuildPerSurfaceElem
int nBuildPerSurfaceElem() const
Definition: NekRSMesh.h:83
NekRSMesh::_n_moose_per_nek
int _n_moose_per_nek
Definition: NekRSMesh.h:452
NekRSMesh::_n_surface_elems
int _n_surface_elems
Definition: NekRSMesh.h:428
NekUtility.h
NekRSMesh::_exact
const bool & _exact
Definition: NekRSMesh.h:392
NekRSMesh::nekNumSurfaceElems
const int & nekNumSurfaceElems() const
Definition: NekRSMesh.h:192
NekRSMesh::initializePreviousDisplacements
void initializePreviousDisplacements()
Initialize previous displacement values to zero for boundary mirror-based moving mesh problems.
NekRSMesh::_scaling
const Real & _scaling
Spatial scaling factor to apply to the mesh.
Definition: NekRSMesh.h:413
NekRSMesh::nekNumVolumeElems
const int & nekNumVolumeElems() const
Definition: NekRSMesh.h:210
NekInterface.h
NekRSMesh::_n_vertices_per_volume
int _n_vertices_per_volume
Number of vertices per volume element.
Definition: NekRSMesh.h:398
NekRSMesh::_vol_node_index
std::vector< int > _vol_node_index
Mapping of volume GLL indices to MooseMesh node indices.
Definition: NekRSMesh.h:555
NekRSMesh::_n_build_per_surface_elem
int _n_build_per_surface_elem
Number of MOOSE surface elements to build per NekRS surface element.
Definition: NekRSMesh.h:431
NekRSMesh::facesOnBoundary
int facesOnBoundary(const int elem_id) const
NekRSMesh::numVerticesPerSurface
const int & numVerticesPerSurface() const
Definition: NekRSMesh.h:198
NekRSMesh::updateDisplacement
void updateDisplacement(const int e, const double *src, const field::NekWriteEnum field)
NekRSMesh::validParams
static InputParameters validParams()
NekRSMesh::printMeshInfo
virtual void printMeshInfo() const
Print diagnostic information related to the mesh.
NekRSMesh::_fluid_block_id
const unsigned int & _fluid_block_id
Block ID for the fluid portion of the mesh mirror.
Definition: NekRSMesh.h:416
NekRSMesh::_nek_n_volume_elems
int _nek_n_volume_elems
Total number of volume elements in the nekRS problem.
Definition: NekRSMesh.h:467
NekRSMesh::_corner_indices
std::vector< std::vector< int > > _corner_indices
Corner indices for GLL points of mesh mirror elements.
Definition: NekRSMesh.h:580
NekBoundaryCoupling.h
NekRSMesh::_n_volume_elems
int _n_volume_elems
Definition: NekRSMesh.h:437
NekRSMesh::nek_initial_z
const std::vector< double > & nek_initial_z() const
Definition: NekRSMesh.h:101
NekRSMesh::buildDummyMesh
virtual void buildDummyMesh()
NekRSMesh::_initial_z
std::vector< double > _initial_z
coordinates of the initial GLL points, for this rank
Definition: NekRSMesh.h:524
NekRSMesh::saveInitialVolMesh
void saveInitialVolMesh()
Save the initial volumetric mesh for volume mirror-based moving mesh problems.
NekRSMesh::storeVolumeCoupling
void storeVolumeCoupling()
Store the rank-local element and rank ownership for volume coupling.
NekRSMesh::numVerticesPerVolume
const int & numVerticesPerVolume() const
Definition: NekRSMesh.h:216
NekRSMesh::safeClone
virtual std::unique_ptr< MooseMesh > safeClone() const override
NekRSMesh::_nek_internal_mesh
mesh_t * _nek_internal_mesh
Pointer to NekRS's internal mesh data structure.
Definition: NekRSMesh.h:577
NekRSMesh::boundaryCoupling
const NekBoundaryCoupling & boundaryCoupling() const
Definition: NekRSMesh.h:125
NekRSMesh::numSurfaceElems
const int & numSurfaceElems() const
Definition: NekRSMesh.h:186
NekRSMesh::_bnd_node_index
std::vector< int > _bnd_node_index
Mapping of boundary GLL indices to MooseMesh node indices.
Definition: NekRSMesh.h:544