OGS
BaseLib::GradualSubdivisionFixedNum Class Reference

Detailed Description

Gradual subdivision operator with a constant multiplier_.

In this class the number of subdivisions is known a priori.

Definition at line 97 of file Subdivision.h.

#include <Subdivision.h>

Inheritance diagram for BaseLib::GradualSubdivisionFixedNum:
[legend]
Collaboration diagram for BaseLib::GradualSubdivisionFixedNum:
[legend]

Public Member Functions

 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.
 
- Public Member Functions inherited from BaseLib::ISubdivision
virtual ~ISubdivision ()=default
 

Private Attributes

const double length_
 
const std::size_t num_subdivisions_
 
const double multiplier_
 

Constructor & Destructor Documentation

◆ GradualSubdivisionFixedNum()

BaseLib::GradualSubdivisionFixedNum::GradualSubdivisionFixedNum ( const double L,
const std::size_t num_subdivisions,
const double multiplier )

Constructor

Parameters
Ltotal length to be subdivided
num_subdivisionsnumber of subdivisions to generate
multipliermultiplier to cell length

Definition at line 68 of file Subdivision.cpp.

70 : length_{L}, num_subdivisions_{num_subdivisions}, multiplier_{multiplier}
71{
72}

Member Function Documentation

◆ operator()()

std::vector< double > BaseLib::GradualSubdivisionFixedNum::operator() ( ) const
overridevirtual

Returns a vector of subdivided points.

Implements BaseLib::ISubdivision.

Definition at line 74 of file Subdivision.cpp.

75{
76 std::vector<double> subdivisions;
77 subdivisions.reserve(num_subdivisions_ + 1);
78 subdivisions.push_back(0.0);
79 auto const q = multiplier_;
80
81 if (q == 1.0)
82 {
83 double const dx = length_ / num_subdivisions_;
84
85 for (std::size_t i = 1; i < num_subdivisions_; ++i)
86 {
87 subdivisions.push_back(dx * i);
88 }
89 }
90 else
91 {
92 // compute initial subdivision size
93 auto const a =
94 length_ * (q - 1.0) / (std::pow(q, num_subdivisions_) - 1.0);
95
96 double qi = q; // q^i
97 for (std::size_t i = 1; i < num_subdivisions_; ++i)
98 {
99 subdivisions.push_back(a * (qi - 1.0) / (q - 1.0));
100 qi *= q;
101 }
102 }
103
104 subdivisions.push_back(length_);
105
106 return subdivisions;
107}

References length_, multiplier_, and num_subdivisions_.

Member Data Documentation

◆ length_

const double BaseLib::GradualSubdivisionFixedNum::length_
private

Definition at line 114 of file Subdivision.h.

Referenced by operator()().

◆ multiplier_

const double BaseLib::GradualSubdivisionFixedNum::multiplier_
private

Definition at line 116 of file Subdivision.h.

Referenced by operator()().

◆ num_subdivisions_

const std::size_t BaseLib::GradualSubdivisionFixedNum::num_subdivisions_
private

Definition at line 115 of file Subdivision.h.

Referenced by operator()().


The documentation for this class was generated from the following files: