PolyFEM
Loading...
Searching...
No Matches
Interpolation.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <polyfem/Common.hpp>
4
5#include <memory>
6#include <vector>
7
8namespace polyfem::utils
9{
11 {
12 public:
13 virtual ~Interpolation() {}
14 virtual double eval(const double t) const = 0;
15 virtual void init(const json &params) {}
16
17 static std::shared_ptr<Interpolation> build(const json &params);
18 };
19
21 {
22 public:
23 double eval(const double t) const override { return 1; };
24 };
25
27 {
28 public:
29 double eval(const double t) const override { return t; }
30 };
31
33 {
34 public:
35 double eval(const double t) const override;
36 void init(const json &params) override;
37
38 private:
39 double to_;
40 double from_;
41 };
42
44 {
45 public:
46 virtual void init(const json &params) override;
47 double eval(const double t) const override;
48 double extend(const double t) const;
49
50 public:
51 std::vector<double> points_;
52 std::vector<double> values_;
53
54 enum class Extend
55 {
58 REPEAT,
60 };
62
63 protected:
64 virtual double eval_piece(const double t, const int i) const = 0;
65
66 double dy_dt(const double t) const;
67 virtual double dy_dt_piece(const double t, const int i) const = 0;
68 };
69
71 {
72 protected:
73 double eval_piece(const double t, const int i) const override { return values_[i]; }
74 double dy_dt_piece(const double t, const int i) const override { return 0; }
75 };
76
78 {
79 protected:
80 double eval_piece(const double t, const int i) const override;
81 double dy_dt_piece(const double t, const int i) const override;
82 };
83
85 {
86 public:
87 void init(const json &params) override;
88
89 const Eigen::MatrixXd &coeffs() const { return coeffs_; }
90
91 protected:
92 double eval_piece(const double t, const int i) const override;
93 double dy_dt_piece(const double t, const int i) const override;
94
95 Eigen::MatrixXd coeffs_;
96 };
97
98} // namespace polyfem::utils
virtual void init(const json &params)
virtual double eval(const double t) const =0
static std::shared_ptr< Interpolation > build(const json &params)
double eval(const double t) const override
void init(const json &params) override
double eval(const double t) const override
double eval(const double t) const override
double eval_piece(const double t, const int i) const override
double dy_dt_piece(const double t, const int i) const override
double eval_piece(const double t, const int i) const override
const Eigen::MatrixXd & coeffs() const
void init(const json &params) override
double dy_dt_piece(const double t, const int i) const override
virtual double eval_piece(const double t, const int i) const =0
double eval(const double t) const override
virtual void init(const json &params) override
double dy_dt(const double t) const
double extend(const double t) const
virtual double dy_dt_piece(const double t, const int i) const =0
double eval_piece(const double t, const int i) const override
double dy_dt_piece(const double t, const int i) const override
nlohmann::json json
Definition Common.hpp:9