ScalarField.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_SCALAR_FIELD_HPP
12 #define CUBBYFLOW_SCALAR_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 {
23 template <size_t N>
24 class ScalarField : public Field<N>
25 {
26  public:
28  ScalarField() = default;
29 
31  ~ScalarField() override = default;
32 
34  ScalarField(const ScalarField&) = default;
35 
37  ScalarField(ScalarField&&) noexcept = default;
38 
40  ScalarField& operator=(const ScalarField&) = default;
41 
43  ScalarField& operator=(ScalarField&&) noexcept = default;
44 
46  [[nodiscard]] virtual double Sample(const Vector<double, N>& x) const = 0;
47 
49  [[nodiscard]] virtual Vector<double, N> Gradient(
50  const Vector<double, N>& x) const;
51 
53  [[nodiscard]] virtual double Laplacian(const Vector<double, N>& x) const;
54 
56  [[nodiscard]] virtual std::function<double(const Vector<double, N>&)>
57  Sampler() const;
58 };
59 
62 
65 
67 using ScalarField2Ptr = std::shared_ptr<ScalarField2>;
68 
70 using ScalarField3Ptr = std::shared_ptr<ScalarField3>;
71 } // namespace CubbyFlow
72 
73 #endif
virtual double Sample(const Vector< double, N > &x) const =0
Returns sampled value at given position x.
std::shared_ptr< ScalarField3 > ScalarField3Ptr
Shared pointer for the ScalarField3 type.
Definition: ScalarField.hpp:70
virtual Vector< double, N > Gradient(const Vector< double, N > &x) const
Returns gradient vector at given position x.
Abstract base class for N-D scalar field.
Definition: ScalarField.hpp:24
std::shared_ptr< ScalarField2 > ScalarField2Ptr
Shared pointer for the ScalarField2 type.
Definition: ScalarField.hpp:67
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
~ScalarField() override=default
Default destructor.
ScalarField()=default
Default constructor.
ScalarField & operator=(const ScalarField &)=default
Default copy assignment operator.
virtual double Laplacian(const Vector< double, N > &x) const
Returns Laplacian at given position x.
virtual std::function< double(const Vector< double, N > &)> Sampler() const
Returns sampler function object.
Abstract base class for N-D fields.
Definition: Field.hpp:20