Loading...
Searching...
No Matches
ConstantScalarField.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_CONSTANT_SCALAR_FIELD_HPP
12#define CUBBYFLOW_CONSTANT_SCALAR_FIELD_HPP
13
15
16namespace CubbyFlow
17{
19template <size_t N>
20class ConstantScalarField final : public ScalarField<N>
21{
22 public:
23 class Builder;
24
26 explicit ConstantScalarField(double value);
27
29 [[nodiscard]] double Sample(const Vector<double, N>& x) const override;
30
32 [[nodiscard]] std::function<double(const Vector<double, N>&)> Sampler()
33 const override;
34
37
38 private:
39 double m_value = 0.0;
40};
41
44
47
49using ConstantScalarField2Ptr = std::shared_ptr<ConstantScalarField2>;
50
52using ConstantScalarField3Ptr = std::shared_ptr<ConstantScalarField3>;
53
57template <size_t N>
59{
60 public:
62 Builder& WithValue(double value);
63
66
68 std::shared_ptr<ConstantScalarField> MakeShared() const;
69
70 private:
71 double m_value = 0.0;
72};
73} // namespace CubbyFlow
74
75#endif
Front-end to create ConstantScalarField objects step by step.
Definition ConstantScalarField.hpp:59
std::shared_ptr< ConstantScalarField > MakeShared() const
Builds shared pointer of ConstantScalarField instance.
Builder & WithValue(double value)
Returns builder with value.
ConstantScalarField Build() const
Builds ConstantScalarField.
N-D constant scalar field.
Definition ConstantScalarField.hpp:21
ConstantScalarField(double value)
Constructs a constant scalar field with given value.
double Sample(const Vector< double, N > &x) const override
Returns the sampled value at given position x.
static Builder GetBuilder()
Returns builder for ConstantScalarField.
std::function< double(const Vector< double, N > &)> Sampler() const override
Returns the sampler function.
Definition Matrix.hpp:30
Abstract base class for N-D scalar field.
Definition ScalarField.hpp:25
Definition pybind11Utils.hpp:21
std::shared_ptr< ConstantScalarField3 > ConstantScalarField3Ptr
Shared pointer for the ConstantScalarField3 type.
Definition ConstantScalarField.hpp:52
std::shared_ptr< ConstantScalarField2 > ConstantScalarField2Ptr
Shared pointer for the ConstantScalarField2 type.
Definition ConstantScalarField.hpp:49