VAPOR3 3.9.4
CurvilinearGrid.h
Go to the documentation of this file.
1#ifndef _CurvilinearGrid_
2#define _CurvilinearGrid_
3#include <vapor/common.h>
4#include <vapor/Grid.h>
5#include <vapor/RegularGrid.h>
7
8namespace VAPoR {
33//
35public:
70 //
71 CurvilinearGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const RegularGrid &xrg, const RegularGrid &yrg, const std::vector<double> &zcoords,
72 std::shared_ptr<const QuadTreeRectangleP> qtr);
73 CurvilinearGrid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const std::vector<float *> &blks, const RegularGrid &xrg, const RegularGrid &yrg,
74 const std::vector<double> &zcoords, std::shared_ptr<const QuadTreeRectangleP> qtr);
75
111 //
112 CurvilinearGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const RegularGrid &xrg, const RegularGrid &yrg, const RegularGrid &zrg,
113 std::shared_ptr<const QuadTreeRectangleP> qtr);
114 CurvilinearGrid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const std::vector<float *> &blks, const RegularGrid &xrg, const RegularGrid &yrg, const RegularGrid &zrg,
115 std::shared_ptr<const QuadTreeRectangleP> qtr);
116
147 //
148 CurvilinearGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const RegularGrid &xrg, const RegularGrid &yrg, std::shared_ptr<const QuadTreeRectangleP> qtr);
149 CurvilinearGrid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const std::vector<float *> &blks, const RegularGrid &xrg, const RegularGrid &yrg,
150 std::shared_ptr<const QuadTreeRectangleP> qtr);
151
152 CurvilinearGrid() = default;
154 {
155 if (_qtr) {
156 _qtr = nullptr; // qtr is a C++ shared pointer
157 }
158 }
159
160 std::shared_ptr<const QuadTreeRectangleP> GetQuadTreeRectangle() const { return (_qtr); }
161
162 static std::string GetClassType() { return ("Curvilinear"); }
163 std::string GetType() const override { return (GetClassType()); }
164
165 virtual DimsType GetCoordDimensions(size_t dim) const override;
166
167 virtual size_t GetGeometryDim() const override { return (GetTopologyDim()); };
168
169 // \copydoc GetGrid::GetBoundingBox()
170 //
171 virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override;
172
173 // \copydoc GetGrid::GetUserCoordinates()
174 //
175 virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override;
176
179 virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override;
180
181 // \copydoc GetGrid::InsideGrid()
182 //
183 virtual bool InsideGrid(const CoordType &coords) const override;
184
190 const RegularGrid &GetXRG() const { return (_xrg); };
191
197 const RegularGrid &GetYRG() const { return (_yrg); };
198
204 const std::vector<double> &GetZCoords() const { return (_zcoords); };
205
207 public:
208 ConstCoordItrCG(const CurvilinearGrid *cg, bool begin);
210
212 virtual ~ConstCoordItrCG() {}
213
214 virtual void next();
215 virtual void next(const long &offset);
216 virtual ConstCoordType &deref() const { return (_coords); }
217 virtual const void * address() const { return this; };
218
219 virtual bool equal(const void *rhs) const
220 {
221 const ConstCoordItrCG *itrptr = static_cast<const ConstCoordItrCG *>(rhs);
222
223 return (_index == itrptr->_index);
224 }
225
226 virtual std::unique_ptr<ConstCoordItrAbstract> clone() const { return std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrCG(*this)); };
227
228 private:
229 const CurvilinearGrid *_cg;
230 DimsType _index;
231 CoordType _coords;
232 ConstIterator _xCoordItr;
233 ConstIterator _yCoordItr;
234 ConstIterator _zCoordItr;
235 bool _terrainFollowing;
236 };
237
238 virtual ConstCoordItr ConstCoordBegin() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrCG(this, true))); }
239 virtual ConstCoordItr ConstCoordEnd() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrCG(this, false))); }
240
241protected:
242 virtual float GetValueNearestNeighbor(const CoordType &coords) const override;
243
244 virtual float GetValueLinear(const CoordType &coords) const override;
245
246 // \copydoc GetGrid::GetUserExtents()
247 //
248 virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override;
249
250private:
251 std::vector<double> _zcoords;
252 CoordType _minu = {{0.0, 0.0, 0.0}};
253 CoordType _maxu = {{0.0, 0.0, 0.0}};
254 RegularGrid _xrg;
255 RegularGrid _yrg;
256 RegularGrid _zrg;
257 bool _terrainFollowing;
258 std::shared_ptr<const QuadTreeRectangleP> _qtr;
259
260 void _curvilinearGrid(const RegularGrid &xrg, const RegularGrid &yrg, const RegularGrid &zrg, const std::vector<double> &zcoords, std::shared_ptr<const QuadTreeRectangleP> qtr);
261
262 bool _insideFace(const DimsType &face, double pt[2], double lambda[4], std::vector<DimsType> &nodes) const;
263
264 bool _insideGrid(double x, double y, double z, size_t &i, size_t &j, size_t &k, double lambda[4], double zwgt[2]) const;
265
266 void _getIndicesHelper(const std::vector<double> &coords, std::vector<size_t> &indices) const;
267
268 bool _insideGridHelperStretched(double z, size_t &k, double zwgt[2]) const;
269
270 bool _insideGridHelperTerrain(double x, double y, double z, const size_t &i, const size_t &j, size_t &k, double zwgt[2]) const;
271
272 std::shared_ptr<QuadTreeRectangleP> _makeQuadTreeRectangle() const;
273};
274}; // namespace VAPoR
275#endif
virtual bool equal(const void *rhs) const
ConstCoordItrCG(const ConstCoordItrCG &rhs)
ConstCoordItrCG(const CurvilinearGrid *cg, bool begin)
virtual ConstCoordType & deref() const
virtual std::unique_ptr< ConstCoordItrAbstract > clone() const
virtual const void * address() const
virtual void next(const long &offset)
This class implements a 2D or 3D curvilinear grid.
const RegularGrid & GetXRG() const
CurvilinearGrid(const DimsType &dims, const DimsType &bs, const std::vector< float * > &blks, const RegularGrid &xrg, const RegularGrid &yrg, const RegularGrid &zrg, std::shared_ptr< const QuadTreeRectangleP > qtr)
std::shared_ptr< const QuadTreeRectangleP > GetQuadTreeRectangle() const
virtual bool InsideGrid(const CoordType &coords) const override
const RegularGrid & GetYRG() const
virtual DimsType GetCoordDimensions(size_t dim) const override
CurvilinearGrid(const std::vector< size_t > &dims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const RegularGrid &xrg, const RegularGrid &yrg, const std::vector< double > &zcoords, std::shared_ptr< const QuadTreeRectangleP > qtr)
CurvilinearGrid(const std::vector< size_t > &dims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const RegularGrid &xrg, const RegularGrid &yrg, const RegularGrid &zrg, std::shared_ptr< const QuadTreeRectangleP > qtr)
virtual size_t GetGeometryDim() const override
virtual float GetValueNearestNeighbor(const CoordType &coords) const override
std::string GetType() const override
virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override
const std::vector< double > & GetZCoords() const
virtual float GetValueLinear(const CoordType &coords) const override
virtual ConstCoordItr ConstCoordEnd() const override
virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
CurvilinearGrid(const DimsType &dims, const DimsType &bs, const std::vector< float * > &blks, const RegularGrid &xrg, const RegularGrid &yrg, std::shared_ptr< const QuadTreeRectangleP > qtr)
virtual ConstCoordItr ConstCoordBegin() const override
Return constant grid coordinate iterator.
CurvilinearGrid(const DimsType &dims, const DimsType &bs, const std::vector< float * > &blks, const RegularGrid &xrg, const RegularGrid &yrg, const std::vector< double > &zcoords, std::shared_ptr< const QuadTreeRectangleP > qtr)
CurvilinearGrid(const std::vector< size_t > &dims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const RegularGrid &xrg, const RegularGrid &yrg, std::shared_ptr< const QuadTreeRectangleP > qtr)
static std::string GetClassType()
virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override
virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override
const CoordType ConstCoordType
Definition: Grid.h:936
This class implements a 2D or 3D regular grid.
Definition: RegularGrid.h:25
Abstract base class for a 2D or 3D structured grid.
#define VDF_API
Definition: common.h:73
std::array< double, 3 > CoordType
Type for specifying floating point coordinates.
Definition: Grid.h:23
std::array< size_t, 3 > DimsType
Type for specifying integer indices.
Definition: Grid.h:26