6 enum class GridType { loglinear, logarithmic, linear };
10 std::size_t num_points;
16 double inrmax = 1.0,
double inb = 4.0,
17 GridType intype = GridType::loglinear,
double indu = 0);
20 GridParameters(std::size_t innum_points,
double inr0,
double inrmax,
21 double inb,
const std::string &str_type =
"loglinear",
24 static GridType parseType(
const std::string &str_type);
25 static std::string parseType(GridType type);
43 std::vector<double> m_r;
45 std::vector<double> m_drduor;
47 std::vector<double> m_drdu;
51 Grid(
double in_r0,
double in_rmax, std::size_t in_num_points,
52 GridType in_gridtype,
double in_b = 0);
58 auto r0()
const {
return m_r.front(); }
59 auto front()
const {
return m_r.front(); }
61 auto rmax()
const {
return m_r.back(); }
62 auto back()
const {
return m_r.back(); }
68 auto du()
const {
return m_du; }
70 auto type()
const {
return gridtype; }
75 const std::vector<double> &
r()
const {
return m_r; }
76 auto r(std::size_t i)
const {
return m_r.at(i); };
77 auto at(std::size_t i)
const {
return m_r.at(i); };
78 auto operator()(std::size_t i)
const {
return r(i); }
80 const std::vector<double> &
drdu()
const {
return m_drdu; };
81 auto drdu(std::size_t i)
const {
return m_drdu.at(i); };
83 const std::vector<double> &
drduor()
const {
return m_drduor; };
84 auto drduor(std::size_t i)
const {
return m_drduor.at(i); };
87 std::size_t
getIndex(
double x,
bool require_nearest =
false)
const;
93 std::vector<double>
rpow(
double k)
const;
96 auto begin()
const {
return m_r.cbegin(); }
97 auto end()
const {
return m_r.cend(); }
98 auto cbegin()
const {
return m_r.cbegin(); }
99 auto cend()
const {
return m_r.cend(); }
100 auto rbegin()
const {
return m_r.crbegin(); }
101 auto rend()
const {
return m_r.crend(); }
102 auto crbegin()
const {
return m_r.crbegin(); }
103 auto crend()
const {
return m_r.crend(); }
120 std::size_t in_num_points,
121 GridType in_gridtype,
double in_b = 0);
124 double in_du, GridType in_gridtype,
128 static double next_r_loglin(
double b,
double u,
double r_guess);
129 static std::vector<double> form_r(
const GridType type,
const double r0,
131 const double du,
const double b);
132 static std::vector<double> form_drduor(
const GridType type,
133 const std::vector<double> &in_r,
135 static std::vector<double> form_drdu(
const GridType type,
136 const std::vector<double> &in_r,
137 const std::vector<double> &in_drduor);
Holds grid, including type + Jacobian (dr/du)
Definition: Grid.hpp:31
const std::vector< double > & drduor() const
Convinient: (1/r)*(dr/du)
Definition: Grid.hpp:83
auto size() const
Number of grid points.
Definition: Grid.hpp:66
auto r0() const
Minium (first) grid point.
Definition: Grid.hpp:58
auto begin() const
Provide iterators, but only onst ones.
Definition: Grid.hpp:96
std::vector< double > rpow(double k) const
Calculates+returns vector of 1/r.
Definition: Grid.cpp:120
auto du() const
Linear step size dr = (dr/dr)*du.
Definition: Grid.hpp:68
Grid(double in_r0, double in_rmax, std::size_t in_num_points, GridType in_gridtype, double in_b=0)
Manual constructor.
Definition: Grid.cpp:64
void extend_to(double new_rmax)
Extends grid to new_r_max. Note: This is the only non-const function; use with caution.
Definition: Grid.cpp:132
std::string gridParameters() const
String human-readable grid parameters.
Definition: Grid.cpp:102
static double calc_du_from_num_points(double in_r0, double in_rmax, std::size_t in_num_points, GridType in_gridtype, double in_b=0)
Given r0/rmax + num_points, calculates du.
Definition: Grid.cpp:257
static std::size_t calc_num_points_from_du(double in_r0, double in_rmax, double in_du, GridType in_gridtype, double in_b=0)
Given r0/rmax + du, calculates num_points.
Definition: Grid.cpp:277
const std::vector< double > & drdu() const
Jacobian (dr/du)[i].
Definition: Grid.hpp:80
auto type() const
Grid-type (linear, logarithmic, loglinear)
Definition: Grid.hpp:70
auto num_points() const
Number of grid points.
Definition: Grid.hpp:64
auto rmax() const
Maximum (final) grid point.
Definition: Grid.hpp:61
std::size_t getIndex(double x, bool require_nearest=false) const
Given value, returns grid index. if not require_nearest, returns lower.
Definition: Grid.cpp:76
const std::vector< double > & r() const
Grid points, r.
Definition: Grid.hpp:75
auto loglin_b() const
log-linear grid 'turning point' (~ roughly log for r<b, lin for r>b)
Definition: Grid.hpp:72
GridParameters params() const
Returns set of paramets; may be used to construct grid.
Definition: Grid.hpp:113
Parmaters used to create Grid.
Definition: Grid.hpp:9
GridParameters(std::size_t innum_points=1, double inr0=1.0, double inrmax=1.0, double inb=4.0, GridType intype=GridType::loglinear, double indu=0)
indu is optional. Only used if innum_points = 0 [then, uses du to find N]
Definition: Grid.cpp:24