GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmBaseCellGroupSet Class Reference

A helper class implementing common code for handling group sets, specially handling group nodes. Is inherited by GmCellDisjointGroupSet and by GmCellGenericGroupSet. More...

#include <gmCellGroupSet.h>

Inheritance diagram for GmBaseCellGroupSet:
Collaboration diagram for GmBaseCellGroupSet:

Public Member Functions

virtual ~GmBaseCellGroupSet ()
 Destructor.
 
virtual int numNodes () const
 Returns the number of geometric nodes shared by the group elements.
 
virtual int node (int setIndex) const
 Given an index in the range [0..numNodes()-1], returns the respective mesh node index.
 
virtual void clear ()
 Clear the group set in response to a mesh clear() operation. It will not clear the list of cellGroups.
 
virtual const QList< int > & cellGroups () const
 Returns a list with the cell groups belonging to this group set. Values are the group index in the mesh, ordered by index.
 
virtual GmCellMeshmesh () const
 Returns the mesh owning the cell groups.
 
virtual size_t usedMemory () const
 Returns the approximate amount of memory used to store node data, if any.
 
- Public Member Functions inherited from GmCellGroupSet
virtual ~GmCellGroupSet ()
 Virtual destructor.
 
virtual int numCells () const =0
 Returns the number of unique elements in the cell group set.
 
virtual GmCellcell (int setIndex) const =0
 Given an index in the range [0..numCells()-1], returns the respective cell.
 
virtual bool ordered () const =0
 Returns true if the the set returned by calls to cell(0) through cell(numCells()-1) is ordered by cell id.
 
QStringList cellGroupNames () const
 Returns the result of cellGroups() converted to group names.
 
virtual void applyTransform (std::function< int(int)> &t)=0
 This is a very specialized function. Use only if you know what you are doing. For sets storing internally the cell ids, it should apply the given transformation to every id, replacing the previous ones. Sets that just point to cell groups should do nothing.
 

Protected Types

typedef QPair< int, int * > NodeData
 Type for storing node data information: Number of nodes + vector pointer.
 

Protected Member Functions

 GmBaseCellGroupSet (GmCellMesh *mesh, const QList< int > &groups)
 Base group set constructor. Stores the mesh and an ordered version of the group list.
 
 GmBaseCellGroupSet (GmCellMesh *mesh)
 Base group set constructor. Stores the mesh and an ordered version of the group list.
 
NodeDatabuildNodeList () const
 Builds the list with nodes used by this element groups. Does not changes the internal state.
 
NodeDatanodeData () const
 Auxiliar function that uses the Double Checked Locking Pattern (DCLP) to grab
the pointer to the node data, creating it by calling buildNodeList() if the node data was not created yet..
 

Protected Attributes

GmCellMesh_mesh
 The associated mesh.
 
QList< int > _groupList
 The list of mesh cell groups included in this set.
 
QAtomicPointer< NodeData_nodeData
 Atomic pointer to the node data. Contains the number of nodes shared by the group cells and a vector with node indices. Mutable so that it can be filled in a lazy way by nodeData(). Stored in an atomic pointer to enable the use of a DCLP.
 
QMutex _nodeDataMutex
 Mutex protecting the creation of _nodeData.
 

Additional Inherited Members

- Static Public Member Functions inherited from GmCellGroupSet
static bool cellGroupIds (const GmCellMesh *mesh, const QStringList &groupNames, QList< int > &idList, QString &err)
 Given a set of cell group names, creates a set of group ids, filling idList.
 

Detailed Description

A helper class implementing common code for handling group sets, specially handling group nodes. Is inherited by GmCellDisjointGroupSet and by GmCellGenericGroupSet.

Node data is filled in a lazy way only if numNodes() or node() are ever called.

Member Function Documentation

◆ cellGroups()

virtual const QList< int > & GmBaseCellGroupSet::cellGroups ( ) const
inlinevirtual

Returns a list with the cell groups belonging to this group set. Values are the group index in the mesh, ordered by index.

Implements GmCellGroupSet.

◆ clear()

void GmBaseCellGroupSet::clear ( )
virtual

Clear the group set in response to a mesh clear() operation. It will not clear the list of cellGroups.

Implements GmCellGroupSet.

Reimplemented in GmCellDisjointGroupSet, GmCellGenericGroupSet, and GmCellSequentialGroupSet.

◆ mesh()

virtual GmCellMesh * GmBaseCellGroupSet::mesh ( ) const
inlinevirtual

Returns the mesh owning the cell groups.

Implements GmCellGroupSet.

◆ node()

virtual int GmBaseCellGroupSet::node ( int setIndex) const
inlinevirtual

Given an index in the range [0..numNodes()-1], returns the respective mesh node index.

Implements GmCellGroupSet.

◆ nodeData()

GmBaseCellGroupSet::NodeData * GmBaseCellGroupSet::nodeData ( ) const
protected

Auxiliar function that uses the Double Checked Locking Pattern (DCLP) to grab
the pointer to the node data, creating it by calling buildNodeList() if the node data was not created yet..

Using DCLP guarantees that all accesses but the first one have minimum overhead.

See https://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/ for an extensive documentation about the DCLP problem.

◆ numNodes()

virtual int GmBaseCellGroupSet::numNodes ( ) const
inlinevirtual

Returns the number of geometric nodes shared by the group elements.

Implements GmCellGroupSet.

◆ usedMemory()

size_t GmBaseCellGroupSet::usedMemory ( ) const
virtual

Returns the approximate amount of memory used to store node data, if any.

Implements GmCellGroupSet.

Reimplemented in GmCellGenericGroupSet.


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