VAPOR3 3.9.4
UnstructuredGrid2D.h
Go to the documentation of this file.
1#ifndef _UnstructuredGrid2D_
2#define _UnstructuredGrid2D_
3
4#include <ostream>
5#include <vector>
6#include <memory>
7#include <vapor/common.h>
11
12#ifdef WIN32
13 #pragma warning(disable : 4661 4251) // needed for template class
14#endif
15
16namespace VAPoR {
17
22//
24public:
27 //
28 UnstructuredGrid2D(const DimsType &vertexDims, const DimsType &faceDims, const DimsType &edgeDims, const DimsType &bs, const std::vector<float *> &blks, const int *vertexOnFace,
29 const int *faceOnVertex, const int *faceOnFace,
30 Location location, // node,face, edge
31 size_t maxVertexPerFace, size_t maxFacePerVertex, long nodeOffset, long cellOffset, const UnstructuredGridCoordless &xug, const UnstructuredGridCoordless &yug,
32 const UnstructuredGridCoordless &zug, std::shared_ptr<const QuadTreeRectangleP> qtr);
33
34 UnstructuredGrid2D(const std::vector<size_t> &vertexDims, const std::vector<size_t> &faceDims, const std::vector<size_t> &edgeDims, const std::vector<size_t> &bs, const std::vector<float *> &blks,
35 const int *vertexOnFace, const int *faceOnVertex, const int *faceOnFace,
36 Location location, // node,face, edge
37 size_t maxVertexPerFace, size_t maxFacePerVertex, long nodeOffset, long cellOffset, const UnstructuredGridCoordless &xug, const UnstructuredGridCoordless &yug,
38 const UnstructuredGridCoordless &zug, std::shared_ptr<const QuadTreeRectangleP> qtr);
39
40 UnstructuredGrid2D() = default;
42 {
43 if (_qtr) _qtr = nullptr;
44 }
45
46 std::shared_ptr<const QuadTreeRectangleP> GetQuadTreeRectangle() const { return (_qtr); }
47
48 virtual DimsType GetCoordDimensions(size_t dim) const override;
49
50 virtual size_t GetGeometryDim() const override;
51
52 static std::string GetClassType() { return ("Unstructured2D"); }
53 std::string GetType() const override { return (GetClassType()); }
54
55 virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override;
56
57 bool GetEnclosingRegion(const CoordType &minu, const CoordType &maxu, DimsType &min, DimsType &max) const override;
58
59 virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override;
60
61 bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
62 {
63 std::vector<double> lambda;
64 std::vector<std::vector<size_t>> nodes;
65 return (GetIndicesCell(coords, indices, nodes, lambda));
66 }
67 // For grandparent inheritance of
68 // Grid::GetIndicesCell(const double coords[3], size_t indices[3])
69 //
70 using Grid::GetIndicesCell;
71
78 bool GetIndicesCell(const CoordType &coords, DimsType &indices, std::vector<std::vector<size_t>> &nodes, std::vector<double> &lambda) const;
79
80 bool InsideGrid(const CoordType &coords) const override;
81
82 float GetValueNearestNeighbor(const CoordType &coords) const override;
83
84 float GetValueLinear(const CoordType &coords) const override;
85
87 //
88 // Iterators
89 //
91
93 public:
94 ConstCoordItrU2D(const UnstructuredGrid2D *ug, bool begin);
96
98 virtual ~ConstCoordItrU2D() {}
99
100 virtual void next();
101 virtual void next(const long &offset);
102 virtual ConstCoordType &deref() const { return (_coords); }
103 virtual const void * address() const { return this; };
104
105 virtual bool equal(const void *rhs) const
106 {
107 const ConstCoordItrU2D *itrptr = static_cast<const ConstCoordItrU2D *>(rhs);
108
109 return (_xCoordItr == itrptr->_xCoordItr && _yCoordItr == itrptr->_yCoordItr && _zCoordItr == itrptr->_zCoordItr);
110 }
111
112 virtual std::unique_ptr<ConstCoordItrAbstract> clone() const { return std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrU2D(*this)); };
113
114 private:
115 size_t _ncoords;
116 ConstIterator _xCoordItr;
117 ConstIterator _yCoordItr;
118 ConstIterator _zCoordItr;
119 CoordType _coords;
120 };
121
122 virtual ConstCoordItr ConstCoordBegin() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrU2D(this, true))); }
123 virtual ConstCoordItr ConstCoordEnd() const override { return ConstCoordItr(std::unique_ptr<ConstCoordItrAbstract>(new ConstCoordItrU2D(this, false))); }
124
125 VDF_API friend std::ostream &operator<<(std::ostream &o, const UnstructuredGrid2D &sg);
126
127protected:
128 virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override;
129
130private:
134 std::shared_ptr<const QuadTreeRectangleP> _qtr;
135
136 bool _insideGrid(const CoordType &coords, size_t &face, std::vector<size_t> &nodes, double *lambda, int &nlambda) const;
137
138 bool _insideGridNodeCentered(const CoordType &coords, size_t &face, std::vector<size_t> &nodes, double *lambda, int &nlambda) const;
139
140 bool _insideGridFaceCentered(const CoordType &coords, size_t &face, std::vector<size_t> &nodes, double *lambda, int &nlambda) const;
141
142 bool _pointInsideBoundingRectangle(const double pt[], const double verts[], int n) const;
143
144 bool _insideFace(size_t face, double pt[2], std::vector<size_t> &node_indices, double *lambda, int &nlambda) const;
145
146 std::shared_ptr<QuadTreeRectangleP> _makeQuadTreeRectangle() const;
147};
148}; // namespace VAPoR
149
150#endif
const CoordType ConstCoordType
Definition: Grid.h:936
virtual void next(const long &offset)
virtual ConstCoordType & deref() const
virtual std::unique_ptr< ConstCoordItrAbstract > clone() const
ConstCoordItrU2D(const UnstructuredGrid2D *ug, bool begin)
virtual bool equal(const void *rhs) const
ConstCoordItrU2D(const ConstCoordItrU2D &rhs)
class for a 2D unstructured grid.
std::shared_ptr< const QuadTreeRectangleP > GetQuadTreeRectangle() const
virtual void GetUserExtentsHelper(CoordType &minu, CoordType &maxu) const override
virtual void GetBoundingBox(const DimsType &min, const DimsType &max, CoordType &minu, CoordType &maxu) const override
virtual ConstCoordItr ConstCoordBegin() const override
Return constant grid coordinate iterator.
float GetValueNearestNeighbor(const CoordType &coords) const override
virtual void GetUserCoordinates(const DimsType &indices, CoordType &coords) const override
bool GetIndicesCell(const CoordType &coords, DimsType &indices, std::vector< std::vector< size_t > > &nodes, std::vector< double > &lambda) const
bool InsideGrid(const CoordType &coords) const override
bool GetEnclosingRegion(const CoordType &minu, const CoordType &maxu, DimsType &min, DimsType &max) const override
virtual ConstCoordItr ConstCoordEnd() const override
bool GetIndicesCell(const CoordType &coords, DimsType &indices) const override
UnstructuredGrid2D(const std::vector< size_t > &vertexDims, const std::vector< size_t > &faceDims, const std::vector< size_t > &edgeDims, const std::vector< size_t > &bs, const std::vector< float * > &blks, const int *vertexOnFace, const int *faceOnVertex, const int *faceOnFace, Location location, size_t maxVertexPerFace, size_t maxFacePerVertex, long nodeOffset, long cellOffset, const UnstructuredGridCoordless &xug, const UnstructuredGridCoordless &yug, const UnstructuredGridCoordless &zug, std::shared_ptr< const QuadTreeRectangleP > qtr)
UnstructuredGrid2D(const DimsType &vertexDims, const DimsType &faceDims, const DimsType &edgeDims, const DimsType &bs, const std::vector< float * > &blks, const int *vertexOnFace, const int *faceOnVertex, const int *faceOnFace, Location location, size_t maxVertexPerFace, size_t maxFacePerVertex, long nodeOffset, long cellOffset, const UnstructuredGridCoordless &xug, const UnstructuredGridCoordless &yug, const UnstructuredGridCoordless &zug, std::shared_ptr< const QuadTreeRectangleP > qtr)
virtual size_t GetGeometryDim() const override
std::string GetType() const override
virtual DimsType GetCoordDimensions(size_t dim) const override
VDF_API friend std::ostream & operator<<(std::ostream &o, const UnstructuredGrid2D &sg)
float GetValueLinear(const CoordType &coords) const override
static std::string GetClassType()
class for a 2D unstructured grid.
Abstract base class for a 2D or 3D unstructured 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