GridBoundaryConditionSolver2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridBoundaryConditionSolver2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Abstract base class for 2-D boundary condition solver for grids.
6 > Created Time: 2017/08/09
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_GRID_BOUNDARY_CONDITION_SOLVER2_H
10 #define CUBBYFLOW_GRID_BOUNDARY_CONDITION_SOLVER2_H
11 
15 #include <Core/Size/Size2.h>
16 
17 namespace CubbyFlow
18 {
27  {
28  public:
31 
34 
36  const Collider2Ptr& GetCollider() const;
37 
50  void UpdateCollider(
51  const Collider2Ptr& newCollider,
52  const Size2& gridSize,
53  const Vector2D& gridSpacing,
54  const Vector2D& gridOrigin);
55 
57  int GetClosedDomainBoundaryFlag() const;
58 
60  void SetClosedDomainBoundaryFlag(int flag);
61 
69  virtual void ConstrainVelocity(
70  FaceCenteredGrid2* velocity,
71  unsigned int extrapolationDepth = 5) = 0;
72 
74  virtual ScalarField2Ptr GetColliderSDF() const = 0;
75 
77  virtual VectorField2Ptr GetColliderVelocityField() const = 0;
78 
79  protected:
81  virtual void OnColliderUpdated(
82  const Size2& gridSize,
83  const Vector2D& gridSpacing,
84  const Vector2D& gridOrigin) = 0;
85 
87  const Size2& GetGridSize() const;
88 
90  const Vector2D& GetGridSpacing() const;
91 
93  const Vector2D& GetGridOrigin() const;
94 
95  private:
96  Collider2Ptr m_collider;
97  Size2 m_gridSize;
98  Vector2D m_gridSpacing;
99  Vector2D m_gridOrigin;
100  int m_closedDomainBoundaryFlag = DIRECTION_ALL;
101  };
102 
104  using GridBoundaryConditionSolver2Ptr = std::shared_ptr<GridBoundaryConditionSolver2>;
105 }
106 
107 #endif
GridBoundaryConditionSolver2()
Default constructor.
virtual void OnColliderUpdated(const Size2 &gridSize, const Vector2D &gridSpacing, const Vector2D &gridOrigin)=0
Invoked when a new collider is set.
Abstract base class for 2-D boundary condition solver for grids.
Definition: GridBoundaryConditionSolver2.h:26
virtual ~GridBoundaryConditionSolver2()
Default destructor.
std::shared_ptr< Collider2 > Collider2Ptr
Shared pointer type for the Collider2.
Definition: Collider2.h:112
constexpr int DIRECTION_ALL
All direction.
Definition: Constants.h:187
virtual void ConstrainVelocity(FaceCenteredGrid2 *velocity, unsigned int extrapolationDepth=5)=0
virtual ScalarField2Ptr GetColliderSDF() const =0
Returns the signed distance field of the collider.
std::shared_ptr< GridBoundaryConditionSolver2 > GridBoundaryConditionSolver2Ptr
Shared pointer type for the GridBoundaryConditionSolver2.
Definition: GridBoundaryConditionSolver2.h:104
2-D point class.
Definition: Point2.h:25
std::shared_ptr< ScalarField2 > ScalarField2Ptr
Shared pointer for the ScalarField2 type.
Definition: ScalarField2.h:44
const Vector2D & GetGridOrigin() const
Returns the origin of the velocity grid to be constrained.
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid2.h:25
Definition: pybind11Utils.h:24
virtual VectorField2Ptr GetColliderVelocityField() const =0
Returns the velocity field of the collider.
std::shared_ptr< VectorField2 > VectorField2Ptr
Shared pointer for the VectorField2 type.
Definition: VectorField2.h:44
const Collider2Ptr & GetCollider() const
Returns associated collider.
void UpdateCollider(const Collider2Ptr &newCollider, const Size2 &gridSize, const Vector2D &gridSpacing, const Vector2D &gridOrigin)
Applies new collider and build the internals.
const Vector2D & GetGridSpacing() const
Returns the spacing of the velocity grid to be constrained.
2-D vector class.
Definition: Vector2.h:26
int GetClosedDomainBoundaryFlag() const
Returns the closed domain boundary flag.
const Size2 & GetGridSize() const
Returns the size of the velocity grid to be constrained.
void SetClosedDomainBoundaryFlag(int flag)
Sets the closed domain boundary flag.