Hermes2D  2.0
Hermes::Hermes2D::NeighborSearch< Scalar > Class Template Reference

This class characterizes a neighborhood of a given edge in terms of adjacent elements and provides methods for getting limit values of discontinuous functions from both sides of the edge. More...

#include "src/neighbor.h"

Classes

class  ExtendedShapeset
 
class  NeighborEdgeInfo
 Structure containing all the needed information about the active edge from the neighbor's side. More...
 
struct  Transformations
 Transformations of an element to one of its neighbors. More...
 

Public Member Functions

 NeighborSearch (Element *el, const Mesh *mesh)
 
 NeighborSearch (const NeighborSearch &ns)
 
 ~NeighborSearch ()
 Destructor.
 
void set_active_edge (int edge)
 
bool set_active_edge_multimesh (const int &edge)
 Enhancement of set_active_edge for multimesh assembling.
 
Hermes::vector< unsigned int > get_transforms (uint64_t sub_idx) const
 Extract transformations in the correct direction from the provided sub_idx.
 
bool is_inter_edge (const int &edge, const Hermes::vector< unsigned int > &transformations) const
 Gives an info if edge is an intra- or inter- element edge.
 
void update_according_to_sub_idx (const Hermes::vector< unsigned int > &transformations)
 Update according to the subelement mapping of the central element.
 
void handle_sub_idx_way_down (const Hermes::vector< unsigned int > &transformations)
 Special function for handling subelement transformations in the case of more than one neighboring active elements.
 
bool compatible_transformations (unsigned int a, unsigned int b, int edge) const
 
void clear_initial_sub_idx ()
 
void delete_neighbor (unsigned int position)
 In case we determine a neighbor is not correct due to a subelement mapping, we delete it.
 
DiscontinuousFunc< Scalar > * init_ext_fn (MeshFunction< Scalar > *fu)
 
ExtendedShapesetcreate_extended_asmlist (const Space< Scalar > *space, AsmList< Scalar > *al)
 
ExtendedShapesetcreate_extended_asmlist_multicomponent (const Space< Scalar > *space, AsmList< Scalar > *al)
 
void set_quad_order (int order)
 
int get_quad_eo (bool on_neighbor=false) const
 
int get_num_neighbors () const
 
const Hermes::vector< Element * > * get_neighbors () const
 
void clear_supported_shapes ()
 Frees the memory occupied by the extended shapeset.
 
void set_ignore_errors (bool value)
 Function that sets the variable ignore_errors. See the variable description.
 
int get_active_segment () const
 Returns the current active segment.
 
void set_active_segment (unsigned int index)
 Sets the active segment, neighbor element, and neighbor edge accordingly.
 
Elementget_neighb_el () const
 Returns the current neighbor element according to the current active segment.
 
NeighborEdgeInfo get_neighbor_edge () const
 Returns the current active neighbor edge according to the current active segment.
 
unsigned int get_central_n_trans (unsigned int index) const
 Returns the number(depth) of the current central transformation according to the current active segment.
 
unsigned int get_central_transformations (unsigned int index_1, unsigned int index_2) const
 Returns the current central transformations according to the current active segment.
 
unsigned int get_neighbor_n_trans (unsigned int index) const
 Returns the number(depth) of the current neighbor transformation according to the current active segment.
 
unsigned int get_neighbor_transformations (unsigned int index_1, unsigned int index_2) const
 Returns the current neighbor transformations according to the current active segment.
 

Public Attributes

ExtendedShapesetsupported_shapes
 shapeset and retrieve global assembly information for it. More...
 
bool ignore_errors
 

Friends

template<typename T >
class KellyTypeAdapt
 
template<typename T >
class Adapt
 
template<typename T >
class Func
 
template<typename T >
class DiscontinuousFunc
 
template<typename T >
class DiscreteProblem
 
template<typename T >
class DiscreteProblemLinear
 

Detailed Description

template<typename Scalar>
class Hermes::Hermes2D::NeighborSearch< Scalar >

This class characterizes a neighborhood of a given edge in terms of adjacent elements and provides methods for getting limit values of discontinuous functions from both sides of the edge.

Each instance of the class is connected to a mesh and its active element. The active element becomes the central element of the neighborhood and all adjacent elements the neighbors .

In order to search for the neighboring elements, one selects a particular edge of the central element and calls the method set_active_edge. This enumerates the neighbors and fills in the array transformations, which will be needed later for getting function values at matching points from both sides of the selected (active) edge.

