Grid.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef __GRID_H__
5 #define __GRID_H__
6 
8 #include "vtkSmartPointer.h" // For smart pointers
9 
10 #include <string> // for string
11 #include <vector> // for vector
12 
14 class vtkDataObject;
16 
17 namespace CamAdaptor
18 {
19 
21 {
26 };
27 
32 template <GridType gridType>
34 {
35 public:
36  Grid();
39  ~Grid();
40 
42  void Create();
43  void SetMpiRank(int rank) { this->MpiRank = rank; }
44  void SetChunkCapacity(int capacity) { this->ChunkCapacity = capacity; }
45  void SetNCells2d(int ncells) { this->NCells2d = ncells; }
46  void SetNLon(int nlon) { this->NLon = nlon; }
47  void SetNLat(int nlat) { this->NLat = nlat; }
48  void SetLev(int nlev, double* lev)
49  {
50  this->NLev = nlev;
51  if (lev)
52  {
53  this->Lev = new double[nlev];
54  std::copy(lev, lev + nlev, this->Lev);
55  }
56  }
58  void AddPointsAndCells(double lonRad, double latRad);
59 
62  void SetAttributeValue(int chunkSize, double* lonRad, double* latRad, double* psScalar,
63  double* tScalar, double* uScalar, double* vScalar);
64 
66  vtkSmartPointer<vtkUnstructuredGrid> GetGrid2d() const { return this->Grid2d; }
68  vtkSmartPointer<vtkUnstructuredGrid> GetGrid3d() const { return this->Grid3d; }
70  static bool SetToCoprocessor(vtkCPDataDescription* coprocessorData, const char* name,
72 
75  void SetLonStep(int step) { this->LonStep = step; }
76  void SetLatStep(int step) { this->LatStep = step; }
78  void SetCubeGridPoints(int ne, int np, int lonSize, double* lonRad, int latSize, double* latRad);
80 
81 private:
83  void PrintAddChunk(
84  int* nstep, int* chunkCols, double* lonRad, double* latRad, double* psScalar, double* tScalar);
85 
88 
91 
98  double LevelToRadius(double level) const;
99 
102  void GetLevMinusPlus(int levIndex, double* levMinus, double* levPlus) const;
103  void GetLatMinusPlus(int latIndex, double* latMinus, double* latPlus) const;
104  void GetLonMinusPlus(int lonIndex, double* lonMinus, double* lonPlus) const;
105 
108  void GetValueIndex(double lonRad, double latRad, std::vector<std::vector<int>>& index) const;
109 
111  void GetCellPoints(const int index[3], double cellPoints[4][3]) const;
112  void GetCellPoints(const int index[3], int level, double cell[8][3]) const;
113 
115  void GetPointIds(const int index[3], int pointIndexes[4]) const;
116  void GetPointIds(const int index[3], int level, int pointIndexes[8]) const;
117 
119  int GetCellId(const int index[3]) const;
120  int GetCellId(const int index[3], int level) const;
121 
125  size_t CubeToIndex(double side, const std::vector<double>& cubeCoordinates, double v[3],
126  std::vector<std::vector<int>>& index) const;
127 
130  void IndexToCube(const std::vector<double>& cubeCoordinates, double index[3], double v[3]) const;
131  void CubeToSpherical(double v[3], double* lonRad, double* latRad) const;
132 
135  void MinFaceIndex(int side, int index[3]) const;
136 
137  int MpiRank;
138  int ChunkCapacity;
139  int NCells2d;
140  int NLon, NLat, NLev;
141  double* Lev;
144  double Radius;
147  int Ne;
148  int Np;
150  double LonStep;
154  double LatStep;
155  class Internals;
157  Internals* Impl;
158 
160  vtkSmartPointer<vtkUnstructuredGrid> Grid2d; // the grid
161  int RankArrayIndex2d; // index of the rank array
162  int CoordArrayIndex2d; // index of the coordinates array (lon x lat)
163  int PSArrayIndex;
164 
167  int RankArrayIndex3d;
168  int CoordArrayIndex3d;
169  int TArrayIndex;
170  int UArrayIndex;
171  int VArrayIndex;
172 };
173 } // namespace CamAdaptor
174 #endif
level
void SetChunkCapacity(int capacity)
Definition: Grid.h:44
void SetLatStep(int step)
Definition: Grid.h:76
#define VTKPVADAPTORSCAM_EXPORT
side
void SetNLat(int nlat)
Definition: Grid.h:47
name
vtkSmartPointer< vtkUnstructuredGrid > GetGrid2d() const
Returns the 2D grid.
Definition: Grid.h:66
Creates and accumulates data for a 2D and a 3D grid.
Definition: Grid.h:33
vtkSmartPointer< vtkUnstructuredGrid > GetGrid3d() const
Returns the 3D grid.
Definition: Grid.h:68
void SetLev(int nlev, double *lev)
Definition: Grid.h:48
void SetMpiRank(int rank)
Definition: Grid.h:43
void SetNCells2d(int ncells)
Definition: Grid.h:45
void SetLonStep(int step)
used for the FV dynamic core only
Definition: Grid.h:75
GridType
Definition: Grid.h:20
index
This class provides the description of the data for the coprocessor pipelines.
macro step(n, desc)
void SetNLon(int nlon)
Definition: Grid.h:46