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 };
std::vector< double > _z
coordinates of the current GLL points (which can move in time), for this rank
Definition: NekRSMesh.h:500
const int & numElems() const
Get the number of NekRS elements we rebuild in the MOOSE mesh.
Definition: NekRSMesh.h:161
NekRSMesh(const InputParameters &parameters)
int nekNumQuadraturePoints1D() const
const int & numSurfaceElems() const
Definition: NekRSMesh.h:186
NekVolumeCoupling _volume_coupling
Data structure holding mapping information for volume coupling.
Definition: NekRSMesh.h:574
virtual void printMeshInfo() const
Print diagnostic information related to the mesh.
int boundaryNodeIndex(const int gll_index) const
Definition: NekRSMesh.h:261
int _nek_n_surface_elems
Total number of surface elements in the nekRS problem.
Definition: NekRSMesh.h:464
int _n_vertices_per_surface
Number of vertices per surface.
Definition: NekRSMesh.h:395
NekWriteEnum
Enumeration of possible fields to write in nekRS.
Definition: CardinalEnums.h:105
const unsigned int & _fluid_block_id
Block ID for the fluid portion of the mesh mirror.
Definition: NekRSMesh.h:416
const bool & volume() const
Definition: NekRSMesh.h:228
Elem * volumeElem() const
Create a new element for a volume mesh.
const int & numVerticesPerVolume() const
Definition: NekRSMesh.h:216
Definition: NekRSMesh.h:50
int numQuadraturePoints1D() const
virtual std::unique_ptr< MooseMesh > safeClone() const override
const NekVolumeCoupling & volumeCoupling() const
Definition: NekRSMesh.h:131
std::vector< int > _side_index
Mapping of side indices to libMesh side indices.
Definition: NekRSMesh.h:565
const NekBoundaryCoupling & boundaryCoupling() const
Definition: NekRSMesh.h:125
void updateDisplacement(const int e, const double *src, const field::NekWriteEnum field)
int _n_vertices_per_volume
Number of vertices per volume element.
Definition: NekRSMesh.h:398
std::vector< int > _vol_node_index
Mapping of volume GLL indices to MooseMesh node indices.
Definition: NekRSMesh.h:555
void initializeMeshParams()
Initialize members for the mesh and determine the GLL-to-node mapping.
void volumeVertices()
const std::vector< int > * _boundary
Boundary ID(s) through which to couple Nek to MOOSE.
Definition: NekRSMesh.h:368
int nBuildPerSurfaceElem() const
Definition: NekRSMesh.h:83
const std::vector< double > & nek_initial_z() const
Definition: NekRSMesh.h:101
int facesOnBoundary(const int elem_id) const
std::vector< double > _initial_z
coordinates of the initial GLL points, for this rank
Definition: NekRSMesh.h:524
const int & numVolumeElems() const
Definition: NekRSMesh.h:204
int(NekRSMesh::* _elem_processor_id)(const int elem_id)
Function returning the processor id which should own each element.
Definition: NekRSMesh.h:455
Definition: CardinalEnums.h:86
const int & numVerticesPerSurface() const
Definition: NekRSMesh.h:198
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
void initializePreviousDisplacements()
Initialize previous displacement values to zero for boundary mirror-based moving mesh problems.
const int & numVerticesPerElem() const
Get the number of vertices per element in MOOSE's representation of nekRS's mesh.
Definition: NekRSMesh.h:170
int _nek_polynomial_order
Order of the nekRS solution.
Definition: NekRSMesh.h:422
int nMoosePerNek() const
Definition: NekRSMesh.h:314
NekOrderEnum
Enumeration of possible surface order reconstructions for nekRS solution transfer.
Definition: CardinalEnums.h:69
const std::vector< double > & nek_initial_y() const
Definition: NekRSMesh.h:95
int boundary_id(const int elem_id, const int face_id)
std::vector< double > _prev_disp_z
Definition: NekRSMesh.h:533
int volumeElemProcessorID(const int elem_id)
std::vector< double > _prev_disp_y
Definition: NekRSMesh.h:532
void storeVolumeCoupling()
Store the rank-local element and rank ownership for volume coupling.
const std::vector< int > * boundary() const
Definition: NekRSMesh.h:222
virtual void buildMesh() override
const Real & scaling() const
Definition: NekRSMesh.h:274
void faceVertices()
void saveInitialVolMesh()
Save the initial volumetric mesh for volume mirror-based moving mesh problems.
std::vector< double > & prev_disp_y()
Definition: NekRSMesh.h:113
int _n_build_per_volume_elem
Number of MOOSE volume elements to build per NekRS volume element.
Definition: NekRSMesh.h:440
NekBoundaryCoupling _boundary_coupling
Data structure holding mapping information for boundary coupling.
Definition: NekRSMesh.h:571
int volumeNodeIndex(const int gll_index) const
Definition: NekRSMesh.h:268
std::vector< double > _initial_x
coordinates of the initial GLL points, for this rank
Definition: NekRSMesh.h:508
int _n_surface_elems
Definition: NekRSMesh.h:428
void storeBoundaryCoupling()
std::vector< double > & prev_disp_z()
Definition: NekRSMesh.h:119
int _n_moose_per_nek
Definition: NekRSMesh.h:452
virtual void extractVolumeMesh()
const unsigned int & _solid_block_id
Block ID for the solid portion of the mesh mirror.
Definition: NekRSMesh.h:419
int nBuildPerVolumeElem() const
Definition: NekRSMesh.h:77
int nekPolynomialOrder() const
Definition: NekRSMesh.h:71
NekRSMesh & operator=(const NekRSMesh &other_mesh)=delete
std::vector< std::vector< int > > _corner_indices
Corner indices for GLL points of mesh mirror elements.
Definition: NekRSMesh.h:580
std::vector< double > _y
coordinates of the current GLL points (which can move in time), for this rank
Definition: NekRSMesh.h:492
const bool & _volume
Whether nekRS is coupled through volumes to MOOSE.
Definition: NekRSMesh.h:365
Definition: NekBoundaryCoupling.h:29
std::vector< double > _initial_y
coordinates of the initial GLL points, for this rank
Definition: NekRSMesh.h:516
int _n_elems
Definition: NekRSMesh.h:446
int _n_vertices_per_elem
Number of vertices per element, which depends on whether building a boundary/volume mesh.
Definition: NekRSMesh.h:458
int _n_build_per_surface_elem
Number of MOOSE surface elements to build per NekRS surface element.
Definition: NekRSMesh.h:431
int _n_volume_elems
Definition: NekRSMesh.h:437
std::vector< double > _prev_disp_x
Definition: NekRSMesh.h:531
const order::NekOrderEnum & order() const
Definition: NekRSMesh.h:140
int boundaryElemProcessorID(const int elem_id)
virtual void addElems()
Add all the elements in the mesh to the MOOSE data structures.
const bool & _exact
Definition: NekRSMesh.h:392
static InputParameters validParams()
int _nek_n_volume_elems
Total number of volume elements in the nekRS problem.
Definition: NekRSMesh.h:467
std::vector< double > & prev_disp_x()
Definition: NekRSMesh.h:107
Elem *(NekRSMesh::* _new_elem)() const
Function pointer to the type of new element to add.
Definition: NekRSMesh.h:568
std::vector< std::vector< int > > cornerIndices() const
Definition: NekRSMesh.h:308
const int & nekNumSurfaceElems() const
Definition: NekRSMesh.h:192
mesh_t * _nek_internal_mesh
Pointer to NekRS's internal mesh data structure.
Definition: NekRSMesh.h:577
virtual void extractSurfaceMesh()
int nodeIndex(const int gll_index) const
Get the libMesh node index from nekRS's GLL index ordering.
Definition: NekRSMesh.h:180
const Real & _scaling
Spatial scaling factor to apply to the mesh.
Definition: NekRSMesh.h:413
const int & nekNumVolumeElems() const
Definition: NekRSMesh.h:210
std::vector< int > _phase
"Phase" for each element (fluid = 0, solid = 1)
Definition: NekRSMesh.h:476
const order::NekOrderEnum _order
Order of the surface interpolation between nekRS and MOOSE.
Definition: NekRSMesh.h:380
Definition: NekVolumeCoupling.h:29
const std::vector< double > & nek_initial_x() const
Definition: NekRSMesh.h:89
std::vector< int > _bnd_node_index
Mapping of boundary GLL indices to MooseMesh node indices.
Definition: NekRSMesh.h:544
virtual void buildDummyMesh()
bool exactMirror() const
Definition: NekRSMesh.h:302
Elem * boundaryElem() const
Create a new element for a boundary mesh.
std::vector< double > _x
coordinates of the current GLL points (which can move in time), for this rank
Definition: NekRSMesh.h:484