Skip to content
Snippets Groups Projects
Commit f0c1c692 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[BL] moved code, fixed includes

parent 665ae756
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,9 @@
#include "Subdivision.h"
#include <algorithm>
#include <cmath>
#include <BaseLib/Error.h>
namespace BaseLib
......@@ -31,6 +34,29 @@ GradualSubdivision::GradualSubdivision(const double L,
}
}
std::vector<double> GradualSubdivision::operator()() const
{
std::vector<double> vec_x;
double x = 0;
unsigned i = 0;
do {
vec_x.push_back(x);
x += std::min(_max_dL,
_dL0 * std::pow(_multiplier, static_cast<double>(i)));
i++;
} while (x < _length);
if (vec_x.back() < _length) {
double last_dx = vec_x[vec_x.size() - 1] - vec_x[vec_x.size() - 2];
if (_length - vec_x.back() < last_dx)
vec_x[vec_x.size() - 1] = _length;
else
vec_x.push_back(_length);
}
return vec_x;
}
GradualSubdivisionFixedNum::GradualSubdivisionFixedNum(
const double L, const std::size_t num_subdivisions, const double multiplier)
: _length{L}, _num_subdivisions{num_subdivisions}, _multiplier{multiplier}
......
......@@ -9,7 +9,6 @@
#pragma once
#include <cmath>
#include <vector>
namespace BaseLib
......@@ -77,27 +76,7 @@ public:
const double multiplier);
/// Returns a vector of subdivided points
std::vector<double> operator()() const override
{
std::vector<double> vec_x;
double x = 0;
unsigned i=0;
do {
vec_x.push_back(x);
x += std::min(_max_dL, _dL0*std::pow(_multiplier, static_cast<double>(i)));
i++;
} while (x<_length);
if (vec_x.back() < _length) {
double last_dx = vec_x[vec_x.size()-1] - vec_x[vec_x.size()-2];
if (_length-vec_x.back()<last_dx)
vec_x[vec_x.size()-1] = _length;
else
vec_x.push_back(_length);
}
return vec_x;
}
std::vector<double> operator()() const override;
private:
const double _length;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment