Jet  v1.3.3
cell_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_CELL_CENTERED_SCALAR_GRID2_H_
8 #define INCLUDE_JET_CELL_CENTERED_SCALAR_GRID2_H_
9 
10 #include <jet/scalar_grid2.h>
11 #include <utility> // just make cpplint happy..
12 
13 namespace jet {
14 
23 class CellCenteredScalarGrid2 final : public ScalarGrid2 {
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 initialValue = 0.0);
42 
46  const Size2& resolution,
47  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
48  const Vector2D& origin = Vector2D(),
49  double initialValue = 0.0);
50 
53 
55  Size2 dataSize() const override;
56 
60  Vector2D dataOrigin() const override;
61 
68  void swap(Grid2* other) override;
69 
71  void set(const CellCenteredScalarGrid2& other);
72 
75 
77  std::shared_ptr<ScalarGrid2> clone() const override;
78 
80  static Builder builder();
81 };
82 
84 typedef std::shared_ptr<CellCenteredScalarGrid2> CellCenteredScalarGrid2Ptr;
85 
86 
91  public:
94 
96  Builder& withResolution(size_t resolutionX, size_t resolutionY);
97 
100 
102  Builder& withGridSpacing(double gridSpacingX, double gridSpacingY);
103 
105  Builder& withOrigin(const Vector2D& gridOrigin);
106 
108  Builder& withOrigin(double gridOriginX, double gridOriginY);
109 
111  Builder& withInitialValue(double initialVal);
112 
115 
118 
125  const Size2& resolution,
126  const Vector2D& gridSpacing,
127  const Vector2D& gridOrigin,
128  double initialVal) const override;
129 
130  private:
131  Size2 _resolution{1, 1};
132  Vector2D _gridSpacing{1, 1};
133  Vector2D _gridOrigin{0, 0};
134  double _initialVal = 0.0;
135 };
136 
137 } // namespace jet
138 
139 #endif // INCLUDE_JET_CELL_CENTERED_SCALAR_GRID2_H_
jet::CellCenteredScalarGrid2::CellCenteredScalarGrid2
CellCenteredScalarGrid2(const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1.0, 1.0), const Vector2D &origin=Vector2D(), double initialValue=0.0)
jet::Grid2::origin
const Vector2D & origin() const
Returns the grid origin.
jet::CellCenteredScalarGrid2::Builder::withResolution
Builder & withResolution(const Size2 &resolution)
Returns builder with resolution.
jet::ScalarGridBuilder2
Abstract base class for 2-D scalar grid builder.
Definition: scalar_grid2.h:191
jet::CellCenteredScalarGrid2::Builder::withInitialValue
Builder & withInitialValue(double initialVal)
Returns builder with initial value.
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::CellCenteredScalarGrid2::Builder::withGridSpacing
Builder & withGridSpacing(double gridSpacingX, double gridSpacingY)
Returns builder with grid spacing.
jet::CellCenteredScalarGrid2::CellCenteredScalarGrid2
CellCenteredScalarGrid2()
Constructs zero-sized grid.
jet::CellCenteredScalarGrid2
2-D Cell-centered scalar grid structure.
Definition: cell_centered_scalar_grid2.h:23
jet::CellCenteredScalarGrid2::builder
static Builder builder()
Returns builder fox CellCenteredScalarGrid2.
jet::CellCenteredScalarGrid2::CellCenteredScalarGrid2
CellCenteredScalarGrid2(const CellCenteredScalarGrid2 &other)
Copy constructor.
jet::CellCenteredScalarGrid2::CellCenteredScalarGrid2
CellCenteredScalarGrid2(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::Grid2
Abstract base class for 2-D cartesian grid structure.
Definition: grid2.h:30
jet::CellCenteredScalarGrid2::Builder::withGridSpacing
Builder & withGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
jet::CellCenteredScalarGrid2::Builder::withOrigin
Builder & withOrigin(double gridOriginX, double gridOriginY)
Returns builder with grid origin.
jet::CellCenteredScalarGrid2::operator=
CellCenteredScalarGrid2 & operator=(const CellCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
jet
Definition: advection_solver2.h:18
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::CellCenteredScalarGrid2::Builder::build
CellCenteredScalarGrid2 build() const
Builds CellCenteredScalarGrid2 instance.
jet::CellCenteredScalarGrid2::dataSize
Size2 dataSize() const override
Returns the actual data point size.
jet::CellCenteredScalarGrid2::Builder::withResolution
Builder & withResolution(size_t resolutionX, size_t resolutionY)
Returns builder with resolution.
jet::CellCenteredScalarGrid2::Builder::makeShared
CellCenteredScalarGrid2Ptr makeShared() const
Builds shared pointer of CellCenteredScalarGrid2 instance.
jet::CellCenteredScalarGrid2::clone
std::shared_ptr< ScalarGrid2 > clone() const override
Returns the copy of the grid instance.
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
scalar_grid2.h
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::CellCenteredScalarGrid2::Builder::withOrigin
Builder & withOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
jet::CellCenteredScalarGrid2Ptr
std::shared_ptr< CellCenteredScalarGrid2 > CellCenteredScalarGrid2Ptr
Shared pointer for the CellCenteredScalarGrid2 type.
Definition: cell_centered_scalar_grid2.h:84
jet::Grid2::gridSpacing
const Vector2D & gridSpacing() const
Returns the grid spacing.
jet::CellCenteredScalarGrid2::dataOrigin
Vector2D dataOrigin() const override
jet::CellCenteredScalarGrid2::set
void set(const CellCenteredScalarGrid2 &other)
Sets the contents with the given other grid.
jet::CellCenteredScalarGrid2::swap
void swap(Grid2 *other) override
Swaps the contents with the given other grid.
jet::CellCenteredScalarGrid2::Builder
Front-end to create CellCenteredScalarGrid2 objects step by step.
Definition: cell_centered_scalar_grid2.h:90
jet::CellCenteredScalarGrid2::Builder::build
ScalarGrid2Ptr build(const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin, double initialVal) const override
Builds shared pointer of CellCenteredScalarGrid2 instance.