PLaSK library
|
Rectilinear mesh in 1D space. More...
#include <plask/mesh/ordered1d.hpp>
Classes | |
struct | WarningOff |
Public Types | |
typedef double | PointType |
Type of points in this mesh. | |
typedef std::vector< double >::const_iterator | native_const_iterator |
Random access iterator type which allow iterate over all points in this mesh, in ascending order. | |
Public Types inherited from plask::MeshD< 1 > | |
enum | |
Number of dimensions. More... | |
typedef Primitive< DIM >::DVec | LocalCoords |
Type of vector representing coordinates in local space. | |
typedef IndexedIterator< const MeshD< dimension >, LocalCoords > | const_iterator |
Random access iterator type which allow iterate over all points in this mesh, in order appointed by operator[]. | |
typedef const_iterator | iterator |
typedef const_iterator | Iterator |
Public Member Functions | |
native_const_iterator | begin () const |
native_const_iterator | end () const |
const std::vector< double > & | getPointsVector () const |
native_const_iterator | find (double to_find) const |
Find position where to_find point could be inserted. | |
std::size_t | findIndex (double to_find) const override |
Find index where to_find point could be inserted. | |
native_const_iterator | findUp (double to_find) const |
Find the lowest position for with a coordinate larger than to_find . | |
std::size_t | findUpIndex (double to_find) const override |
Find the lowest index for which coordinate is larger than to_find . | |
native_const_iterator | findNearest (double to_find) const |
Find position nearest to to_find . | |
std::size_t | findNearestIndex (double to_find) const override |
Find index nearest to to_find . | |
OrderedAxis () | |
Construct an empty mesh. | |
OrderedAxis (const OrderedAxis &src) | |
Copy constructor. It does not copy the owner. | |
OrderedAxis (OrderedAxis &&src) | |
Move constructor. It does not move the owner. | |
OrderedAxis (const MeshAxis &src) | |
Copy constructor from any MeshAxis. | |
OrderedAxis (std::initializer_list< PointType > points, double min_dist=MIN_DISTANCE) | |
Construct mesh with given points. | |
OrderedAxis (const std::vector< PointType > &points, double min_dist=MIN_DISTANCE) | |
Construct mesh with points given in a vector. | |
OrderedAxis (std::vector< PointType > &&points, double min_dist=MIN_DISTANCE) | |
Construct mesh with points given in a vector. | |
OrderedAxis & | operator= (const OrderedAxis &src) |
Assign a new mesh. This operation preserves the owner. | |
OrderedAxis & | operator= (OrderedAxis &&src) |
Assign a new mesh. This operation preserves the owner. | |
OrderedAxis & | operator= (const MeshAxis &src) |
Assign a new mesh. This operation preserves the owner. | |
bool | operator== (const OrderedAxis &to_compare) const |
Compares meshes It use algorithm which has linear time complexity. | |
void | writeXML (XMLElement &object) const override |
Write mesh to XML. | |
std::size_t | size () const override |
double | at (std::size_t index) const override |
Get point with given mesh index. | |
bool | addPoint (double new_node_cord, double min_dist) |
Add (1d) point to this mesh. | |
bool | addPoint (double new_node_cord) |
Add (1d) point to this mesh. | |
void | removePoint (std::size_t index) |
Remove point at specified index. | |
void | removePoints (std::size_t start, std::size_t stop) |
Remove range of points between specified indices. | |
void | removePoints (std::size_t start, std::size_t stop, std::ptrdiff_t step) |
Remove range of points between specified indices. | |
template<typename IteratorT > | |
void | addOrderedPoints (IteratorT begin, IteratorT end, std::size_t points_count_hint, double min_dist=MIN_DISTANCE) |
Add points from ordered range. | |
template<typename RandomAccessIteratorT > | |
void | addOrderedPoints (RandomAccessIteratorT begin, RandomAccessIteratorT end) |
Add points from ordered range. | |
void | addPointsLinear (double first, double last, std::size_t points_count) |
Add to mesh points: first + i * (last-first) / points_count, where i is in range [0, points_count]. | |
void | clear () |
Get point by index. | |
shared_ptr< MeshAxis > | clone () const override |
Create new mesh which has copy of data included in this . | |
bool | isIncreasing () const override |
template<typename RandomAccessContainer > | |
auto | interpolateLinear (const RandomAccessContainer &data, double point) const -> typename std::remove_reference< decltype(data[0])>::type |
Calculate (using linear interpolation) value of data in point using data in points described by this mesh. | |
Public Member Functions inherited from plask::MeshAxis | |
virtual shared_ptr< MeshAxis > | getMidpointAxis () const |
Return an axis that enables iterating over middle points of the ranges. | |
Public Member Functions inherited from plask::MeshD< 1 > | |
LocalCoords | operator[] (std::size_t index) const |
Get point with given mesh index. | |
const_iterator | begin () const |
const_iterator | end () const |
MeshD (const MeshD &PLASK_UNUSED(to_copy)) | |
Initialize this to be the same as to_copy but don't copy any changes observer. | |
MeshD () | |
MeshD & | operator= (const MeshD &PLASK_UNUSED(to_copy)) |
Set this to be the same as to_copy but doesn't changed changes observer. | |
bool | operator== (const MeshD &to_compare) const |
Check if this mesh and to_compare represent the same sequence of points (have exactly the same points in the same order). | |
bool | operator!= (const MeshD &to_compare) const |
Check if this mesh and to_compare represent different sequences of points. | |
void | print (std::ostream &out) const override |
Print this to stream out . | |
Public Member Functions inherited from plask::Mesh | |
template<typename ClassT , typename methodT > | |
boost::signals2::connection | changedConnectMethod (ClassT *obj, methodT method, boost::signals2::connect_position at=boost::signals2::at_back) |
Connect a method to changed signal. | |
template<typename ClassT , typename methodT > | |
void | changedDisconnectMethod (ClassT *obj, methodT method) |
template<typename EventT = Event, typename ... Args> | |
void | fireChanged (Args &&... event_constructor_params_without_source) |
Call changed with this as event source. | |
void | fireResized () |
This method is called when the mesh is resized. | |
virtual bool | empty () const |
virtual | ~Mesh () |
Public Member Functions inherited from plask::Printable | |
virtual | ~Printable () |
std::string | str () const |
Get string representation of this using print method. | |
Public Member Functions inherited from plask::MeshBase | |
virtual | ~MeshBase () |
Public Attributes | |
bool | warn_too_close |
Should a warning be issued if the points are too close. | |
Public Attributes inherited from plask::Mesh | |
boost::signals2::signal< void(Event &)> | changed |
Changed signal, fired when mesh was changed. | |
Static Public Attributes | |
static constexpr double | MIN_DISTANCE = 1e-6 |
Maximum difference between the points, so they are treated as one. | |
Additional Inherited Members | |
Protected Member Functions inherited from plask::MeshAxis | |
void | beforeCalcMidpointMesh () const |
Throw exception if this mesh has less than two point. | |
Protected Member Functions inherited from plask::MeshD< 1 > | |
virtual bool | hasSameNodes (const MeshD< dimension > &to_compare) const |
Check if this mesh and to_compare represent the same sequence of points (have exactly the same points in the same order). | |
Protected Member Functions inherited from plask::Mesh | |
virtual void | onChange (const Event &evt) |
This method is called when the mesh is changed, just before changed signal. | |
Rectilinear mesh in 1D space.
Definition at line 38 of file ordered1d.hpp.
Random access iterator type which allow iterate over all points in this mesh, in ascending order.
Definition at line 66 of file ordered1d.hpp.
Type of points in this mesh.
Definition at line 63 of file ordered1d.hpp.
|
inline |
Construct an empty mesh.
Definition at line 109 of file ordered1d.hpp.
|
inline |
Copy constructor. It does not copy the owner.
Definition at line 112 of file ordered1d.hpp.
|
inline |
Move constructor. It does not move the owner.
Definition at line 115 of file ordered1d.hpp.
Copy constructor from any MeshAxis.
Definition at line 118 of file ordered1d.hpp.
plask::OrderedAxis::OrderedAxis | ( | std::initializer_list< PointType > | points, |
double | min_dist = MIN_DISTANCE |
||
) |
Construct mesh with given points.
It use algorithm which has logarithmic time complexity.
points | points, in any order |
min_dist | minimum distance to the existing point |
Definition at line 28 of file ordered1d.cpp.
plask::OrderedAxis::OrderedAxis | ( | const std::vector< PointType > & | points, |
double | min_dist = MIN_DISTANCE |
||
) |
Construct mesh with points given in a vector.
It use algorithm which has logarithmic time complexity per point in points
.
points | points, in any order |
min_dist | minimum distance to the existing point |
Definition at line 32 of file ordered1d.cpp.
plask::OrderedAxis::OrderedAxis | ( | std::vector< PointType > && | points, |
double | min_dist = MIN_DISTANCE |
||
) |
Construct mesh with points given in a vector.
It use algorithm which has logarithmic time complexity per point in points
.
points | points, in any order |
min_dist | minimum distance to the existing point |
Definition at line 36 of file ordered1d.cpp.
|
inline |
Add points from ordered range.
It uses algorithm which has linear time complexity.
begin,end | ordered range of points in ascending order |
points_count_hint | number of points in range (can be approximate, or 0) |
min_dist | minimum distance to the existing point |
IteratorT | input iterator |
Definition at line 286 of file ordered1d.hpp.
|
inline |
Add points from ordered range.
It uses algorithm which has linear time complexity.
begin,end | ordered range of points in ascending order |
RandomAccessIteratorT | random access iterator |
Definition at line 237 of file ordered1d.hpp.
Add (1d) point to this mesh.
Point is added to mesh only if it is not already included in it. It use algorithm which has O(size()) time complexity.
new_node_cord | coordinate of point to add |
true
if the point has been inserted Definition at line 193 of file ordered1d.hpp.
Add (1d) point to this mesh.
Point is added to mesh only if it is not closer than the specified minimum distance to the existing one. It use algorithm which has O(size()) time complexity.
new_node_cord | coordinate of point to add |
min_dist | minimum distance to the existing point |
true
if the point has been inserted Definition at line 92 of file ordered1d.cpp.
Add to mesh points: first + i * (last-first) / points_count, where i is in range [0, points_count].
It uses algorithm which has linear time complexity.
first | coordinate of the first point |
last | coordinate of the last point |
points_count | number of points to add |
Definition at line 111 of file ordered1d.cpp.
|
inlineoverridevirtual |
Get point with given mesh index.
index | index of point, from 0 to size()-1 |
index
Implements plask::MeshD< 1 >.
Definition at line 171 of file ordered1d.hpp.
|
inline |
Definition at line 69 of file ordered1d.hpp.
void plask::OrderedAxis::clear | ( | ) |
Get point by index.
index | index of point, from 0 to size()-1 |
index
Remove all points from mesh. Definition at line 153 of file ordered1d.cpp.
|
overridevirtual |
Create new mesh which has copy of data included in this
.
By default RectangularMesh is used for result, but subclasses can use another types for less memory usage or better performance.
this
Reimplemented from plask::MeshAxis.
Definition at line 158 of file ordered1d.cpp.
|
inline |
Definition at line 72 of file ordered1d.hpp.
OrderedAxis::native_const_iterator plask::OrderedAxis::find | ( | double | to_find | ) | const |
Find position where to_find
point could be inserted.
to_find | point to find |
to_find
only if to_find
is already in mesh, in other case it refer to value bigger than to_find. Can be equal to end() if to_find is higher than all points in mesh (in such case returned iterator can't be dereferenced). Definition at line 56 of file ordered1d.cpp.
|
inlineoverridevirtual |
Find index where to_find
point could be inserted.
to_find | point to find |
to_find
only if to_find
is already in mesh, in other case it refer to value larger than to_find. Can be equal to size() if to_find
is larger than all points in mesh. Reimplemented from plask::MeshAxis.
Definition at line 87 of file ordered1d.hpp.
OrderedAxis::native_const_iterator plask::OrderedAxis::findNearest | ( | double | to_find | ) | const |
Find position nearest to to_find
.
to_find | position to find |
Definition at line 64 of file ordered1d.cpp.
|
inlineoverridevirtual |
Find index nearest to to_find
.
to_find |
Reimplemented from plask::MeshAxis.
Definition at line 106 of file ordered1d.hpp.
OrderedAxis::native_const_iterator plask::OrderedAxis::findUp | ( | double | to_find | ) | const |
Find the lowest position for with a coordinate larger than to_find
.
to_find | point to find |
to_find
. It equals to end() if to_find
is larger than all points in mesh or equals to the last point. Definition at line 60 of file ordered1d.cpp.
|
inlineoverridevirtual |
Find the lowest index for which coordinate is larger than to_find
.
to_find | point to find |
to_find
. Can be equal to size() if to_find
is larger than all points in mesh or equals to the last point. Reimplemented from plask::MeshAxis.
Definition at line 97 of file ordered1d.hpp.
Definition at line 75 of file ordered1d.hpp.
|
inline |
Calculate (using linear interpolation) value of data in point using data in points described by this mesh.
data | values of data in points describe by this mesh |
point | point in which value should be calculate |
point
Definition at line 277 of file ordered1d.hpp.
|
inlineoverridevirtual |
true
only if points are in increasing order, false
if points are in decreasing order Implements plask::MeshAxis.
Definition at line 262 of file ordered1d.hpp.
OrderedAxis & plask::OrderedAxis::operator= | ( | const MeshAxis & | src | ) |
Assign a new mesh. This operation preserves the owner.
Definition at line 68 of file ordered1d.cpp.
OrderedAxis & plask::OrderedAxis::operator= | ( | const OrderedAxis & | src | ) |
Assign a new mesh. This operation preserves the owner.
Definition at line 85 of file ordered1d.cpp.
OrderedAxis & plask::OrderedAxis::operator= | ( | OrderedAxis && | src | ) |
Assign a new mesh. This operation preserves the owner.
Definition at line 78 of file ordered1d.cpp.
bool plask::OrderedAxis::operator== | ( | const OrderedAxis & | to_compare | ) | const |
Compares meshes It use algorithm which has linear time complexity.
to_compare | mesh to compare |
true
only if this mesh and to_compare
represents the same set of points Definition at line 40 of file ordered1d.cpp.
void plask::OrderedAxis::removePoint | ( | std::size_t | index | ) |
Remove point at specified index.
index | index of the point to remove |
Definition at line 120 of file ordered1d.cpp.
void plask::OrderedAxis::removePoints | ( | std::size_t | start, |
std::size_t | stop | ||
) |
Remove range of points between specified indices.
start | index of the first point to remove |
stop | index of the first point keep |
Definition at line 125 of file ordered1d.cpp.
void plask::OrderedAxis::removePoints | ( | std::size_t | start, |
std::size_t | stop, | ||
std::ptrdiff_t | step | ||
) |
Remove range of points between specified indices.
start | index of the first point to remove |
stop | index of the first point keep |
step | step to remove poinst |
Definition at line 130 of file ordered1d.cpp.
|
inlineoverridevirtual |
Implements plask::Mesh.
Definition at line 169 of file ordered1d.hpp.
|
overridevirtual |
Write mesh to XML.
object | XML object to write to |
Reimplemented from plask::Mesh.
Definition at line 44 of file ordered1d.cpp.
Maximum difference between the points, so they are treated as one.
Definition at line 60 of file ordered1d.hpp.
bool plask::OrderedAxis::warn_too_close |
Should a warning be issued if the points are too close.
Definition at line 57 of file ordered1d.hpp.