PLaSK library
Loading...
Searching...
No Matches
Boundaries

About boundaries

Boundaries represent some conditions which allow to choose a subset of points (strictly: indexes of points) from mesh. Boundaries are typically used by solvers to show points for boundaries conditions.

How to use boundaries?

Boundaries are specific for given type of mesh. Class MeshType::Boundary (which in most cases is same as Boundary<MeshType>) stores boundary for mesh of type MeshType. It has get method which return BoundaryNodeSet instance for mesh given as parameter. BoundaryNodeSet represent a set of points (indexes of points in given mesh) and allow for:

  • checking if it contains point with given index (contains method),
  • iterate over represented indexes (has begin and end methods).

Typically, you should call MeshType static methods to obtain value for Boundary<MeshType>.

Example:

using namespace plask;
RectilinearMesh2D::Boundary boundary; // stores boundary for mesh of type RectilinearMesh2D
boundary = RectilinearMesh2D::getLeftBoundary();
// now boundary represents condition which choose indexes of points on left boundary of any RectilinearMesh2D instance
//...
RectilinearMesh2D mesh;
//... (add some points to mesh)
BoundaryNodeSet bwm = boundary.get(mesh); // or boundary(mesh);
// bwm represent set of points indexes which lies on left boundary of mesh
std::cout << "Does point with index 0 lies on left boundary? Answer: " << bwm.contains(0) << std::endl;
for (std::size_t index: bwm) { // iterate over boundary points (indexes)
std::cout << "Point with index " << index
<< " lies on left boundary and has coordinates: "
<< mesh[index] << std::endl;
}

How to use boundaries in solvers?

Solvers hold boundary conditions which are pairs of: boundary (described by plask::Boundary) and condidion (description depends from type of condition, can be solver specific). Class plask::BoundaryConditions is container template of such pairs (it depends from both types: mesh and condition). So, typically, solvers have one or more public fields of type BoundaryConditions<MeshType, ConditionType>. User of solver can call this fields methods to add boundary condition, and solver can iterate over this boundary conditions.

See also Writing solvers in depth.

Boundaries implementations.

Instance of BoundaryNodeSet in fact is only a holder which contains pointer to abstract class plask::BoundaryNodeSetImpl. It points to subclass of plask::BoundaryNodeSetImpl which implements all boundary logic (all calls of BoundaryNodeSet methods are delegete to it).

So, writing new boundary for given type of mesh MeshType is writing subclass of plask::BoundaryNodeSetImpl.

PLaSK contains some universal BoundaryNodeSet implementations: