VAPOR3 3.9.4
LayeredGrid.h
Go to the documentation of this file.
1#ifndef _LayeredGrid_
2#define _LayeredGrid_
3#include <vapor/common.h>
4#include "RegularGrid.h"
5#include "StretchedGrid.h"
6
7namespace VAPoR {
8
26//
28public:
46 LayeredGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const std::vector<double> &xcoords, const std::vector<double> &ycoords, const RegularGrid &rg);
47 LayeredGrid(const std::vector<size_t> &dims, const std::vector<size_t> &bs, const std::vector<float *> &blks, const std::vector<double> &xcoords, const std::vector<double> &ycoords,
48 const RegularGrid &rg);
49
50 LayeredGrid() = default;
51 virtual ~LayeredGrid() = default;
52
53 virtual size_t GetGeometryDim() const override { return (3); }
54
55 virtual DimsType GetCoordDimensions(size_t dim) const override;
56
57 static std::string GetClassType() { return ("Layered"); }
58 std::string GetType() const override { return (GetClassType()); }
59
62 float GetValue(const CoordType &coords) const override;
63
65 //
66 virtual int GetInterpolationOrder() const override { return _interpolationOrder; };
67
80 virtual void SetInterpolationOrder(int order) override;
81
84 virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override;
85
88 virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override;
89
90 // For grandparent inheritance of
91 // Grid::GetUserCoordinates(const size_t indices[], double coords[])
92 //
93 using Grid::GetUserCoordinates;
94
97 virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override;
98
99 // For grandparent inheritance of
100 // Grid::GetIndicesCell(const double coords[3], size_t indices[3])
101 //
102 using Grid::GetIndicesCell;
103
106 bool InsideGrid(const CoordType &coords) const override;
107
112 //
113 virtual void SetPeriodic(const std::vector<bool> &periodic) override
114 {
115 VAssert(periodic.size() == 3);
116 std::vector<bool> myPeriodic = periodic;
117 myPeriodic[2] = false;
118 Grid::SetPeriodic(myPeriodic);
119 }
120
124 const RegularGrid &GetZRG() const { return (_zrg); };
125
127 public:
128 ConstCoordItrLayered(const LayeredGrid *rg, bool begin);
130
133
134 virtual void next();
135 virtual void next(const long &offset);
136 virtual ConstCoordType &deref() const { return (_coords); }
137 virtual const void * address() const { return this; };
138
139 virtual bool equal(const void *rhs) const
140 {
141 const ConstCoordItrLayered *itrptr = static_cast<const ConstCoordItrLayered *>(rhs);
142
143 return (_zCoordItr == itrptr->_zCoordItr);
144 }
145
146 virtual std::unique_ptr<ConstCoordItrAbstract> clone() const { return std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrLayered(*this)); };
147
148 private:
149 const LayeredGrid * _lg;
150 size_t _nElements2D;
151 CoordType _coords;
152 size_t _index2D;
153 ConstIterator _zCoordItr;
155 };
156
157 virtual ConstCoordItr ConstCoordBegin() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrLayered(this, true))); }
158 virtual ConstCoordItr ConstCoordEnd() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrLayered(this, false))); }
159
160protected:
163 virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override;
164
165private:
166 StretchedGrid _sg2d; // horizontal coordinates maintained in stretched grid
167 RegularGrid _zrg; // vertical coords are the values of a regular grid
168 std::vector<double> _xcoords;
169 std::vector<double> _ycoords;
170 CoordType _minu = {{0.0, 0.0, 0.0}};
171 CoordType _maxu = {{0.0, 0.0, 0.0}};
172 int _interpolationOrder;
173
174 void _layeredGrid(const DimsType &dims, const DimsType &bs, const std::vector<float *> &blks, const std::vector<double> &xcoords, const std::vector<double> &ycoords, const RegularGrid &rg);
175
176 virtual float GetValueNearestNeighbor(const CoordType &coords) const override;
177
178 virtual float GetValueLinear(const CoordType &coords) const override;
179
192 //
193 void _getBilinearWeights(const double coords[3], double &iwgt, double &jwgt) const;
194
206
207 double _bilinearElevation(size_t i0, size_t i1, size_t j0, size_t j1, size_t k0, double iwgt, double jwgt) const;
208
226 double _bilinearInterpolation(size_t i0, size_t i1, size_t j0, size_t j1, size_t k0, double iwgt, double jwgt) const;
227
247 float _getValueQuadratic(const double coords[3]) const;
248
260 double _verticalLinearInterpolation(double x, double y, double z) const;
261
262 double _interpolateVaryingCoord(size_t i0, size_t j0, size_t k0, double x, double y) const;
263
264 bool _insideGrid(const CoordType &coords, DimsType &indices, double wgts[3]) const;
265};
266}; // namespace VAPoR
267#endif
#define VAssert(expr)
Definition: VAssert.h:9
const CoordType ConstCoordType
Definition: Grid.h:936
virtual void next(const long &offset)
virtual ConstCoordType & deref() const
Definition: LayeredGrid.h:136
ConstCoordItrLayered(const LayeredGrid *rg, bool begin)
virtual std::unique_ptr< ConstCoordItrAbstract > clone() const
Definition: LayeredGrid.h:146
ConstCoordItrLayered(const ConstCoordItrLayered &rhs)
virtual const void * address() const
Definition: LayeredGrid.h:137
virtual bool equal(const void *rhs) const
Definition: LayeredGrid.h:139
This class implements a 2D or 3D layered grid.
Definition: LayeredGrid.h:27
virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override
virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override
bool InsideGrid(const CoordType &coords) const override
float GetValue(const CoordType &coords) const override
LayeredGrid(const DimsType &dims, const DimsType &bs, const std::vector< float * > &blks, const std::vector< double > &xcoords, const std::vector< double > &ycoords, const RegularGrid &rg)
virtual size_t GetGeometryDim() const override
Definition: LayeredGrid.h:53
virtual ~LayeredGrid()=default
static std::string GetClassType()
Definition: LayeredGrid.h:57
virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override
const RegularGrid & GetZRG() const
Definition: LayeredGrid.h:124
virtual ConstCoordItr ConstCoordBegin() const override
Return constant grid coordinate iterator.
Definition: LayeredGrid.h:157
virtual void SetPeriodic(const std::vector< bool > &periodic) override
Definition: LayeredGrid.h:113
virtual DimsType GetCoordDimensions(size_t dim) const override
virtual void SetInterpolationOrder(int order) override
std::string GetType() const override
Definition: LayeredGrid.h:58
LayeredGrid()=default
LayeredGrid(const std::vector< size_t > &dims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const std::vector< double > &xcoords, const std::vector< double > &ycoords, const RegularGrid &rg)
virtual ConstCoordItr ConstCoordEnd() const override
Definition: LayeredGrid.h:158
virtual bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
virtual int GetInterpolationOrder() const override
Definition: LayeredGrid.h:66
This class implements a 2D or 3D regular grid.
Definition: RegularGrid.h:25
This class implements a 2D or 3D stretched grid.
Definition: StretchedGrid.h:26
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