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

Regular mesh in 1d space. More...

#include <plask/mesh/regular1d.hpp>

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

Public Types

typedef double PointType
 Type of points in this mesh.
 
typedef IndexedIterator< const RegularAxis, PointTypenative_const_iterator
 
- 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
 
 RegularAxis ()
 Construct uninitialized mesh.
 
 RegularAxis (const RegularAxis &src)
 Copy constructor. It does not copy owner.
 
 RegularAxis (double first, double last, std::size_t points_count)
 Construct mesh with given parameters.
 
RegularAxisoperator= (const RegularAxis &src)
 Assign a new mesh. This operation preserves the owner.
 
void reset (double first, double last, std::size_t points_count)
 Set new mesh parameters.
 
double first () const
 
double last () const
 
double step () const
 
std::size_t size () const override
 
bool operator== (const RegularAxis &to_compare) const
 Compare meshes.
 
bool operator!= (const RegularAxis &to_compare) const
 Compare meshes.
 
bool empty () const override
 
double operator[] (std::size_t index) const
 Get point by index.
 
double at (std::size_t index) const override
 Get point with given mesh index.
 
void clear ()
 Remove all points from mesh.
 
std::size_t findIndex (double to_find) const override
 Find index where to_find point could be inserted.
 
native_const_iterator find (double to_find) const
 Find position where to_find point could be inserted.
 
std::size_t findUpIndex (double to_find) const override
 Find the lowest index for which coordinate is larger than to_find.
 
native_const_iterator findUp (double to_find) const
 Find the lowest position for with a coordinate 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.
 
shared_ptr< MeshAxisclone () const override
 Create new mesh which has copy of data included in this.
 
void writeXML (XMLElement &object) const override
 Write mesh to XML.
 
bool isIncreasing () const override
 
shared_ptr< MeshAxisgetMidpointAxis () const override
 Return an axis that enables iterating over middle points of the ranges.
 
template<typename RandomAccessContainer >
auto interpolateLinear (const RandomAccessContainer &data, double point) -> typename std::remove_reference< decltype(data[0])>::type
 Calculate (using linear interpolation) value of data in point using data in points describe by this mesh.
 
- 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 ~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 ()
 

Protected Member Functions

bool hasSameNodes (const MeshD< 1 > &to_compare) const override
 
- 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.
 

Additional Inherited Members

- Public Attributes inherited from plask::Mesh
boost::signals2::signal< void(Event &)> changed
 Changed signal, fired when mesh was changed.
 

Detailed Description

Regular mesh in 1d space.

Definition at line 34 of file regular1d.hpp.

Member Typedef Documentation

◆ native_const_iterator

◆ PointType

Type of points in this mesh.

Definition at line 42 of file regular1d.hpp.

Constructor & Destructor Documentation

◆ RegularAxis() [1/3]

plask::RegularAxis::RegularAxis ( )
inline

Construct uninitialized mesh.

Definition at line 53 of file regular1d.hpp.

◆ RegularAxis() [2/3]

plask::RegularAxis::RegularAxis ( const RegularAxis src)
inline

Copy constructor. It does not copy owner.

Definition at line 57 of file regular1d.hpp.

◆ RegularAxis() [3/3]

plask::RegularAxis::RegularAxis ( double  first,
double  last,
std::size_t  points_count 
)
inline

Construct mesh with given parameters.

Parameters
firstcoordinate of first point in mesh
lastcoordinate of last point in mesh
points_countnumber of points in mesh

Definition at line 66 of file regular1d.hpp.

Member Function Documentation

◆ at()

double plask::RegularAxis::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 129 of file regular1d.hpp.

◆ begin()

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

Definition at line 47 of file regular1d.hpp.

◆ clear()

void plask::RegularAxis::clear ( )
inline

Remove all points from mesh.

Definition at line 134 of file regular1d.hpp.

◆ clone()

shared_ptr< MeshAxis > plask::RegularAxis::clone ( ) const
inlineoverridevirtual

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 184 of file regular1d.hpp.

◆ empty()

