OGS
Subdivision.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <cstddef>
14#include <vector>
15
16namespace BaseLib
17{
22{
23public:
25 virtual std::vector<double> operator()() const = 0;
26
27 virtual ~ISubdivision() = default;
28};
29
34{
35public:
41 UniformSubdivision(double length, std::size_t n_subdivision)
42 : length_(length), n_subdivision_(n_subdivision)
43 {
44 }
45
47 std::vector<double> operator()() const override
48 {
49 std::vector<double> x;
50 x.reserve(n_subdivision_ + 1);
51 const double dL = length_ / static_cast<double>(n_subdivision_);
52 for (std::size_t i = 0; i < n_subdivision_ + 1; i++)
53 {
54 x.push_back(i * dL);
55 }
56 return x;
57 }
58
59private:
60 const double length_;
61 const std::size_t n_subdivision_;
62};
63
68{
69public:
77 GradualSubdivision(const double L,
78 const double dL0,
79 const double max_dL,
80 const double multiplier);
81
83 std::vector<double> operator()() const override;
84
85private:
86 const double length_;
87 const double dL0_;
88 const double max_dL_;
89 const double multiplier_;
90};
91
98{
99public:
106 GradualSubdivisionFixedNum(const double L,
107 const std::size_t num_subdivisions,
108 const double multiplier);
109
111 std::vector<double> operator()() const override;
112
113private:
114 const double length_;
115 const std::size_t num_subdivisions_;
116 const double multiplier_;
117};
118
119} // namespace BaseLib
GradualSubdivisionFixedNum(const double L, const std::size_t num_subdivisions, const double multiplier)
std::vector< double > operator()() const override
Returns a vector of subdivided points.
GradualSubdivision(const double L, const double dL0, const double max_dL, const double multiplier)
std::vector< double > operator()() const override
Returns a vector of subdivided points.
virtual ~ISubdivision()=default
virtual std::vector< double > operator()() const =0
Returns a vector of subdivided points.
const std::size_t n_subdivision_
Definition Subdivision.h:61
UniformSubdivision(double length, std::size_t n_subdivision)
Definition Subdivision.h:41
std::vector< double > operator()() const override
Returns a vector of subdivided points.
Definition Subdivision.h:47