PLaSK library
Loading...
Searching...
No Matches
plask::OrderedAxis Class Reference

Rectilinear mesh in 1D space. More...

#include <plask/mesh/ordered1d.hpp>

Inheritance diagram for plask::OrderedAxis:
[legend]
Collaboration diagram for plask::OrderedAxis:
[legend]

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 >, LocalCoordsconst_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.
 
OrderedAxisoperator= (const OrderedAxis &src)
 Assign a new mesh. This operation preserves the owner.
 
OrderedAxisoperator= (OrderedAxis &&src)
 Assign a new mesh. This operation preserves the owner.
 
OrderedAxisoperator= (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< MeshAxisclone () 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< MeshAxisgetMidpointAxis () 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 ()
 
MeshDoperator= (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.
 

Detailed Description

Rectilinear mesh in 1D space.

Definition at line 38 of file ordered1d.hpp.

Member Typedef Documentation

◆ native_const_iterator

Random access iterator type which allow iterate over all points in this mesh, in ascending order.

Definition at line 66 of file ordered1d.hpp.

◆ PointType

Type of points in this mesh.

Definition at line 63 of file ordered1d.hpp.

Constructor & Destructor Documentation

◆ OrderedAxis() [1/7]

plask::OrderedAxis::OrderedAxis ( )
inline

Construct an empty mesh.

Definition at line 109 of file ordered1d.hpp.

◆ OrderedAxis() [2/7]

plask::OrderedAxis::OrderedAxis ( const OrderedAxis src)
inline

Copy constructor. It does not copy the owner.

Definition at line 112 of file ordered1d.hpp.

◆ OrderedAxis() [3/7]

plask::OrderedAxis::OrderedAxis ( OrderedAxis &&  src)
inline

Move constructor. It does not move the owner.

Definition at line 115 of file ordered1d.hpp.

◆ OrderedAxis() [4/7]

plask::OrderedAxis::OrderedAxis ( const MeshAxis src)
inline

Copy constructor from any MeshAxis.

Definition at line 118 of file ordered1d.hpp.

◆ OrderedAxis() [5/7]

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.

Parameters
pointspoints, in any order
min_distminimum distance to the existing point

Definition at line 28 of file ordered1d.cpp.

◆ OrderedAxis() [6/7]

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.

Parameters
pointspoints, in any order
min_distminimum distance to the existing point

Definition at line 32 of file ordered1d.cpp.

◆ OrderedAxis() [7/7]

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.

Parameters
pointspoints, in any order
min_distminimum distance to the existing point

Definition at line 36 of file ordered1d.cpp.

Member Function Documentation

◆ addOrderedPoints() [1/2]

template<typename IteratorT >
void plask::OrderedAxis::addOrderedPoints ( IteratorT  begin,
IteratorT  end,
std::size_t  points_count_hint,
double  min_dist = MIN_DISTANCE 
)
inline

Add points from ordered range.

It uses algorithm which has linear time complexity.

Parameters
begin,endordered range of points in ascending order
points_count_hintnumber of points in range (can be approximate, or 0)
min_distminimum distance to the existing point
Template Parameters
IteratorTinput iterator

Definition at line 286 of file ordered1d.hpp.

◆ addOrderedPoints() [2/2]

void plask::OrderedAxis::addOrderedPoints ( RandomAccessIteratorT  begin,
RandomAccessIteratorT  end 
)
inline

Add points from ordered range.

It uses algorithm which has linear time complexity.

Parameters
begin,endordered range of points in ascending order
Template Parameters
RandomAccessIteratorTrandom access iterator

Definition at line 237 of file ordered1d.hpp.

◆ addPoint() [1/2]

bool plask::OrderedAxis::addPoint ( double  new_node_cord)
inline

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.

Parameters
new_node_cordcoordinate of point to add
Returns
true if the point has been inserted

Definition at line 193 of file ordered1d.hpp.

◆ addPoint() [2/2]

bool plask::OrderedAxis::addPoint ( double  new_node_cord,
double  min_dist 
)

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.

Parameters
new_node_cordcoordinate of point to add
min_distminimum distance to the existing point
Returns
true if the point has been inserted

Definition at line 92 of file ordered1d.cpp.

◆ addPointsLinear()

void plask::OrderedAxis::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].

It uses algorithm which has linear time complexity.

Parameters
firstcoordinate of the first point
lastcoordinate of the last point
points_countnumber of points to add

Definition at line 111 of file ordered1d.cpp.

◆ at()

double plask::OrderedAxis::at ( std::size_t  index) const
inlineoverridevirtual

Get point with given mesh index.

Parameters
indexindex of point, from 0 to size()-1
Returns
point with given index

Implements plask::MeshD< 1 >.

Definition at line 171 of file ordered1d.hpp.

◆ begin()

native_const_iterator plask::OrderedAxis::begin ( ) const
inline
Returns
iterator referring to the first point in this mesh

Definition at line 69 of file ordered1d.hpp.

◆ clear()

void plask::OrderedAxis::clear ( )

Get point by index.

Parameters
indexindex of point, from 0 to size()-1
Returns
point with given index Remove all points from mesh.

Definition at line 153 of file ordered1d.cpp.

◆ clone()

shared_ptr< MeshAxis > plask::OrderedAxis::clone ( ) const
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.

Returns
new mesh which has copy of data included in this

Reimplemented from plask::MeshAxis.

Definition at line 158 of file ordered1d.cpp.

◆ end()

native_const_iterator plask::OrderedAxis::end ( ) const
inline
Returns
iterator referring to the past-the-end point in this mesh

Definition at line 72 of file ordered1d.hpp.

◆ find()

OrderedAxis::native_const_iterator plask::OrderedAxis::find ( double  to_find) const

Find position where to_find point could be inserted.

Parameters
to_findpoint to find
Returns
First position where to_find could be insert. Refer to value equal to 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.

◆ findIndex()

std::size_t plask::OrderedAxis::findIndex ( double  to_find) const
inlineoverridevirtual

Find index where to_find point could be inserted.

Parameters
to_findpoint to find
Returns
First index where to_find could be inserted. Refer to value equal to 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.

◆ findNearest()

OrderedAxis::native_const_iterator plask::OrderedAxis::findNearest ( double  to_find) const

Find position nearest to to_find.

Parameters
to_findposition to find
Returns
position pos for which abs(*pos-to_find) is minimal

Definition at line 64 of file ordered1d.cpp.

◆ findNearestIndex()

std::size_t plask::OrderedAxis::findNearestIndex ( double  to_find) const
inlineoverridevirtual

Find index nearest to to_find.

Parameters
to_find
Returns
index i for which abs((*this)[i]-to_find) is minimal

Reimplemented from plask::MeshAxis.

Definition at line 106 of file ordered1d.hpp.

◆ findUp()

OrderedAxis::native_const_iterator plask::OrderedAxis::findUp ( double  to_find) const

Find the lowest position for with a coordinate larger than to_find.

Parameters
to_findpoint to find
Returns
The first position with coordinate larger than 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.

◆ findUpIndex()

std::size_t plask::OrderedAxis::findUpIndex ( double  to_find) const
inlineoverridevirtual

Find the lowest index for which coordinate is larger than to_find.

Parameters
to_findpoint to find
Returns
First index with coordinate larger than 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.

◆ getPointsVector()

const std::vector< double > & plask::OrderedAxis::getPointsVector ( ) const
inline
Returns
vector of points (reference to internal vector)

Definition at line 75 of file ordered1d.hpp.

◆ interpolateLinear()

auto plask::OrderedAxis::interpolateLinear ( const RandomAccessContainer data,
double  point 
) const -> typename std::remove_reference<decltype(data[0])>::type
inline

Calculate (using linear interpolation) value of data in point using data in points described by this mesh.

Parameters
datavalues of data in points describe by this mesh
pointpoint in which value should be calculate
Returns
interpolated value in point point

Definition at line 277 of file ordered1d.hpp.

◆ isIncreasing()

bool plask::OrderedAxis::isIncreasing ( ) const
inlineoverridevirtual
Returns
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.

◆ operator=() [1/3]

OrderedAxis & plask::OrderedAxis::operator= ( const MeshAxis src)

Assign a new mesh. This operation preserves the owner.

Definition at line 68 of file ordered1d.cpp.

◆ operator=() [2/3]

OrderedAxis & plask::OrderedAxis::operator= ( const OrderedAxis src)

Assign a new mesh. This operation preserves the owner.

Definition at line 85 of file ordered1d.cpp.

◆ operator=() [3/3]

OrderedAxis & plask::OrderedAxis::operator= ( OrderedAxis &&  src)

Assign a new mesh. This operation preserves the owner.

Definition at line 78 of file ordered1d.cpp.

◆ operator==()

bool plask::OrderedAxis::operator== ( const OrderedAxis to_compare) const

Compares meshes It use algorithm which has linear time complexity.

Parameters
to_comparemesh to compare
Returns
true only if this mesh and to_compare represents the same set of points

Definition at line 40 of file ordered1d.cpp.

◆ removePoint()

void plask::OrderedAxis::removePoint ( std::size_t  index)

Remove point at specified index.

Parameters
indexindex of the point to remove

Definition at line 120 of file ordered1d.cpp.

◆ removePoints() [1/2]

void plask::OrderedAxis::removePoints ( std::size_t  start,
std::size_t  stop 
)

Remove range of points between specified indices.

Parameters
startindex of the first point to remove
stopindex of the first point keep

Definition at line 125 of file ordered1d.cpp.

◆ removePoints() [2/2]

void plask::OrderedAxis::removePoints ( std::size_t  start,
std::size_t  stop,
std::ptrdiff_t  step 
)

Remove range of points between specified indices.

Parameters
startindex of the first point to remove
stopindex of the first point keep
stepstep to remove poinst

Definition at line 130 of file ordered1d.cpp.

◆ size()

std::size_t plask::OrderedAxis::size ( ) const
inlineoverridevirtual
Returns
number of points in mesh

Implements plask::Mesh.

Definition at line 169 of file ordered1d.hpp.

◆ writeXML()

void plask::OrderedAxis::writeXML ( XMLElement object) const
overridevirtual

Write mesh to XML.

Parameters
objectXML object to write to

Reimplemented from plask::Mesh.

Definition at line 44 of file ordered1d.cpp.

Member Data Documentation

◆ MIN_DISTANCE

constexpr double plask::OrderedAxis::MIN_DISTANCE = 1e-6
staticconstexpr

Maximum difference between the points, so they are treated as one.

Definition at line 60 of file ordered1d.hpp.

◆ warn_too_close

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.


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