Jet  v1.3.3
vertex_centered_vector_grid2.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_VERTEX_CENTERED_VECTOR_GRID2_H_
8 #define INCLUDE_JET_VERTEX_CENTERED_VECTOR_GRID2_H_
9 
11 #include <utility> // just make cpplint happy..
12 
13 namespace jet {
14 
24  public:
26 
27  class Builder;
28 
31 
35  size_t resolutionX,
36  size_t resolutionY,
37  double gridSpacingX = 1.0,
38  double gridSpacingY = 1.0,
39  double originX = 0.0,
40  double originY = 0.0,
41  double initialValueU = 0.0,
42  double initialValueV = 0.0);
43 
47  const Size2& resolution,
48  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
49  const Vector2D& origin = Vector2D(),
50  const Vector2D& initialValue = Vector2D());
51 
54 
56  Size2 dataSize() const override;
57 
61  Vector2D dataOrigin() const override;
62 
69  void swap(Grid2* other) override;
70 
72  void set(const VertexCenteredVectorGrid2& other);
73 
76  const VertexCenteredVectorGrid2& other);
77 
79  void fill(const Vector2D& value,
81 
83  void fill(const std::function<Vector2D(const Vector2D&)>& func,
85 
87  std::shared_ptr<VectorGrid2> clone() const override;
88 
90  static Builder builder();
91 };
92 
94 typedef std::shared_ptr<VertexCenteredVectorGrid2> VertexCenteredVectorGrid2Ptr;
95 
96 
99  public:
102 
104  Builder& withResolution(size_t resolutionX, size_t resolutionY);
105 
108 
110  Builder& withGridSpacing(double gridSpacingX, double gridSpacingY);
111 
113  Builder& withOrigin(const Vector2D& gridOrigin);
114 
116  Builder& withOrigin(double gridOriginX, double gridOriginY);
117 
119  Builder& withInitialValue(const Vector2D& initialVal);
120 
122  Builder& withInitialValue(double initialValX, double initialValY);
123 
126 
129 
136  const Size2& resolution,
137  const Vector2D& gridSpacing,
138  const Vector2D& gridOrigin,
139  const Vector2D& initialVal) const override;
140 
141  private:
142  Size2 _resolution{1, 1};
143  Vector2D _gridSpacing{1, 1};
144  Vector2D _gridOrigin{0, 0};
145  Vector2D _initialVal{0, 0};
146 };
147 
148 } // namespace jet
149 
150 #endif // INCLUDE_JET_VERTEX_CENTERED_VECTOR_GRID2_H_
jet::VertexCenteredVectorGrid2::builder
static Builder builder()
Returns builder fox VertexCenteredVectorGrid2.
jet::ExecutionPolicy
ExecutionPolicy
Execution policy tag.
Definition: parallel.h:13
jet::VertexCenteredVectorGrid2::operator=
VertexCenteredVectorGrid2 & operator=(const VertexCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
jet::Grid2::origin
const Vector2D & origin() const
Returns the grid origin.
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::VertexCenteredVectorGrid2::Builder::withInitialValue
Builder & withInitialValue(const Vector2D &initialVal)
Returns builder with initial value.
jet::VertexCenteredVectorGrid2::Builder::withGridSpacing
Builder & withGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
jet::VertexCenteredVectorGrid2::Builder::withOrigin
Builder & withOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
jet::VertexCenteredVectorGrid2::dataOrigin
Vector2D dataOrigin() const override
jet::VertexCenteredVectorGrid2::VertexCenteredVectorGrid2
VertexCenteredVectorGrid2()
Constructs zero-sized grid.
jet::Grid2
Abstract base class for 2-D cartesian grid structure.
Definition: grid2.h:30
jet::VertexCenteredVectorGrid2::fill
void fill(const std::function< Vector2D(const Vector2D &)> &func, ExecutionPolicy policy=ExecutionPolicy::kParallel) override
Fills the grid with given function.
jet::VertexCenteredVectorGrid2::VertexCenteredVectorGrid2
VertexCenteredVectorGrid2(const VertexCenteredVectorGrid2 &other)
Copy constructor.
jet::VertexCenteredVectorGrid2::VertexCenteredVectorGrid2
VertexCenteredVectorGrid2(size_t resolutionX, size_t resolutionY, double gridSpacingX=1.0, double gridSpacingY=1.0, double originX=0.0, double originY=0.0, double initialValueU=0.0, double initialValueV=0.0)
jet
Definition: advection_solver2.h:18
jet::VertexCenteredVectorGrid2::clone
std::shared_ptr< VectorGrid2 > clone() const override
Returns the copy of the grid instance.
jet::VertexCenteredVectorGrid2Ptr
std::shared_ptr< VertexCenteredVectorGrid2 > VertexCenteredVectorGrid2Ptr
Shared pointer for the VertexCenteredVectorGrid2 type.
Definition: vertex_centered_vector_grid2.h:94
jet::VertexCenteredVectorGrid2::Builder::withGridSpacing
Builder & withGridSpacing(double gridSpacingX, double gridSpacingY)
Returns builder with grid spacing.
jet::VertexCenteredVectorGrid2::Builder::build
VertexCenteredVectorGrid2 build() const
Builds VertexCenteredVectorGrid2 instance.
jet::VectorGridBuilder2
Abstract base class for 2-D vector grid builder.
Definition: vector_grid2.h:91
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::VertexCenteredVectorGrid2::swap
void swap(Grid2 *other) override
Swaps the contents with the given other grid.
jet::CollocatedVectorGrid2
Abstract base class for 2-D collocated vector grid structure.
Definition: collocated_vector_grid2.h:18
collocated_vector_grid2.h
jet::VertexCenteredVectorGrid2::set
void set(const VertexCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
jet::VertexCenteredVectorGrid2::Builder::withOrigin
Builder & withOrigin(double gridOriginX, double gridOriginY)
Returns builder with grid origin.
jet::VertexCenteredVectorGrid2
2-D Vertex-centered vector grid structure.
Definition: vertex_centered_vector_grid2.h:23
jet::VertexCenteredVectorGrid2::Builder::withInitialValue
Builder & withInitialValue(double initialValX, double initialValY)
Returns builder with initial value.
jet::Size2
2-D size class.
Definition: size2.h:19
jet::VertexCenteredVectorGrid2::Builder::build
VectorGrid2Ptr build(const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin, const Vector2D &initialVal) const override
Builds shared pointer of VertexCenteredVectorGrid2 instance.
jet::ExecutionPolicy::kParallel
@ kParallel
jet::VertexCenteredVectorGrid2::VertexCenteredVectorGrid2
VertexCenteredVectorGrid2(const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1.0, 1.0), const Vector2D &origin=Vector2D(), const Vector2D &initialValue=Vector2D())
JET_GRID2_TYPE_NAME
#define JET_GRID2_TYPE_NAME(DerivedClassName)
Definition: grid2.h:113
jet::Grid2::resolution
const Size2 & resolution() const
Returns the grid resolution.
jet::VertexCenteredVectorGrid2::dataSize
Size2 dataSize() const override
Returns the actual data point size.
jet::Grid2::gridSpacing
const Vector2D & gridSpacing() const
Returns the grid spacing.
jet::VertexCenteredVectorGrid2::Builder::withResolution
Builder & withResolution(const Size2 &resolution)
Returns builder with resolution.
jet::VertexCenteredVectorGrid2::fill
void fill(const Vector2D &value, ExecutionPolicy policy=ExecutionPolicy::kParallel) override
Fills the grid with given value.
jet::VectorGrid2Ptr
std::shared_ptr< VectorGrid2 > VectorGrid2Ptr
Shared pointer for the VectorGrid2 type.
Definition: vector_grid2.h:88
jet::VertexCenteredVectorGrid2::Builder::makeShared
VertexCenteredVectorGrid2Ptr makeShared() const
Builds shared pointer of VertexCenteredVectorGrid2 instance.
jet::VertexCenteredVectorGrid2::Builder
A grid builder class that returns 2-D vertex-centered vector grid.
Definition: vertex_centered_vector_grid2.h:98
jet::VertexCenteredVectorGrid2::Builder::withResolution
Builder & withResolution(size_t resolutionX, size_t resolutionY)
Returns builder with resolution.