The actual procedure depends on the relative size of the central element with respect to the neighbor element(s) across the active edge:

  • If active edge is shared by two elements of same size, then Element::get_neighbor is used to retrieve pointer to the neighboring element. Moreover, no transformations are needed to obtain values of any given function from either side of active edge.
  • If the neighbor element is bigger than the central element, then we "go up" on the central element, until we find its parent that has the same size as the neighbor. We keep track of the visited intermediate parents and after the final one has been found, we use them in reverse order to fill in the transformations array. These transformations will have to be pushed to a function on the neighboring (bigger) element in order to obtain values at points matching those from the central element's side.
  • If the neighbor element is smaller than the central element, it means that it is one of several neighbors across the active edge. Hence, we "go down" in the central element in order to find a (virtual) sub-element matching the currently processed neighbor and store the corresponding transformations in the neighbor's field of the array transformations. This way, we obtain for each neighbor a set of transformations which have to be applied on the central element to transform integration points to its correct part matching the neighbor.

There may be either one or more neighbors (see below). In the second case, each of the neighbors shares with the central element a unique segment of the active edge. The next step is therefore a loop through all neighbors, setting the appropriate active segment through set_active_segment at the beginning of every iteration. This also handles the "go-down" transformations of the attached central element's pss and creates a pss on the neighbor element for use in evaluating discontinuous bilinear forms (see below).

If only external functions are supposed to be discontinuous across the active edge (e.g. in the case of linear forms), the init_ext_fn methods may now be used to create pointers to new DiscontinuousFunc objects - first to one used for evaluating integration order and then, after computing the quadrature order for given form and setting it via set_quad_order, to that with the actual values at the matching integration points from both sides of the active segment.

If also the test functions need to be considered discontinuous (e.g when assembling DG bilinear forms), the local precalculated shapesets on the central element (attached from the assembling procedure) and on the current neighbor element are extended by zero to the whole neighborhood of the two elements (see create_extended_shapeset). A so-called extended shapeset thus created is stored in the variable supported_shapes and may be queried for the count of all contained extended shapes and their global DOF numbers. Assembling is done over all shape functions from the extended shapes. The user gets a pointer to the current extended shape function by calling supported_shapes.get_extended_shape_fn and may use it then to obtain DiscontinuousFunc objects with the shape function's order/values on both sides of active edge as in the previous case of external functions.

Definition at line 68 of file neighbor.h.

Constructor & Destructor Documentation

template<typename Scalar >
Hermes::Hermes2D::NeighborSearch< Scalar >::NeighborSearch ( Element el,
const Mesh mesh 
)

Constructor.

Parameters
[in]elCentral element of the neighborhood (current active element in the assembling procedure).
[in]meshMesh on which we search for the neighbors.

Definition at line 24 of file neighbor.cpp.

Member Function Documentation

template<typename Scalar >
void Hermes::Hermes2D::NeighborSearch< Scalar >::clear_initial_sub_idx ( )

Clear the initial_sub_idxs from the central element transformations of NeighborSearches with multiple neighbors. Does nothing in the opposite case.

Definition at line 472 of file neighbor.cpp.

template<typename Scalar >
bool Hermes::Hermes2D::NeighborSearch< Scalar >::compatible_transformations ( unsigned int  a,
unsigned int  b,
int  edge 
) const

Give the info if the two transformations are correct, w.r.t. the edge. Simply compares a to b in case of triangles, does more work in case of quads.

Definition at line 432 of file neighbor.cpp.

template<typename Scalar >
NeighborSearch< Scalar >::ExtendedShapeset * Hermes::Hermes2D::NeighborSearch< Scalar >::create_extended_asmlist ( const Space< Scalar > *  space,
AsmList< Scalar > *  al 
)

Form the extended shapeset.

Initializes the class attribute supported_shapes for the first time and updates it whenever the active segment or edge change. The extended shapeset consists of shape functions from both the central element and current neighbor element, extended by zero to the union of these elements.

