GridBoundaryConditionSolver2.hpp
Go to the documentation of this file.
1 // This code is based on Jet framework.
2 // Copyright (c) 2018 Doyub Kim
3 // CubbyFlow is voxel-based fluid simulation engine for computer games.
4 // Copyright (c) 2020 CubbyFlow Team
5 // Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6 // AI Part: Dongheon Cho, Minseo Kim
7 // We are making my contributions/submissions to this project solely in our
8 // personal capacity and are not conveying any rights to any intellectual
9 // property of any third parties.
10 
11 #ifndef CUBBYFLOW_GRID_BOUNDARY_CONDITION_SOLVER2_HPP
12 #define CUBBYFLOW_GRID_BOUNDARY_CONDITION_SOLVER2_HPP
13 
17 
18 namespace CubbyFlow
19 {
28 {
29  public:
31  GridBoundaryConditionSolver2() = default;
32 
35 
38  delete;
39 
41  virtual ~GridBoundaryConditionSolver2() = default;
42 
45  const GridBoundaryConditionSolver2&) = delete;
46 
49  GridBoundaryConditionSolver2&&) noexcept = delete;
50 
52  [[nodiscard]] const Collider2Ptr& GetCollider() const;
53 
66  void UpdateCollider(const Collider2Ptr& newCollider,
67  const Vector2UZ& gridSize, const Vector2D& gridSpacing,
68  const Vector2D& gridOrigin);
69 
71  [[nodiscard]] int GetClosedDomainBoundaryFlag() const;
72 
74  void SetClosedDomainBoundaryFlag(int flag);
75 
83  virtual void ConstrainVelocity(FaceCenteredGrid2* velocity,
84  unsigned int extrapolationDepth = 5) = 0;
85 
87  [[nodiscard]] virtual ScalarField2Ptr GetColliderSDF() const = 0;
88 
90  [[nodiscard]] virtual VectorField2Ptr GetColliderVelocityField() const = 0;
91 
92  protected:
94  virtual void OnColliderUpdated(const Vector2UZ& gridSize,
95  const Vector2D& gridSpacing,
96  const Vector2D& gridOrigin) = 0;
97 
99  [[nodiscard]] const Vector2UZ& GetGridSize() const;
100 
102  [[nodiscard]] const Vector2D& GetGridSpacing() const;
103 
105  [[nodiscard]] const Vector2D& GetGridOrigin() const;
106 
107  private:
108  Collider2Ptr m_collider;
109  Vector2UZ m_gridSize;
110  Vector2D m_gridSpacing;
111  Vector2D m_gridOrigin;
112  int m_closedDomainBoundaryFlag = DIRECTION_ALL;
113 };
114 
117  std::shared_ptr<GridBoundaryConditionSolver2>;
118 } // namespace CubbyFlow
119 
120 #endif
GridBoundaryConditionSolver2()=default
Default constructor.
Abstract base class for 2-D boundary condition solver for grids.
Definition: GridBoundaryConditionSolver2.hpp:27
std::shared_ptr< Collider2 > Collider2Ptr
Shared pointer type for the Collider2.
Definition: Collider.hpp:141
constexpr int DIRECTION_ALL
All direction.
Definition: Constants.hpp:332
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.hpp:117
GridBoundaryConditionSolver2 & operator=(const GridBoundaryConditionSolver2 &)=delete
Deleted copy assignment operator.
virtual ~GridBoundaryConditionSolver2()=default
Default virtual destructor.
std::shared_ptr< ScalarField2 > ScalarField2Ptr
Shared pointer for the ScalarField2 type.
Definition: ScalarField.hpp:67
const Vector2D & GetGridOrigin() const
Returns the origin of the velocity grid to be constrained.
void UpdateCollider(const Collider2Ptr &newCollider, const Vector2UZ &gridSize, const Vector2D &gridSpacing, const Vector2D &gridOrigin)
Applies new collider and build the internals.
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
virtual VectorField2Ptr GetColliderVelocityField() const =0
Returns the velocity field of the collider.
N-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid.hpp:31
std::shared_ptr< VectorField2 > VectorField2Ptr
Shared pointer for the VectorField2 type.
Definition: VectorField.hpp:87
const Collider2Ptr & GetCollider() const
Returns associated collider.
const Vector2D & GetGridSpacing() const
Returns the spacing of the velocity grid to be constrained.
virtual void OnColliderUpdated(const Vector2UZ &gridSize, const Vector2D &gridSpacing, const Vector2D &gridOrigin)=0
Invoked when a new collider is set.
const Vector2UZ & GetGridSize() const
Returns the size of the velocity grid to be constrained.
int GetClosedDomainBoundaryFlag() const
Returns the closed domain boundary flag.
void SetClosedDomainBoundaryFlag(int flag)
Sets the closed domain boundary flag.