Jet  v1.3.3
vertex_centered_scalar_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_SCALAR_GRID2_H_
8 #define INCLUDE_JET_VERTEX_CENTERED_SCALAR_GRID2_H_
9 
10 #include <jet/array2.h>
11 #include <jet/scalar_grid2.h>
12 #include <utility> // just make cpplint happy..
13 
14 namespace jet {
15 
24 class VertexCenteredScalarGrid2 final : public ScalarGrid2 {
25  public:
27 
28  class Builder;
29 
32 
36  size_t resolutionX,
37  size_t resolutionY,
38  double gridSpacingX = 1.0,
39  double gridSpacingY = 1.0,
40  double originX = 0.0,
41  double originY = 0.0,
42  double initialValue = 0.0);
43 
47  const Size2& resolution,
48  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
49  const Vector2D& origin = Vector2D(),
50  double initialValue = 0.0);
51 
54 
56  Size2 dataSize() const override;
57 
61  Vector2D dataOrigin() const override;
62 
64  std::shared_ptr<ScalarGrid2> clone() const override;
65 
72  void swap(Grid2* other) override;
73 
75  void set(const VertexCenteredScalarGrid2& other);
76 
79  const VertexCenteredScalarGrid2& other);
80 
82  static Builder builder();
83 };
84 
86 typedef std::shared_ptr<VertexCenteredScalarGrid2> VertexCenteredScalarGrid2Ptr;
87 
88 
93  public:
96 
98  Builder& withResolution(size_t resolutionX, size_t resolutionY);
99 
102 
104  Builder& withGridSpacing(double gridSpacingX, double gridSpacingY);
105 
107  Builder& withOrigin(const Vector2D& gridOrigin);
108 
110  Builder& withOrigin(double gridOriginX, double gridOriginY);
111 
113  Builder& withInitialValue(double initialVal);
114 
117 
120 
127  const Size2& resolution,
128  const Vector2D& gridSpacing,
129  const Vector2D& gridOrigin,
130  double initialVal) const override;
131 
132  private:
133  Size2 _resolution{1, 1};
134  Vector2D _gridSpacing{1, 1};
135  Vector2D _gridOrigin{0, 0};
136  double _initialVal = 0.0;
137 };
138 
139 } // namespace jet
140 
141 #endif // INCLUDE_JET_VERTEX_CENTERED_SCALAR_GRID2_H_
jet::VertexCenteredScalarGrid2::Builder::withGridSpacing
Builder & withGridSpacing(double gridSpacingX, double gridSpacingY)
Returns builder with grid spacing.
array2.h
jet::VertexCenteredScalarGrid2::VertexCenteredScalarGrid2
VertexCenteredScalarGrid2(const VertexCenteredScalarGrid2 &other)
Copy constructor.
jet::VertexCenteredScalarGrid2::Builder::withResolution
Builder & withResolution(size_t resolutionX, size_t resolutionY)
Returns builder with resolution.
jet::VertexCenteredScalarGrid2::Builder::withOrigin
Builder & withOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
jet::VertexCenteredScalarGrid2::Builder
Front-end to create VertexCenteredScalarGrid2 objects step by step.
Definition: vertex_centered_scalar_grid2.h:92
jet::Grid2::origin
const Vector2D & origin() const
Returns the grid origin.
jet::ScalarGridBuilder2
Abstract base class for 2-D scalar grid builder.
Definition: scalar_grid2.h:191
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::VertexCenteredScalarGrid2::dataSize
Size2 dataSize() const override
Returns the actual data point size.
jet::VertexCenteredScalarGrid2::clone
std::shared_ptr< ScalarGrid2 > clone() const override
Returns the copy of the grid instance.
jet::VertexCenteredScalarGrid2::VertexCenteredScalarGrid2
VertexCenteredScalarGrid2(const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1.0, 1.0), const Vector2D &origin=Vector2D(), double initialValue=0.0)
jet::VertexCenteredScalarGrid2::Builder::build
VertexCenteredScalarGrid2 build() const
Builds VertexCenteredScalarGrid2 instance.
jet::VertexCenteredScalarGrid2Ptr
std::shared_ptr< VertexCenteredScalarGrid2 > VertexCenteredScalarGrid2Ptr
Shared pointer for the VertexCenteredScalarGrid2 type.
Definition: vertex_centered_scalar_grid2.h:86
jet::Grid2
Abstract base class for 2-D cartesian grid structure.
Definition: grid2.h:30
jet::VertexCenteredScalarGrid2::VertexCenteredScalarGrid2
VertexCenteredScalarGrid2()
Constructs zero-sized grid.
jet
Definition: advection_solver2.h:18
jet::VertexCenteredScalarGrid2::builder
static Builder builder()
Returns builder fox VertexCenteredScalarGrid2.
jet::ScalarGrid2
Abstract base class for 2-D scalar grid structure.
Definition: scalar_grid2.h:21
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::VertexCenteredScalarGrid2::Builder::withOrigin
Builder & withOrigin(double gridOriginX, double gridOriginY)
Returns builder with grid origin.
jet::VertexCenteredScalarGrid2
2-D Vertex-centered scalar grid structure.
Definition: vertex_centered_scalar_grid2.h:24
jet::ScalarGrid2Ptr
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition: scalar_grid2.h:188
jet::Size2
2-D size class.
Definition: size2.h:19
jet::VertexCenteredScalarGrid2::Builder::build
ScalarGrid2Ptr build(const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin, double initialVal) const override
Builds shared pointer of VertexCenteredScalarGrid2 instance.
scalar_grid2.h
jet::VertexCenteredScalarGrid2::Builder::withResolution
Builder & withResolution(const Size2 &resolution)
Returns builder with resolution.
jet::VertexCenteredScalarGrid2::Builder::withGridSpacing
Builder & withGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
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::VertexCenteredScalarGrid2::VertexCenteredScalarGrid2
VertexCenteredScalarGrid2(size_t resolutionX, size_t resolutionY, double gridSpacingX=1.0, double gridSpacingY=1.0, double originX=0.0, double originY=0.0, double initialValue=0.0)
jet::VertexCenteredScalarGrid2::swap
void swap(Grid2 *other) override
Swaps the contents with the given other grid.
jet::VertexCenteredScalarGrid2::dataOrigin
Vector2D dataOrigin() const override
jet::Grid2::gridSpacing
const Vector2D & gridSpacing() const
Returns the grid spacing.
jet::VertexCenteredScalarGrid2::Builder::withInitialValue
Builder & withInitialValue(double initialVal)
Returns builder with initial value.
jet::VertexCenteredScalarGrid2::operator=
VertexCenteredScalarGrid2 & operator=(const VertexCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
jet::VertexCenteredScalarGrid2::Builder::makeShared
VertexCenteredScalarGrid2Ptr makeShared() const
Builds shared pointer of VertexCenteredScalarGrid2 instance.
jet::VertexCenteredScalarGrid2::set
void set(const VertexCenteredScalarGrid2 &other)
Sets the contents with the given other grid.