Parameters
[in]spaceSpace from which the local shapesets are drawn.
[in]alAssembly list for the central element.
Returns
Number of shape functions in the extended shapeset (sum of central and neighbor elems' local counts).

Definition at line 827 of file neighbor.cpp.

template<typename Scalar >
const Hermes::vector< Element * > * Hermes::Hermes2D::NeighborSearch< Scalar >::get_neighbors ( ) const

Retrieve all neighbor elements.

Returns
pointer to the vector of neighboring elements.

Definition at line 111 of file neighbor.cpp.

Referenced by Hermes::Hermes2D::DiscreteProblem< Scalar >::assemble_DG_one_neighbor(), and Hermes::Hermes2D::DiscreteProblem< Scalar >::create_sparse_structure().

template<typename Scalar >
int Hermes::Hermes2D::NeighborSearch< Scalar >::get_num_neighbors ( ) const

Return the number of elements (neighbors) adjacent to the central element across the common (active) edge.

Returns
The number of neighbors.

Definition at line 105 of file neighbor.cpp.

Referenced by Hermes::Hermes2D::DiscreteProblem< Scalar >::create_sparse_structure(), Hermes::Hermes2D::DiscreteProblem< Scalar >::update_neighbor_search(), and Hermes::Hermes2D::DiscreteProblem< Scalar >::update_ns_subtree().

template<typename Scalar >
int Hermes::Hermes2D::NeighborSearch< Scalar >::get_quad_eo ( bool  on_neighbor = false) const

Get the integration pseudo-order for the active edge (assumes the true order has been set by set_quad_order).

Parameters
[in]on_neighborIf true, order is returned for the neighbor el. (using its local active edge number).
Returns
The edge "pseudo-order" (determined by the true order and local edge number).

Definition at line 853 of file neighbor.cpp.

Referenced by Hermes::Hermes2D::DiscreteProblem< Scalar >::assemble_DG_one_neighbor(), and Hermes::Hermes2D::NeighborSearch< Scalar >::init_ext_fn().

template<typename Scalar >
DiscontinuousFunc< Scalar > * Hermes::Hermes2D::NeighborSearch< Scalar >::init_ext_fn ( MeshFunction< Scalar > *  fu)

Fill arrays with function values / derivatives at both sides of the active segment of active edge. Assumes that integration order has been set by set_quad_order.

Parameters
[in]fuMeshFunction whose values are requested.
Returns
Pointer to a discontinuous function allowing to access the values from each side of the active edge.

Definition at line 931 of file neighbor.cpp.

template<typename Scalar >
void Hermes::Hermes2D::NeighborSearch< Scalar >::set_active_edge ( int  edge)

Set active edge and compute all information about the neighbors.

In particular, it fills the neighbors and neighbor_edges vectors and the transformations array used for transforming either the central or the neighboring elements to the same size. It also sets neighborhood_type, according to whether we can find a vertex in the middle of the active edge - if we can, then we go down and the corresponding transformations will be filled for the bigger central element. This is performed by the method find_act_elem_down. Otherwise, we go up and will later push the transformations from transfomations to functions on the bigger neighboring element. Way up is Realized by the method find_act_elem_up.

Parameters
[in]edgeLocal (element dependent) number of the edge.
[in]ignore_visited_segmentsIf true, it indicates that an edge-based discontinuous Galerkin formulation is assumed. This means that once an edge is visited during assembling, integrals on that edge from both its sides are assembled at once and the edge should be ignored when the neighbor is assembled. A sum of edge-integrals over edges represents interelement coupling across the edge in the math. formulation.

If false, an element-based DG formulation is assumed, where each edge of every element is assembled (a sum of edge-integrals over elements appears in the mathematical formulation). Note that this may be also use in the edge-based form., e.g. to specify linear forms.

Definition at line 155 of file neighbor.cpp.

Referenced by Hermes::Hermes2D::DiscreteProblem< Scalar >::create_sparse_structure().

template<typename Scalar >
void Hermes::Hermes2D::NeighborSearch< Scalar >::set_quad_order ( int  order)

Sets the quadrature order to be used for obtaining integration points and weights in both neighbors.

Parameters
[in]orderThe integration order.

Definition at line 846 of file neighbor.cpp.

Referenced by Hermes::Hermes2D::DiscreteProblem< Scalar >::assemble_DG_one_neighbor().

Member Data Documentation

template<typename Scalar>
bool Hermes::Hermes2D::NeighborSearch< Scalar >::ignore_errors

When creating sparse structure of a matrix using this class, we want to ignore errors and do nothing instead when set_active_edge() function is called for a non-boundary edge.

Definition at line 249 of file neighbor.h.

Referenced by Hermes::Hermes2D::NeighborSearch< Scalar >::NeighborSearch().

template<typename Scalar>
ExtendedShapeset* Hermes::Hermes2D::NeighborSearch< Scalar >::supported_shapes

shapeset and retrieve global assembly information for it.

Object allowing to set/get a particular shape function from the extended

Definition at line 141 of file neighbor.h.


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