ug4
ug::CopyAttachmentHandler< TElem, TAttachment > Class Template Reference

handler for attachments in a multi-grid More...

#include <copy_attachment_handler.h>

+ Inheritance diagram for ug::CopyAttachmentHandler< TElem, TAttachment >:

Classes

struct  propagate
 
struct  propagate< TElem, Dummy >
 
struct  register_as_observer
 
struct  register_as_observer< Edge, Dummy >
 
struct  register_as_observer< Face, Dummy >
 
struct  register_as_observer< Vertex, Dummy >
 
struct  register_as_observer< Volume, Dummy >
 

Public Member Functions

 CopyAttachmentHandler ()
 constructor More...
 
virtual void edge_created (Grid *grid, Edge *e, GridObject *pParent=NULL, bool replacesParent=false)
 Notified whenever a new element of the given type is created in the given grid. More...
 
void enable_vertical_communication (bool b)
 
virtual void face_created (Grid *grid, Face *f, GridObject *pParent=NULL, bool replacesParent=false)
 Notified whenever a new element of the given type is created in the given grid. More...
 
void set_attachment (const TAttachment &attch)
 
void set_grid (SmartPtr< MultiGrid > mg)
 
virtual void vertex_created (Grid *grid, Vertex *vrt, GridObject *pParent=NULL, bool replacesParent=false)
 Notified whenever a new element of the given type is created in the given grid. More...
 
virtual void volume_created (Grid *grid, Volume *vol, GridObject *pParent=NULL, bool replacesParent=false)
 Notified whenever a new element of the given type is created in the given grid. More...
 
virtual ~CopyAttachmentHandler ()
 destructor More...
 
- Public Member Functions inherited from ug::GridObserver
virtual void elements_to_be_cleared (Grid *grid)
 
virtual void grid_to_be_destroyed (Grid *grid)
 
virtual ~GridObserver ()
 
virtual void vertex_to_be_erased (Grid *grid, Vertex *vrt, Vertex *replacedBy=NULL)
 Notified whenever an element of the given type is erased from the given grid. More...
 
virtual void edge_to_be_erased (Grid *grid, Edge *e, Edge *replacedBy=NULL)
 Notified whenever an element of the given type is erased from the given grid. More...
 
virtual void face_to_be_erased (Grid *grid, Face *f, Face *replacedBy=NULL)
 Notified whenever an element of the given type is erased from the given grid. More...
 
virtual void volume_to_be_erased (Grid *grid, Volume *vol, Volume *replacedBy=NULL)
 Notified whenever an element of the given type is erased from the given grid. More...
 
virtual void vertices_to_be_merged (Grid *grid, Vertex *target, Vertex *elem1, Vertex *elem2)
 Notified when two elements of the same type are going to be merged. More...
 
virtual void edges_to_be_merged (Grid *grid, Edge *target, Edge *elem1, Edge *elem2)
 Notified when two elements of the same type are going to be merged. More...
 
virtual void faces_to_be_merged (Grid *grid, Face *target, Face *elem1, Face *elem2)
 Notified when two elements of the same type are going to be merged. More...
 
virtual void volumes_to_be_merged (Grid *grid, Volume *target, Volume *elem1, Volume *elem2)
 Notified when two elements of the same type are going to be merged. More...
 

Protected Member Functions

virtual void copy (TElem *parent, TElem *child)
 
virtual void copy_from_other_elem_type (GridObject *parent, TElem *child)
 
void propagate_to_level (size_t lvl, bool vertComm=true)
 
void propagate_to_levels ()
 

Protected Attributes

TAttachment m_a
 attachment to be handled More...
 
Grid::AttachmentAccessor< TElem, TAttachment > m_aa
 accessor for handled attachment More...
 
bool m_bEnableVertComm
 
SmartPtr< MultiGridm_spMG
 multigrid More...
 

Friends

struct propagate< TElem, void >
 

Detailed Description

template<typename TElem, typename TAttachment>
class ug::CopyAttachmentHandler< TElem, TAttachment >

handler for attachments in a multi-grid

When using attachments in a multi-grid hierarchy, one EITHER needs to create the attachment after the geometry is refined (and distributed) up to the state in which the attachments are used - in this case, every geometric object which the data is attached to will have its attachment and there is no problem OR one creates the attachment before the geometry is refined (and distributed) - in this case, if the attachment is required on elements that are created after creation of the attachment, one needs to take care to supply those elements with attachment values. This class will do exactly this, but only to a very limited extent:

When this class is assigned a multi-grid, it will propagate attachment values from the base level upwards to the children of the same type< > by copying. Vertical communication is performed on each level to make sure that all those children will get their values.

Moreover, making use of the GridObserver interface, this class will copy attachment values to each child element (of equal type as their parent) created after assignment of the grid.

This will not, in general, guarantee that every element of the required type will get an attachment value. It will however suffice if the element type the attachment is attached to is full-dimensional (in its domain); it will obviously also suffice if the attachment values are only required on direct children (of equal type) of coarse grid elements, e.g. on d-dimensional elements on a d-dimensional manifold.

Example:

If, in the base level, attachments (a1, a2) are attached to their resp. nodes like this:

a1 ------— a2 <– lvl 0

then, on the next level, the node marked by "o" will not have an attachment value propagated from below (since it does not have a parent of the same type):

a1 — o — a2 <– lvl 1

a1 ------— a2 <– lvl 0

You may, however, choose to derive another handler class from this implementation and treat the cases where an upper-level element is child of an element of different type there by overloading copy_from_other_elem_type(). In the same manner, you might use derivation and overloading (of the copy() method) to perform a more specialized way of copying.

