Grid.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: Grid.h
5 
6  Copyright (c) Kitware, Inc.
7  All rights reserved.
8  See Copyright.txt or http://www.paraview.org/HTML/Copyright.html for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #ifndef __GRID_H__
17 #define __GRID_H__
18 
19 #include "vtkPVAdaptorsCamModule.h"
20 #include "vtkSmartPointer.h" // For smart pointers
21 
22 #include <string> // for string
23 #include <vector> // for vector
24 
26 class vtkDataObject;
28 
29 namespace CamAdaptor
30 {
31 
33 {
38 };
39 
44 template <GridType gridType>
46 {
47 public:
48  Grid();
51  ~Grid();
52 
54  void Create();
55  void SetMpiRank(int rank) { this->MpiRank = rank; }
56  void SetChunkCapacity(int capacity) { this->ChunkCapacity = capacity; }
57  void SetNCells2d(int ncells) { this->NCells2d = ncells; }
58  void SetNLon(int nlon) { this->NLon = nlon; }
59  void SetNLat(int nlat) { this->NLat = nlat; }
60  void SetLev(int nlev, double* lev)
61  {
62  this->NLev = nlev;
63  if (lev)
64  {
65  this->Lev = new double[nlev];
66  std::copy(lev, lev + nlev, this->Lev);
67  }
68  }
70  void AddPointsAndCells(double lonRad, double latRad);
71 
74  void SetAttributeValue(int chunkSize, double* lonRad, double* latRad, double* psScalar,
75  double* tScalar, double* uScalar, double* vScalar);
76 
78  vtkSmartPointer<vtkUnstructuredGrid> GetGrid2d() const { return this->Grid2d; }
80  vtkSmartPointer<vtkUnstructuredGrid> GetGrid3d() const { return this->Grid3d; }
82  static bool SetToCoprocessor(vtkCPDataDescription* coprocessorData, const char* name,
84 
87  void SetLonStep(int step) { this->LonStep = step; }
88  void SetLatStep(int step) { this->LatStep = step; }
90  void SetCubeGridPoints(int ne, int np, int lonSize, double* lonRad, int latSize, double* latRad);
92 
93 private:
95  void PrintAddChunk(
96  int* nstep, int* chunkCols, double* lonRad, double* latRad, double* psScalar, double* tScalar);
97 
100 
103 
110  double LevelToRadius(double level) const;
111 
114  void GetLevMinusPlus(int levIndex, double* levMinus, double* levPlus) const;
115  void GetLatMinusPlus(int latIndex, double* latMinus, double* latPlus) const;
116  void GetLonMinusPlus(int lonIndex, double* lonMinus, double* lonPlus) const;
117 
120  void GetValueIndex(double lonRad, double latRad, std::vector<std::vector<int> >& index) const;
121 
123  void GetCellPoints(const int index[3], double cellPoints[4][3]) const;
124  void GetCellPoints(const int index[3], int level, double cell[8][3]) const;
125 
127  void GetPointIds(const int index[3], int pointIndexes[4]) const;
128  void GetPointIds(const int index[3], int level, int pointIndexes[8]) const;
129 
131  int GetCellId(const int index[3]) const;
132  int GetCellId(const int index[3], int level) const;
133 
137  size_t CubeToIndex(double side, const std::vector<double>& cubeCoordinates, double v[3],
138  std::vector<std::vector<int> >& index) const;
139 
142  void IndexToCube(const std::vector<double>& cubeCoordinates, double index[3], double v[3]) const;
143  void CubeToSpherical(double v[3], double* lonRad, double* latRad) const;
144 
147  void MinFaceIndex(int side, int index[3]) const;
148 
149 private:
150  int MpiRank;
151  int ChunkCapacity;
152  int NCells2d;
153  int NLon, NLat, NLev;
154  double* Lev;
157  double Radius;
160  int Ne;
161  int Np;
163  double LonStep;
167  double LatStep;
168  class Internals;
170  Internals* Impl;
171 
173  vtkSmartPointer<vtkUnstructuredGrid> Grid2d; // the grid
174  int RankArrayIndex2d; // index of the rank array
175  int CoordArrayIndex2d; // index of the coordinates array (lon x lat)
176  int PSArrayIndex;
177 
180  int RankArrayIndex3d;
181  int CoordArrayIndex3d;
182  int TArrayIndex;
183  int UArrayIndex;
184  int VArrayIndex;
185 };
186 } // namespace CamAdaptor
187 #endif
level
void SetChunkCapacity(int capacity)
Definition: Grid.h:56
void SetLatStep(int step)
Definition: Grid.h:88
#define VTKPVADAPTORSCAM_EXPORT
side
void SetNLat(int nlat)
Definition: Grid.h:59
name
vtkSmartPointer< vtkUnstructuredGrid > GetGrid2d() const
Returns the 2D grid.
Definition: Grid.h:78
Creates and accumulates data for a 2D and a 3D grid.
Definition: Grid.h:45
vtkSmartPointer< vtkUnstructuredGrid > GetGrid3d() const
Returns the 3D grid.
Definition: Grid.h:80
void SetLev(int nlev, double *lev)
Definition: Grid.h:60
void SetMpiRank(int rank)
Definition: Grid.h:55
void SetNCells2d(int ncells)
Definition: Grid.h:57
void SetLonStep(int step)
used for the FV dynamic core only
Definition: Grid.h:87
GridType
Definition: Grid.h:32
index
This class provides the description of the data for the coprocessor pipelines.
macro step(n, desc)
void SetNLon(int nlon)
Definition: Grid.h:58