Jet  v1.3.3
collocated_vector_grid3.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_COLLOCATED_VECTOR_GRID3_H_
8 #define INCLUDE_JET_COLLOCATED_VECTOR_GRID3_H_
9 
10 #include <jet/array3.h>
11 #include <jet/array_samplers3.h>
12 #include <jet/vector_grid3.h>
13 #include <vector>
14 
15 namespace jet {
16 
19  public:
22 
25 
27  virtual Size3 dataSize() const = 0;
28 
35  virtual Vector3D dataOrigin() const = 0;
36 
38  const Vector3D& operator()(size_t i, size_t j, size_t k) const;
39 
41  Vector3D& operator()(size_t i, size_t j, size_t k);
42 
44  double divergenceAtDataPoint(size_t i, size_t j, size_t k) const;
45 
47  Vector3D curlAtDataPoint(size_t i, size_t j, size_t k) const;
48 
51 
54 
57 
66  const std::function<void(size_t, size_t, size_t)>& func) const;
67 
78  const std::function<void(size_t, size_t, size_t)>& func) const;
79 
80  // VectorField3 implementations
81 
83  Vector3D sample(const Vector3D& x) const override;
84 
86  double divergence(const Vector3D& x) const override;
87 
89  Vector3D curl(const Vector3D& x) const override;
90 
97  std::function<Vector3D(const Vector3D&)> sampler() const override;
98 
99  protected:
102 
105 
107  void getData(std::vector<double>* data) const override;
108 
110  void setData(const std::vector<double>& data) override;
111 
112  private:
113  Array3<Vector3D> _data;
115  std::function<Vector3D(const Vector3D&)> _sampler;
116 
117  void onResize(
118  const Size3& resolution,
119  const Vector3D& gridSpacing,
120  const Vector3D& origin,
121  const Vector3D& initialValue) final;
122 
123  void resetSampler();
124 };
125 
127 typedef std::shared_ptr<CollocatedVectorGrid3> CollocatedVectorGrid3Ptr;
128 
129 } // namespace jet
130 
131 #endif // INCLUDE_JET_COLLOCATED_VECTOR_GRID3_H_
jet::ConstArrayAccessor< T, 3 >
3-D read-only array accessor class.
Definition: array_accessor3.h:270
jet::CollocatedVectorGrid3::parallelForEachDataPointIndex
void parallelForEachDataPointIndex(const std::function< void(size_t, size_t, size_t)> &func) const
Invokes the given function func for each data point parallelly.
jet::CollocatedVectorGrid3::CollocatedVectorGrid3
CollocatedVectorGrid3()
Constructs an empty grid.
array_samplers3.h
jet::CollocatedVectorGrid3::dataAccessor
VectorDataAccessor dataAccessor()
Returns the read-write data array accessor.
jet::CollocatedVectorGrid3::constDataAccessor
ConstVectorDataAccessor constDataAccessor() const
Returns the read-only data array accessor.
jet::CollocatedVectorGrid3::setData
void setData(const std::vector< double > &data) override
Sets the data from a continuous linear array.
jet::CollocatedVectorGrid3::sample
Vector3D sample(const Vector3D &x) const override
Returns sampled value at given position x.
jet::CollocatedVectorGrid3::dataPosition
DataPositionFunc dataPosition() const
Returns the function that maps data point to its position.
jet::CollocatedVectorGrid3::dataOrigin
virtual Vector3D dataOrigin() const =0
Returns data position for the grid point at (0, 0, 0).
jet::CollocatedVectorGrid3
Abstract base class for 3-D collocated vector grid structure.
Definition: collocated_vector_grid3.h:18
jet::CollocatedVectorGrid3::swapCollocatedVectorGrid
void swapCollocatedVectorGrid(CollocatedVectorGrid3 *other)
Swaps the data storage and predefined samplers with given grid.
jet::CollocatedVectorGrid3::~CollocatedVectorGrid3
virtual ~CollocatedVectorGrid3()
Default destructor.
jet::CollocatedVectorGrid3::dataSize
virtual Size3 dataSize() const =0
Returns the actual data point size.
jet::CollocatedVectorGrid3::curl
Vector3D curl(const Vector3D &x) const override
Returns curl at given position x.
jet
Definition: advection_solver2.h:18
jet::LinearArraySampler< T, R, 3 >
2-D linear array sampler class.
Definition: array_samplers3.h:77
jet::Grid3::origin
const Vector3D & origin() const
Returns the grid origin.
jet::Grid3::resolution
const Size3 & resolution() const
Returns the grid resolution.
jet::CollocatedVectorGrid3::divergenceAtDataPoint
double divergenceAtDataPoint(size_t i, size_t j, size_t k) const
Returns divergence at data point location.
jet::CollocatedVectorGrid3::operator()
Vector3D & operator()(size_t i, size_t j, size_t k)
Returns the grid data at given data point.
jet::CollocatedVectorGrid3::setCollocatedVectorGrid
void setCollocatedVectorGrid(const CollocatedVectorGrid3 &other)
Sets the data storage and predefined samplers with given grid.
jet::Grid3::gridSpacing
const Vector3D & gridSpacing() const
Returns the grid spacing.
jet::Size3
3-D size class.
Definition: size3.h:19
array3.h
jet::VectorGrid3
Abstract base class for 3-D vector grid structure.
Definition: vector_grid3.h:19
jet::CollocatedVectorGrid3::divergence
double divergence(const Vector3D &x) const override
Returns divergence at given position x.
jet::ArrayAccessor< T, 3 >
3-D array accessor class.
Definition: array_accessor3.h:31
jet::Grid3::DataPositionFunc
std::function< Vector3D(size_t, size_t, size_t)> DataPositionFunc
Function type for mapping data index to actual position.
Definition: grid3.h:33
jet::CollocatedVectorGrid3::sampler
std::function< Vector3D(const Vector3D &)> sampler() const override
Returns the sampler function.
jet::Vector3D
Vector3< double > Vector3D
Double-type 3D vector.
Definition: vector3.h:349
jet::CollocatedVectorGrid3::curlAtDataPoint
Vector3D curlAtDataPoint(size_t i, size_t j, size_t k) const
Returns curl at data point location.
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::CollocatedVectorGrid3Ptr
std::shared_ptr< CollocatedVectorGrid3 > CollocatedVectorGrid3Ptr
Shared pointer for the CollocatedVectorGrid3 type.
Definition: collocated_vector_grid3.h:127
vector_grid3.h
jet::CollocatedVectorGrid3::forEachDataPointIndex
void forEachDataPointIndex(const std::function< void(size_t, size_t, size_t)> &func) const
Invokes the given function func for each data point.
jet::Array< T, 3 >
3-D array class.
Definition: array3.h:43
jet::CollocatedVectorGrid3::getData
void getData(std::vector< double > *data) const override
Fetches the data into a continuous linear array.
jet::CollocatedVectorGrid3::operator()
const Vector3D & operator()(size_t i, size_t j, size_t k) const
Returns the grid data at given data point.