Jet  v1.3.3
cell_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_CELL_CENTERED_VECTOR_GRID2_H_
8 #define INCLUDE_JET_CELL_CENTERED_VECTOR_GRID2_H_
9 
10 #include <jet/array2.h>
12 #include <utility> // just make cpplint happy..
13 
14 namespace jet {
15 
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 initialValueU = 0.0,
43  double initialValueV = 0.0);
44 
48  const Size2& resolution,
49  const Vector2D& gridSpacing = Vector2D(1.0, 1.0),
50  const Vector2D& origin = Vector2D(),
51  const Vector2D& initialValue = Vector2D());
52 
55 
57  Size2 dataSize() const override;
58 
62  Vector2D dataOrigin() const override;
63 
70  void swap(Grid2* other) override;
71 
73  void set(const CellCenteredVectorGrid2& other);
74 
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<CellCenteredVectorGrid2> CellCenteredVectorGrid2Ptr;
95 
96 
101  public:
104 
106  Builder& withResolution(size_t resolutionX, size_t resolutionY);
107 
110 
112  Builder& withGridSpacing(double gridSpacingX, double gridSpacingY);
113 
115  Builder& withOrigin(const Vector2D& gridOrigin);
116 
118  Builder& withOrigin(double gridOriginX, double gridOriginY);
119 
121  Builder& withInitialValue(const Vector2D& initialVal);
122 
124  Builder& withInitialValue(double initialValX, double initialValY);
125 
128 
131 
138  const Size2& resolution,
139  const Vector2D& gridSpacing,
140  const Vector2D& gridOrigin,
141  const Vector2D& initialVal) const override;
142 
143  private:
144  Size2 _resolution{1, 1};
145  Vector2D _gridSpacing{1, 1};
146  Vector2D _gridOrigin{0, 0};
147  Vector2D _initialVal{0, 0};
148 };
149 
150 } // namespace jet
151 
152 #endif // INCLUDE_JET_CELL_CENTERED_VECTOR_GRID2_H_
jet::CellCenteredVectorGrid2::fill
void fill(const std::function< Vector2D(const Vector2D &)> &func, ExecutionPolicy policy=ExecutionPolicy::kParallel) override
Fills the grid with given function.
jet::ExecutionPolicy
ExecutionPolicy
Execution policy tag.
Definition: parallel.h:13
array2.h
jet::Grid2::origin
const Vector2D & origin() const
Returns the grid origin.
jet::CellCenteredVectorGrid2
2-D Cell-centered vector grid structure.
Definition: cell_centered_vector_grid2.h:24
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::CellCenteredVectorGrid2::Builder::withInitialValue
Builder & withInitialValue(const Vector2D &initialVal)
Returns builder with initial value.
jet::CellCenteredVectorGrid2::CellCenteredVectorGrid2
CellCenteredVectorGrid2(const Size2 &resolution, const Vector2D &gridSpacing=Vector2D(1.0, 1.0), const Vector2D &origin=Vector2D(), const Vector2D &initialValue=Vector2D())
jet::CellCenteredVectorGrid2::Builder::withOrigin
Builder & withOrigin(const Vector2D &gridOrigin)
Returns builder with grid origin.
jet::Grid2
Abstract base class for 2-D cartesian grid structure.
Definition: grid2.h:30
jet::CellCenteredVectorGrid2::Builder::build
VectorGrid2Ptr build(const Size2 &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin, const Vector2D &initialVal) const override
Builds shared pointer of CellCenteredVectorGrid2 instance.
jet::CellCenteredVectorGrid2::CellCenteredVectorGrid2
CellCenteredVectorGrid2()
Constructs zero-sized grid.
jet::CellCenteredVectorGrid2::Builder::withInitialValue
Builder & withInitialValue(double initialValX, double initialValY)
Returns builder with initial value.
jet
Definition: advection_solver2.h:18
jet::CellCenteredVectorGrid2::Builder::withResolution
Builder & withResolution(const Size2 &resolution)
Returns builder with resolution.
jet::CellCenteredVectorGrid2::Builder::withGridSpacing
Builder & withGridSpacing(double gridSpacingX, double gridSpacingY)
Returns builder with grid spacing.
jet::CellCenteredVectorGrid2::Builder::withResolution
Builder & withResolution(size_t resolutionX, size_t resolutionY)
Returns builder with resolution.
jet::CellCenteredVectorGrid2::dataOrigin
Vector2D dataOrigin() const override
jet::VectorGridBuilder2
Abstract base class for 2-D vector grid builder.
Definition: vector_grid2.h:91
jet::CellCenteredVectorGrid2::set
void set(const CellCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::CellCenteredVectorGrid2::dataSize
Size2 dataSize() const override
Returns the actual data point size.
jet::CollocatedVectorGrid2
Abstract base class for 2-D collocated vector grid structure.
Definition: collocated_vector_grid2.h:18
collocated_vector_grid2.h
jet::CellCenteredVectorGrid2Ptr
std::shared_ptr< CellCenteredVectorGrid2 > CellCenteredVectorGrid2Ptr
Shared pointer for the CellCenteredVectorGrid2 type.
Definition: cell_centered_vector_grid2.h:94
jet::CellCenteredVectorGrid2::CellCenteredVectorGrid2
CellCenteredVectorGrid2(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::Size2
2-D size class.
Definition: size2.h:19
jet::CellCenteredVectorGrid2::swap
void swap(Grid2 *other) override
Swaps the contents with the given other grid.
jet::CellCenteredVectorGrid2::operator=
CellCenteredVectorGrid2 & operator=(const CellCenteredVectorGrid2 &other)
Sets the contents with the given other grid.
jet::CellCenteredVectorGrid2::Builder::withGridSpacing
Builder & withGridSpacing(const Vector2D &gridSpacing)
Returns builder with grid spacing.
jet::CellCenteredVectorGrid2::Builder::withOrigin
Builder & withOrigin(double gridOriginX, double gridOriginY)
Returns builder with grid origin.
jet::CellCenteredVectorGrid2::clone
std::shared_ptr< VectorGrid2 > clone() const override
Returns the copy of the grid instance.
jet::CellCenteredVectorGrid2::CellCenteredVectorGrid2
CellCenteredVectorGrid2(const CellCenteredVectorGrid2 &other)
Copy constructor.
jet::CellCenteredVectorGrid2::builder
static Builder builder()
Returns builder fox CellCenteredVectorGrid2.
jet::CellCenteredVectorGrid2::fill
void fill(const Vector2D &value, ExecutionPolicy policy=ExecutionPolicy::kParallel) override
Fills the grid with given value.
jet::ExecutionPolicy::kParallel
@ kParallel
jet::CellCenteredVectorGrid2::Builder::makeShared
CellCenteredVectorGrid2Ptr makeShared() const
Builds shared pointer of CellCenteredVectorGrid2 instance.
jet::CellCenteredVectorGrid2::Builder::build
CellCenteredVectorGrid2 build() const
Builds CellCenteredVectorGrid2 instance.
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::CellCenteredVectorGrid2::Builder
Front-end to create CellCenteredVectorGrid2 objects step by step.
Definition: cell_centered_vector_grid2.h:100
jet::Grid2::gridSpacing
const Vector2D & gridSpacing() const
Returns the grid spacing.
jet::VectorGrid2Ptr
std::shared_ptr< VectorGrid2 > VectorGrid2Ptr
Shared pointer for the VectorGrid2 type.
Definition: vector_grid2.h:88