Loading...
Searching...
No Matches
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>
16
17#include <functional>
18#include <memory>
19
20namespace CubbyFlow
21{
22template <size_t N>
23struct GetCurl
24{
25 // Do nothing
26};
27
28template <>
29struct GetCurl<2>
30{
31 using Type = double;
32};
33
34template <>
35struct GetCurl<3>
36{
37 using Type = Vector3D;
38};
39
41template <size_t N>
42class 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<
76 Vector<double, N>(const Vector<double, N>&)>
77 Sampler() const;
78};
79
82
85
87using VectorField2Ptr = std::shared_ptr<VectorField2>;
88
90using VectorField3Ptr = std::shared_ptr<VectorField3>;
91} // namespace CubbyFlow
92
93#endif
Abstract base class for N-D fields.
Definition Field.hpp:21
Definition Matrix.hpp:30
Abstract base class for N-D vector field.
Definition VectorField.hpp:43
~VectorField() override=default
Default destructor.
VectorField(const VectorField &)=default
Default copy constructor.
virtual std::function< Vector< double, N >(const Vector< double, N > &)> Sampler() const
Returns sampler function object.
virtual GetCurl< N >::Type Curl(const Vector< double, N > &x) const
Returns curl at given position x.
virtual double Divergence(const Vector< double, N > &x) const
Returns divergence at given position x.
virtual Vector< double, N > Sample(const Vector< double, N > &x) const =0
Returns sampled value at given position x.
VectorField(VectorField &&) noexcept=default
Default move constructor.
VectorField()=default
Default constructor.
Definition pybind11Utils.hpp:21
Vector3< double > Vector3D
Definition Matrix.hpp:787
std::shared_ptr< VectorField2 > VectorField2Ptr
Shared pointer for the VectorField2 type.
Definition VectorField.hpp:87
std::shared_ptr< VectorField3 > VectorField3Ptr
Shared pointer for the VectorField3 type.
Definition VectorField.hpp:90
double Type
Definition VectorField.hpp:31
Definition VectorField.hpp:24