Note
Implementation relies on a template trick: One cannot - as decreed by the standard - specialize template methods of a not fully specialized template class; it is possible, however, to partially specialize nested template classes of a template class. This is what is used here.

Constructor & Destructor Documentation

◆ CopyAttachmentHandler()

template<typename TElem , typename TAttachment >
ug::CopyAttachmentHandler< TElem, TAttachment >::CopyAttachmentHandler ( )
inline

constructor

◆ ~CopyAttachmentHandler()

template<typename TElem , typename TAttachment >
virtual ug::CopyAttachmentHandler< TElem, TAttachment >::~CopyAttachmentHandler ( )
inlinevirtual

Member Function Documentation

◆ copy()

template<typename TElem , typename TAttachment >
virtual void ug::CopyAttachmentHandler< TElem, TAttachment >::copy ( TElem *  parent,
TElem *  child 
)
inlineprotectedvirtual

◆ copy_from_other_elem_type()

template<typename TElem , typename TAttachment >
virtual void ug::CopyAttachmentHandler< TElem, TAttachment >::copy_from_other_elem_type ( GridObject parent,
TElem *  child 
)
inlineprotectedvirtual

◆ edge_created()

template<typename TElem , typename TAttachment >
virtual void ug::CopyAttachmentHandler< TElem, TAttachment >::edge_created ( Grid grid,
Edge e,
GridObject pParent = NULL,
bool  replacesParent = false 
)
inlinevirtual

Notified whenever a new element of the given type is created in the given grid.

Creation callbacks are called in the order in which the GridObservers were registered at the given grid.

If replacesParent is true, then pParent is of the same base type as the created object (e.g. in case of edge_created, the parent is an Edge*). This case usually appears, when a contraining object is replaced by a regular grid object if the same base type during refinement. The method is called with replacesParent == true by Grid::create_and_replace methods.

Please note: If replacesParent == true, then a call to OBJECT_to_be_erased(grid, pParent, obj) will follow (OBJECT and obj are pseudonyms for the concrete type).

Reimplemented from ug::GridObserver.

◆ enable_vertical_communication()

template<typename TElem , typename TAttachment >
void ug::CopyAttachmentHandler< TElem, TAttachment >::enable_vertical_communication ( bool  b)
inline

◆ face_created()

template<typename TElem , typename TAttachment >
virtual void ug::CopyAttachmentHandler< TElem, TAttachment >::face_created ( Grid grid,
Face f,
GridObject pParent = NULL,
bool  replacesParent = false 
)
inlinevirtual

Notified whenever a new element of the given type is created in the given grid.

Creation callbacks are called in the order in which the GridObservers were registered at the given grid.

If replacesParent is true, then pParent is of the same base type as the created object (e.g. in case of edge_created, the parent is an Edge*). This case usually appears, when a contraining object is replaced by a regular grid object if the same base type during refinement. The method is called with replacesParent == true by Grid::create_and_replace methods.

Please note: If replacesParent == true, then a call to OBJECT_to_be_erased(grid, pParent, obj) will follow (OBJECT and obj are pseudonyms for the concrete type).

Reimplemented from ug::GridObserver.

◆ propagate_to_level()

◆ propagate_to_levels()

◆ set_attachment()

template<typename TElem , typename TAttachment >
void ug::CopyAttachmentHandler< TElem, TAttachment >::set_attachment ( const TAttachment &  attch)
inline

◆ set_grid()

◆ vertex_created()

template<typename TElem , typename TAttachment >
virtual void ug::CopyAttachmentHandler< TElem, TAttachment >::vertex_created ( Grid grid,
Vertex vrt,
GridObject pParent = NULL,
bool  replacesParent = false 
)
inlinevirtual

Notified whenever a new element of the given type is created in the given grid.

Creation callbacks are called in the order in which the GridObservers were registered at the given grid.

If replacesParent is true, then pParent is of the same base type as the created object (e.g. in case of edge_created, the parent is an Edge*). This case usually appears, when a contraining object is replaced by a regular grid object if the same base type during refinement. The method is called with replacesParent == true by Grid::create_and_replace methods.

Please note: If replacesParent == true, then a call to OBJECT_to_be_erased(grid, pParent, obj) will follow (OBJECT and obj are pseudonyms for the concrete type).

Reimplemented from ug::GridObserver.

◆ volume_created()

template<typename TElem , typename TAttachment >
virtual void ug::CopyAttachmentHandler< TElem, TAttachment >::volume_created ( Grid grid,
Volume vol,
GridObject pParent = NULL,
bool  replacesParent = false 
)
inlinevirtual

Notified whenever a new element of the given type is created in the given grid.

Creation callbacks are called in the order in which the GridObservers were registered at the given grid.

If replacesParent is true, then pParent is of the same base type as the created object (e.g. in case of edge_created, the parent is an Edge*). This case usually appears, when a contraining object is replaced by a regular grid object if the same base type during refinement. The method is called with replacesParent == true by Grid::create_and_replace methods.

Please note: If replacesParent == true, then a call to OBJECT_to_be_erased(grid, pParent, obj) will follow (OBJECT and obj are pseudonyms for the concrete type).

Reimplemented from ug::GridObserver.

Friends And Related Function Documentation

◆ propagate< TElem, void >

template<typename TElem , typename TAttachment >
friend struct propagate< TElem, void >
friend

Member Data Documentation

◆ m_a

template<typename TElem , typename TAttachment >
TAttachment ug::CopyAttachmentHandler< TElem, TAttachment >::m_a
protected

◆ m_aa

◆ m_bEnableVertComm

template<typename TElem , typename TAttachment >
bool ug::CopyAttachmentHandler< TElem, TAttachment >::m_bEnableVertComm
protected

◆ m_spMG


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