Hermes2D  3.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_search.h"

Classes

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

Public Member Functions

 NeighborSearch (Element *el, MeshSharedPtr mesh)
 
 NeighborSearch (const NeighborSearch &ns)
 
 ~NeighborSearch ()
 Destructor.
 
void free ()
 
void set_active_edge (int edge)
 
bool set_active_edge_multimesh (const int &edge)
 Enhancement of set_active_edge for multimesh assembling.
 
std::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 std::vector< unsigned int > &transformations) const
 Gives an info if edge is an intra- or inter- element edge.
 
void update_according_to_sub_idx (const std::vector< unsigned int > &transformations)
 Update according to the subelement mapping of the central element.
 
void handle_sub_idx_way_down (const std::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 (SpaceSharedPtr< Scalar > space, AsmList< Scalar > *al)
 
ExtendedShapesetcreate_extended_asmlist_multicomponent (SpaceSharedPtr< 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 std::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.
 
void add_central_transformations (Transformations *to_add, int position, bool replace=false)
 
void add_neighbor_transformations (Transformations *to_add, int position, bool replace=false)
 

Public Attributes

ExtendedShapesetsupported_shapes
 Object allowing to set/get a particular shape function from the extended. More...
 
bool ignore_errors
 
MeshSharedPtr mesh
 
Transformations ** central_transformations
 Array of transformations of the central element to each neighbor. More...
 
unsigned int central_transformations_size
 
unsigned int central_transformations_alloc_size
 
Transformations ** neighbor_transformations
 Array of transformations of the neighbor to the central element (go-up).
 
unsigned int neighbor_transformations_size
 
unsigned int neighbor_transformations_alloc_size
 
uint64_t original_central_el_transform
 Sub-element transformation of any function that comes from the. More...
 
Elementcentral_el
 Central (currently assembled) element.
 
Elementneighb_el
 Currently selected neighbor element (on the other side of active segment).
 

Static Public Attributes

static const unsigned int H2D_INITIAL_NEIGHBOR_NUMBER_GUESS = 32
 

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 MultimeshDGNeighborTree
 
template<typename T >
class DiscreteProblemDGAssembler
 
template<typename T >
class DiscreteProblemIntegrationOrderCalculator
 
template<typename T >
class ErrorThreadCalculator< T >::DGErrorCalculator
 

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 27 of file error_thread_calculator.h.

Constructor & Destructor Documentation

template<typename Scalar >
Hermes::Hermes2D::NeighborSearch< Scalar >::NeighborSearch ( Element el,
MeshSharedPtr  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_search.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 555 of file neighbor_search.cpp.

Referenced by Hermes::Hermes2D::ErrorThreadCalculator< Scalar >::DGErrorCalculator::init_neighbors().

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 515 of file neighbor_search.cpp.

template<typename Scalar >
NeighborSearch< Scalar >::ExtendedShapeset * Hermes::Hermes2D::NeighborSearch< Scalar >::create_extended_asmlist ( SpaceSharedPtr< 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 916 of file neighbor_search.cpp.

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

Retrieve all neighbor elements.

Returns
pointer to the vector of neighboring elements.

Definition at line 128 of file neighbor_search.cpp.

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 122 of file neighbor_search.cpp.

Referenced by Hermes::Hermes2D::EggShell::get_egg_shell().

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 942 of file neighbor_search.cpp.

Referenced by 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 1018 of file neighbor_search.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 177 of file neighbor_search.cpp.

Referenced by Hermes::Hermes2D::EggShell::get_egg_shell(), and Hermes::Hermes2D::DiscreteProblemSelectiveAssembler< Scalar >::prepare_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 935 of file neighbor_search.cpp.

Member Data Documentation

template<typename Scalar>
Transformations** Hermes::Hermes2D::NeighborSearch< Scalar >::central_transformations

Array of transformations of the central element to each neighbor.

(in a go-down neighborhood; stored as on Transformation structure for each neighbor).

Definition at line 335 of file neighbor_search.h.

Referenced by Hermes::Hermes2D::NeighborSearch< Scalar >::delete_neighbor(), Hermes::Hermes2D::NeighborSearch< Scalar >::get_central_n_trans(), Hermes::Hermes2D::NeighborSearch< Scalar >::get_central_transformations(), and Hermes::Hermes2D::NeighborSearch< Scalar >::NeighborSearch().

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 263 of file neighbor_search.h.

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

template<typename Scalar>
uint64_t Hermes::Hermes2D::NeighborSearch< Scalar >::original_central_el_transform

Sub-element transformation of any function that comes from the.

assembly, before transforms from transformations are pushed to it.

Definition at line 349 of file neighbor_search.h.

Referenced by Hermes::Hermes2D::ErrorThreadCalculator< Scalar >::DGErrorCalculator::init_neighbors(), and Hermes::Hermes2D::NeighborSearch< Scalar >::NeighborSearch().

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

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

shapeset and retrieve global assembly information for it.

Definition at line 147 of file neighbor_search.h.


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