PLaSK library
|
Rectangular mesh which uses (and indexes) only chosen elements and all nodes in their corners. More...
#include <plask/mesh/rectangular_masked2d.hpp>
Classes | |
struct | BoundaryIteratorImpl |
struct | BoundaryNodeSetImpl |
class | Element |
struct | ElementMesh |
Element mesh. More... | |
struct | Elements |
Public Types | |
typedef std::function< bool(const RectangularMesh2D::Element &)> | Predicate |
Type of predicate function which returns bool for given element of a mesh. | |
Public Types inherited from plask::RectangularMaskedMeshBase< 2 > | |
enum | |
Returned by some methods to signalize that element or node (with given index(es)) is not included in the mesh. More... | |
typedef const_iterator | iterator |
Iterator over nodes coordinates. The same as const_iterator, since non-const iterators are not supported. | |
Public Member Functions | |
RectangularMaskedMesh2D ()=default | |
Construct empty/uninitialized mesh. | |
void | reset (const Predicate &predicate) |
Change a selection of elements used to once pointed by a given predicate . | |
RectangularMaskedMesh2D (const RectangularMesh< 2 > &fullMesh, const Predicate &predicate, bool clone_axes=false) | |
Construct masked mesh with elements of fullMesh chosen by a predicate . | |
void | reset (const RectangularMesh< 2 > &fullMesh, const Predicate &predicate, bool clone_axes=false) |
Change parameters of this mesh to use elements of fullMesh chosen by a predicate . | |
RectangularMaskedMesh2D (const RectangularMesh< 2 > &fullMesh, const GeometryD< 2 > &geom, const std::function< bool(shared_ptr< const Material >)> materialPredicate, bool clone_axes=false) | |
Construct masked mesh with all elements of fullMesh which have required materials in the midpoints. | |
void | reset (const RectangularMesh< 2 > &rectangularMesh, const GeometryD< 2 > &geom, const std::function< bool(shared_ptr< const Material >)> materialPredicate, bool clone_axes=false) |
Change parameters of this mesh to use all elements of rectangularMesh which have required materials in the midpoints. | |
RectangularMaskedMesh2D (const RectangularMesh< 2 > &rectangularMesh, const GeometryD< 2 > &geom, unsigned materialKinds, bool clone_axes=false) | |
Construct masked mesh with all elements of rectangularMesh which have required kinds of materials (in the midpoints). | |
void | reset (const RectangularMesh< 2 > &rectangularMesh, const GeometryD< 2 > &geom, unsigned materialKinds, bool clone_axes=false) |
Change parameters of this mesh to use all elements of rectangularMesh which have required kinds of materials (in the midpoints). | |
RectangularMaskedMesh2D (const RectangularMesh< DIM > &rectangularMesh, Set nodeSet, bool clone_axes=false) | |
Construct a mesh with given set of nodes. | |
Elements | elements () const |
Elements | getElements () const |
Element | element (std::size_t i0, std::size_t i1) const |
Element | getElement (std::size_t i0, std::size_t i1) const |
Element | element (std::size_t i) const |
Get an element with a given index i . | |
Element | getElement (std::size_t i) const |
Get an element with a given index i . | |
std::size_t | index (std::size_t axis0_index, std::size_t axis1_index) const |
Calculate this mesh index using indexes of axis0 and axis1. | |
Vec< 2, double > | at (std::size_t index0, std::size_t index1) const |
Get point with given mesh indices. | |
Vec< 2, double > | operator() (std::size_t axis0_index, std::size_t axis1_index) const |
Get point with given x and y indexes. | |
shared_ptr< RectangularMaskedMesh2D::ElementMesh > | getElementMesh () const |
Return a mesh that enables iterating over middle points of the selected rectangles. | |
bool | prepareInterpolation (const Vec< 2 > &point, Vec< 2 > &wrapped_point, std::size_t &index0_lo, std::size_t &index0_hi, std::size_t &index1_lo, std::size_t &index1_hi, const InterpolationFlags &flags) const |
Prepare point for interpolation. | |
template<typename RandomAccessContainer > | |
auto | interpolateLinear (const RandomAccessContainer &data, const Vec< 2 > &point, const InterpolationFlags &flags) 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. | |
template<typename RandomAccessContainer > | |
auto | interpolateNearestNeighbor (const RandomAccessContainer &data, const Vec< 2 > &point, const InterpolationFlags &flags) const -> typename std::remove_reference< decltype(data[0])>::type |
Calculate (using nearest neighbor interpolation) value of data in point using data in points described by this mesh. | |
std::size_t | getElementIndexFromLowIndexes (std::size_t axis0_index, std::size_t axis1_index) const |
Convert mesh indexes of a bottom-left corner of an element to the index of this element. | |
double | getElementArea (std::size_t index0, std::size_t index1) const |
Get an area of a given element. | |
Vec< 2, double > | getElementMidpoint (std::size_t index0, std::size_t index1) const |
Get point in center of Elements. | |
Box2D | getElementBox (std::size_t index0, std::size_t index1) const |
Get element as rectangle. | |
BoundaryNodeSet | createVerticalBoundaryAtLine (std::size_t line_nr_axis0) const override |
BoundaryNodeSet | createVerticalBoundaryAtLine (std::size_t line_nr_axis0, std::size_t indexBegin, std::size_t indexEnd) const override |
BoundaryNodeSet | createVerticalBoundaryNear (double axis0_coord) const override |
BoundaryNodeSet | createVerticalBoundaryNear (double axis0_coord, double from, double to) const override |
BoundaryNodeSet | createLeftBoundary () const override |
BoundaryNodeSet | createRightBoundary () const override |
BoundaryNodeSet | createLeftOfBoundary (const Box2D &box) const override |
BoundaryNodeSet | createRightOfBoundary (const Box2D &box) const override |
BoundaryNodeSet | createBottomOfBoundary (const Box2D &box) const override |
BoundaryNodeSet | createTopOfBoundary (const Box2D &box) const override |
BoundaryNodeSet | createHorizontalBoundaryAtLine (std::size_t line_nr_axis1) const override |
BoundaryNodeSet | createHorizontalBoundaryAtLine (std::size_t line_nr_axis1, std::size_t indexBegin, std::size_t indexEnd) const override |
BoundaryNodeSet | createHorizontalBoundaryNear (double axis1_coord) const override |
BoundaryNodeSet | createHorizontalBoundaryNear (double axis1_coord, double from, double to) const override |
BoundaryNodeSet | createTopBoundary () const override |
BoundaryNodeSet | createBottomBoundary () const override |
Public Member Functions inherited from plask::RectangularMaskedMeshBase< 2 > | |
RectangularMaskedMeshBase ()=default | |
Construct an empty mesh. One should use reset() or selectAll() method before using it. | |
RectangularMaskedMeshBase (const RectangularMesh< DIM > &rectangularMesh, Set nodeSet, bool clone_axes=false) | |
Constructor which allows us to construct midpoints mesh. | |
RectangularMaskedMeshBase (const RectangularMesh< DIM > &rectangularMesh, bool clone_axes=false) | |
Construct a mesh by wrap of a given rectangularMesh . | |
const_iterator | begin () const |
const_iterator | end () const |
LocalCoords | at (std::size_t index) const override |
std::size_t | size () const override |
bool | empty () const override |
bool | full () const |
void | selectAll (const RectangularMesh< DIM > &rectangularMesh, bool clone_axes=false) |
Set wrapped mesh and select all its elements. | |
void | selectAll () |
Select all elements of wrapped mesh. | |
std::size_t | index (const Vec< DIM, std::size_t > &indexes) const |
Calculate this mesh index using indexes of axis[0] and axis[1]. | |
std::size_t | index0 (std::size_t mesh_index) const |
Calculate index of axis0 using this mesh index. | |
std::size_t | index1 (std::size_t mesh_index) const |
Calculate index of axis1 using this mesh index. | |
Vec< DIM, std::size_t > | indexes (std::size_t mesh_index) const |
Calculate indexes of axes. | |
std::size_t | majorIndex (std::size_t mesh_index) const |
Calculate index of major axis using given mesh index. | |
std::size_t | minorIndex (std::size_t mesh_index) const |
Calculate index of major axis using given mesh index. | |
std::size_t | getElementsCount0 () const |
Get number of elements (for FEM method) in the first direction. | |
std::size_t | getElementsCount1 () const |
Get number of elements (for FEM method) in the second direction. | |
std::size_t | getElementsCount () const |
Get number of elements (for FEM method). | |
std::size_t | getElementIndexFromLowIndex (std::size_t mesh_index_of_el_bottom_left) const |
Convert mesh index of bottom left element corner to index of this element. | |
std::size_t | getElementMeshLowIndex (std::size_t element_index) const |
Convert element index to mesh index of bottom-left element corner. | |
Vec< DIM, std::size_t > | getElementMeshLowIndexes (std::size_t element_index) const |
Convert an element index to mesh indexes of bottom-left corner of the element. | |
double | getElementArea (std::size_t element_index) const |
Get an area of a given element. | |
double | getElementMidpoint0 (std::size_t index0) const |
Get first coordinate of point in the center of an elements. | |
double | getElementMidpoint1 (std::size_t index1) const |
Get second coordinate of point in the center of an elements. | |
Vec< DIM, double > | getElementMidpoint (std::size_t element_index) const |
Get point in the center of an element. | |
Primitive< DIM >::Box | getElementBox (std::size_t element_index) const |
Get an element as a rectangle. | |
Additional Inherited Members | |
Public Attributes inherited from plask::RectangularMaskedMeshBase< 2 > | |
RectangularMesh< DIM > | fullMesh |
Full, rectangular, wrapped mesh. | |
Static Public Attributes inherited from plask::RectangularMaskedMeshBase< 2 > | |
static constexpr double | MIN_DISTANCE |
Maximum distance from boundary to include in the inerpolation. | |
Protected Types inherited from plask::RectangularMaskedMeshBase< 2 > | |
typedef CompressedSetOfNumbers< std::size_t > | Set |
typedef BoundaryIndexForAxis | BoundaryIndex[DIM] |
Protected Member Functions inherited from plask::RectangularMaskedMeshBase< 2 > | |
void | resetBoundyIndex () |
void | reset () |
Clear nodeSet, elementSet and call resetBoundyIndex(). | |
const Set & | ensureHasElements () const |
Ensure that elementSet is calculated (calculate it if it is not). | |
const BoundaryIndex & | ensureHasBoundaryIndex () const |
Ensure that boundaryIndex is calculated (calculate it if it is not). | |
Static Protected Member Functions inherited from plask::RectangularMaskedMeshBase< 2 > | |
static void | findIndexes (const MeshAxis &axis, double wrapped_point_coord, std::size_t &index_lo, std::size_t &index_hi) |
Used by interpolation. | |
static std::size_t | nearest (double p, const MeshAxis &axis, std::size_t index_lo, std::size_t index_hi) |
Used by nearest neighbor interpolation. | |
Protected Attributes inherited from plask::RectangularMaskedMeshBase< 2 > | |
Set | nodeSet |
Numbers of rectangularMesh indexes which are in the corners of the elements enabled. | |
Set | elementSet |
Numbers of enabled elements. | |
BoundaryIndex | boundaryIndex |
DontCopyThisField< boost::mutex > | writeMutex |
Only one thread can calculate elementSet or boundaryIndex. | |
bool | elementSetInitialized |
Whether elementSet is initialized (default for most constructors). | |
bool | boundaryIndexInitialized |
Whether boundatyIndex is initialized. | |
Rectangular mesh which uses (and indexes) only chosen elements and all nodes in their corners.
Objects of this class can be constructed from instences of full rectangular mesh (RectangularMaskedMesh2D) and they can use the same boundary conditions (BoundaryConditions instance for full mesh accepts also objects of this class). Interpolation methods return NaN-s for all elements which have not been chosen.
Definition at line 28 of file rectangular_masked2d.hpp.
typedef std::function<bool(const RectangularMesh2D::Element&)> plask::RectangularMaskedMesh2D::Predicate |
Type of predicate function which returns bool for given element of a mesh.
Definition at line 31 of file rectangular_masked2d.hpp.
|
default |
Construct empty/uninitialized mesh.
One should call reset() or selectAll() method before using this.
plask::RectangularMaskedMesh2D::RectangularMaskedMesh2D | ( | const RectangularMesh< 2 > & | fullMesh, |
const Predicate & | predicate, | ||
bool | clone_axes = false |
||
) |
Construct masked mesh with elements of fullMesh
chosen by a predicate
.
Preserve order of elements and nodes of fullMesh
.
fullMesh | input mesh, before masking |
predicate | predicate which returns either true for accepting element or false for rejecting it |
clone_axes | whether axes of the fullMesh should be cloned (if true ) or shared with fullMesh (if false ; default) |
Definition at line 23 of file rectangular_masked2d.cpp.
|
inline |
Construct masked mesh with all elements of fullMesh
which have required materials in the midpoints.
Preserve order of elements and nodes of fullMesh
.
fullMesh | input mesh, before masking |
geom | geometry to get materials from |
materialPredicate | predicate which returns either true for accepting material or false for rejecting it |
clone_axes | whether axes of the fullMesh should be cloned (if true ) or shared (if false ; default) |
Definition at line 296 of file rectangular_masked2d.hpp.
|
inline |
Construct masked mesh with all elements of rectangularMesh
which have required kinds of materials (in the midpoints).
Preserve order of elements and nodes of rectangularMesh
.
rectangularMesh | input mesh, before masking |
geom | geometry to get materials from |
materialKinds | one or more kinds of material encoded with bit or operation, e.g. DIELECTRIC|METAL for selecting all dielectrics and metals, or ~ (DIELECTRIC|METAL) for selecting everything else |
clone_axes | whether axes of the rectangularMesh should be cloned (if true ) or shared (if false ; default) |
Definition at line 327 of file rectangular_masked2d.hpp.
plask::RectangularMaskedMesh2D::RectangularMaskedMesh2D | ( | const RectangularMesh< DIM > & | rectangularMesh, |
Set | nodeSet, | ||
bool | clone_axes = false |
||
) |
Construct a mesh with given set of nodes.
Set of elements are calculated on-demand, just before the first use, according to the rule: An element is selected if and only if all its vertices are included in the nodeSet
.
This constructor is used by getElementMesh.
|
inline |
Get point with given mesh indices.
index0 | index of point in axis[0] |
index1 | index of point in axis[1] |
index
Definition at line 399 of file rectangular_masked2d.hpp.
|
override |
Definition at line 182 of file rectangular_masked2d.cpp.
|
override |
Definition at line 140 of file rectangular_masked2d.cpp.
|
override |
Definition at line 158 of file rectangular_masked2d.cpp.
|
override |
Definition at line 163 of file rectangular_masked2d.cpp.
|
override |
Definition at line 167 of file rectangular_masked2d.cpp.
|
override |
Definition at line 171 of file rectangular_masked2d.cpp.
|
override |
Definition at line 114 of file rectangular_masked2d.cpp.
|
override |
Definition at line 122 of file rectangular_masked2d.cpp.
|
override |
Definition at line 118 of file rectangular_masked2d.cpp.
|
override |
Definition at line 131 of file rectangular_masked2d.cpp.
|
override |
Definition at line 178 of file rectangular_masked2d.cpp.
|
override |
Definition at line 149 of file rectangular_masked2d.cpp.
|
override |
Definition at line 94 of file rectangular_masked2d.cpp.
|
override |
Definition at line 99 of file rectangular_masked2d.cpp.
|
override |
Definition at line 103 of file rectangular_masked2d.cpp.
|
override |
Definition at line 107 of file rectangular_masked2d.cpp.
|
inline |
Get an element with a given index i
.
i | index of the element |
Definition at line 371 of file rectangular_masked2d.hpp.
|
inline |
Definition at line 363 of file rectangular_masked2d.hpp.
|
inline |
Definition at line 360 of file rectangular_masked2d.hpp.
|
inline |
Get an element with a given index i
.
i | index of the element |
Definition at line 378 of file rectangular_masked2d.hpp.
|
inline |
Definition at line 364 of file rectangular_masked2d.hpp.
|
inline |
Get an area of a given element.
index0,index1 | axis 0 and axis 1 indexes of the element |
Definition at line 510 of file rectangular_masked2d.hpp.
|
inline |
Get element as rectangle.
index0,index1 | index of Elements |
Definition at line 528 of file rectangular_masked2d.hpp.
|
inline |
Convert mesh indexes of a bottom-left corner of an element to the index of this element.
axis0_index | index of the corner along the axis0 (left), from 0 to axis[0]->size()-1 |
axis1_index | index of the corner along the axis1 (bottom), from 0 to axis[1]->size()-1 |
Definition at line 501 of file rectangular_masked2d.hpp.
|
inline |
Return a mesh that enables iterating over middle points of the selected rectangles.
Definition at line 417 of file rectangular_masked2d.hpp.
|
inline |
Get point in center of Elements.
index0,index1 | index of Elements |
Definition at line 519 of file rectangular_masked2d.hpp.
|
inline |
Definition at line 361 of file rectangular_masked2d.hpp.
|
inline |
Calculate this mesh index using indexes of axis0 and axis1.
axis0_index | index of axis0, from 0 to axis[0]->size()-1 |
axis1_index | index of axis1, from 0 to axis[1]->size()-1 |
Definition at line 386 of file rectangular_masked2d.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 452 of file rectangular_masked2d.hpp.
|
inline |
Calculate (using nearest neighbor 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 479 of file rectangular_masked2d.hpp.
|
inline |
Get point with given x and y indexes.
axis0_index | index of axis[0], from 0 to axis[0]->size()-1 |
axis1_index | index of axis[1], from 0 to axis[1]->size()-1 |
Definition at line 409 of file rectangular_masked2d.hpp.
bool plask::RectangularMaskedMesh2D::prepareInterpolation | ( | const Vec< 2 > & | point, |
Vec< 2 > & | wrapped_point, | ||
std::size_t & | index0_lo, | ||
std::size_t & | index0_hi, | ||
std::size_t & | index1_lo, | ||
std::size_t & | index1_hi, | ||
const InterpolationFlags & | flags | ||
) | const |
Prepare point for interpolation.
point | point to check | |
[out] | wrapped_point | point after wrapping with interpolation flags |
[out] | index0_lo,index0_hi | surrounding indices in the rectangular mesh for axis0 |
[out] | index1_lo,index1_hi | surrounding indices in the rectangular mesh for axis1 |
flags | interpolation flags |
false
if the point falls in the hole or outside of the mesh, true
if it can be interpolated Definition at line 58 of file rectangular_masked2d.cpp.
Change a selection of elements used to once pointed by a given predicate
.
predicate | predicate which returns either true for accepting element or false for rejecting it |
Definition at line 18 of file rectangular_masked2d.cpp.
void plask::RectangularMaskedMesh2D::reset | ( | const RectangularMesh< 2 > & | fullMesh, |
const Predicate & | predicate, | ||
bool | clone_axes = false |
||
) |
Change parameters of this mesh to use elements of fullMesh
chosen by a predicate
.
Preserve order of elements and nodes of fullMesh
.
fullMesh | input mesh, before masking |
predicate | predicate which returns either true for accepting element or false for rejecting it |
clone_axes | whether axes of the fullMesh should be cloned (if true ) or shared with rectangularMesh (if false ; default) |
Definition at line 29 of file rectangular_masked2d.cpp.
|
inline |
Change parameters of this mesh to use all elements of rectangularMesh
which have required materials in the midpoints.
Preserve order of elements and nodes of rectangularMesh
.
rectangularMesh | input mesh, before masking |
geom | geometry to get materials from |
materialPredicate | predicate which returns either true for accepting material or false for rejecting it |
clone_axes | whether axes of the rectangularMesh should be cloned (if true ) or shared (if false ; default) |
Definition at line 311 of file rectangular_masked2d.hpp.
|
inline |
Change parameters of this mesh to use all elements of rectangularMesh
which have required kinds of materials (in the midpoints).
Preserve order of elements and nodes of rectangularMesh
.
rectangularMesh | input mesh, before masking |
geom | geometry to get materials from |
materialKinds | one or more kinds of material encoded with bit or operation, e.g. DIELECTRIC|METAL for selecting all dielectrics and metals, or ~ (DIELECTRIC|METAL) for selecting everything else |
clone_axes | whether axes of the rectangularMesh should be cloned (if true ) or shared (if false ; default) |
Definition at line 344 of file rectangular_masked2d.hpp.