bool plask::RegularAxis::empty ( ) const
inlineoverridevirtual
Returns
true only if there are no points in mesh

Reimplemented from plask::Mesh.

Definition at line 120 of file regular1d.hpp.

◆ end()

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

Definition at line 50 of file regular1d.hpp.

◆ find()

native_const_iterator plask::RegularAxis::find ( double  to_find) const
inline

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 152 of file regular1d.hpp.

◆ findIndex()

std::size_t plask::RegularAxis::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 140 of file regular1d.hpp.

◆ findNearest()

native_const_iterator plask::RegularAxis::findNearest ( double  to_find) const
inline

Find position nearest to to_find.

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

Definition at line 173 of file regular1d.hpp.

◆ findNearestIndex()

std::size_t plask::RegularAxis::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 182 of file regular1d.hpp.

◆ findUp()

native_const_iterator plask::RegularAxis::findUp ( double  to_find) const
inline

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 164 of file regular1d.hpp.

◆ findUpIndex()

std::size_t plask::RegularAxis::findUpIndex ( double  to_find) const
overridevirtual

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 35 of file regular1d.cpp.

◆ first()

double plask::RegularAxis::first ( ) const
inline
Returns
coordinate of the first point in the mesh

Definition at line 84 of file regular1d.hpp.

◆ getMidpointAxis()

shared_ptr< MeshAxis > plask::RegularAxis::getMidpointAxis ( ) const
overridevirtual

Return an axis that enables iterating over middle points of the ranges.

Throw exception if this mesh has less than two points.

Returns
new rectilinear mesh with points in the middles of original ranges

Reimplemented from plask::MeshAxis.

Definition at line 54 of file regular1d.cpp.

◆ hasSameNodes()

bool plask::RegularAxis::hasSameNodes ( const MeshD< 1 > &  to_compare) const
overrideprotected

Definition at line 66 of file regular1d.cpp.

◆ interpolateLinear()

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

Calculate (using linear interpolation) value of data in point using data in points describe 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 208 of file regular1d.hpp.

◆ isIncreasing()

bool plask::RegularAxis::isIncreasing ( ) const
overridevirtual
Returns
true only if points are in increasing order, false if points are in decreasing order

Implements plask::MeshAxis.

Definition at line 49 of file regular1d.cpp.

◆ last()

double plask::RegularAxis::last ( ) const
inline
Returns
coordinate of the last point in the mesh

Definition at line 89 of file regular1d.hpp.

◆ operator!=()

bool plask::RegularAxis::operator!= ( const RegularAxis to_compare) const
inline

Compare meshes.

It uses algorithm which has constant time complexity.

Parameters
to_comparemesh to compare
Returns
true only if this mesh and to_compare represents different sets of points

Definition at line 115 of file regular1d.hpp.

◆ operator=()

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

Assign a new mesh. This operation preserves the owner.

Definition at line 20 of file regular1d.cpp.

◆ operator==()

bool plask::RegularAxis::operator== ( const RegularAxis to_compare) const
inline

Compare meshes.

It uses algorithm which has constant 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 105 of file regular1d.hpp.

◆ operator[]()

double plask::RegularAxis::operator[] ( std::size_t  index) const
inline

Get point by index.

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

Definition at line 127 of file regular1d.hpp.

◆ reset()

void plask::RegularAxis::reset ( double  first,
double  last,
std::size_t  points_count 
)

Set new mesh parameters.

Parameters
firstcoordinate of first point in mesh
lastcoordinate of last point in mesh
points_countnumber of points in mesh

Definition at line 27 of file regular1d.cpp.

◆ size()

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

Implements plask::Mesh.

Definition at line 97 of file regular1d.hpp.

◆ step()

double plask::RegularAxis::step ( ) const
inline
Returns
distance between two neighboring points in the mesh

Definition at line 94 of file regular1d.hpp.

◆ writeXML()

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

Write mesh to XML.

Parameters
objectXML object to write to

Reimplemented from plask::Mesh.

Definition at line 45 of file regular1d.cpp.


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