VectorField.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_VECTOR_FIELD_HPP
12 #define CUBBYFLOW_VECTOR_FIELD_HPP
13 
14 #include <Core/Field/Field.hpp>
15 #include <Core/Matrix/Matrix.hpp>
16 
17 #include <functional>
18 #include <memory>
19 
20 namespace CubbyFlow
21 {
22 template <size_t N>
23 struct GetCurl
24 {
25  // Do nothing
26 };
27 
28 template <>
29 struct GetCurl<2>
30 {
31  using Type = double;
32 };
33 
34 template <>
35 struct GetCurl<3>
36 {
37  using Type = Vector3D;
38 };
39 
41 template <size_t N>
42 class VectorField : public Field<N>
43 {
44  public:
46  VectorField() = default;
47 
49  ~VectorField() override = default;
50 
52  VectorField(const VectorField&) = default;
53 
55  VectorField(VectorField&&) noexcept = default;
56 
58  VectorField& operator=(const VectorField&) = default;
59 
61  VectorField& operator=(VectorField&&) noexcept = default;
62 
64  [[nodiscard]] virtual Vector<double, N> Sample(
65  const Vector<double, N>& x) const = 0;
66 
68  [[nodiscard]] virtual double Divergence(const Vector<double, N>& x) const;
69 
71  [[nodiscard]] virtual typename GetCurl<N>::Type Curl(
72  const Vector<double, N>& x) const;
73 
75  [[nodiscard]] virtual std::function<
77  Sampler() const;
78 };
79 
82 
85 
87 using VectorField2Ptr = std::shared_ptr<VectorField2>;
88 
90 using VectorField3Ptr = std::shared_ptr<VectorField3>;
91 } // namespace CubbyFlow
92 
93 #endif
double Type
Definition: VectorField.hpp:31
std::shared_ptr< VectorField3 > VectorField3Ptr
Shared pointer for the VectorField3 type.
Definition: VectorField.hpp:90
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
std::shared_ptr< VectorField2 > VectorField2Ptr
Shared pointer for the VectorField2 type.
Definition: VectorField.hpp:87
Abstract base class for N-D vector field.
Definition: VectorField.hpp:42
Abstract base class for N-D fields.
Definition: Field.hpp:20
Definition: VectorField.hpp:23
Vector3< double > Vector3D
Definition: Matrix.hpp:787