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

A derived class from GmValueSetGroup storing GmGaussValueSet objects. More...

#include <gmGaussValueSetGroup.h>

Inheritance diagram for GmGaussValueSetGroup:
Collaboration diagram for GmGaussValueSetGroup:

Public Member Functions

 GmGaussValueSetGroup (GmSimulationData *simData, GmElementMesh *mesh)
 Constructor. Creates an empty group. See description for GmValueSetGroup constructor.
 
virtual bool addValueSet (QString id, GmValueInfo *info)
 Adds a new value set to the group. Does not accepts a NULL info value. All added value sets MUST share the same integration rule set. Otherwise, see comments on GmValueSetGroup::addValueSet()
 
bool init ()
 Initializes all the ValueSets with the initial size given by the mesh. See comments on GmValueSetGroup::init().
 
bool addValues ()
 Adds values to all the ValueSets so that its size is increased to match the actual mesh size, as given by the associated Gauss index.
 
void restoreSize ()
 Restores the size of the set to the previous size before addValues. Requires that the Gauss indices are already updated to the previous size. Needed since a mesh can have multiple groups due to attributes with different rule sets.
 
GmGaussValueSetgaussValueSet (QString id) const
 Returns the value set associated with the given data id. Returns NULL if not found.
 
- Public Member Functions inherited from GmValueSetGroup
 GmValueSetGroup (GmSimulationData *simData, GmMesh *mesh)
 Constructor. Creates an empty group. Value sets should be added by calls to addValueSet() After all adds are done, call init() to prepare the value sets for usage. The simulation data and mesh parameters are needed for instancing value sets that can store function references (as indicated by the info metadata). The simulation data is also needed for access to the autoPackAttributes configuration parameter. If simData is NULL, the parameter will be considered as false (in addition to the no support for functions in the value sets). The mesh can be set to NULL if the stored value sest are not directly bound to a mesh (bound to a property set, for example). In that case, a GmSingleVector storage will be used (since we can not base the decision on the GmMesh::useDualVectors() result for NULL meshes).
 
virtual ~GmValueSetGroup ()
 Destructor.
 
virtual bool removeValueSet (QString id, bool releaseInfo=false)
 Removes a value set from the group. If that value set belongs to a pack and the group has already been initialized, this will lead to a pack restructuring. Returns false for an invalid id or if there was an error restructuring a pack.
 
bool isEmpty () const
 Returns true if this group is empty (does not include any value set).
 
int numSets () const
 Returns the number of sets stored in this group.
 
void addValueSetBegin ()
 Starts the addition of value sets to a new / existing pack after the group has been initialized. Pack reestructuring will be delayed until a call to addValueSetEnd(). If called before group initialization, does nothing.
 
bool addValueSetEnd ()
 Ends the addition of value sets to a new / existing pack after the group has been initialized. Pack reestructuring will be executed. If called before group initialization, does nothing. If there was no call to addValueSet() in the begin / end block, dos nothing. On error, will try to leave the group in the state prior to the begin call, removing the added value sets, INCLUDING those that do not belong to a pack. That can go wrong if we are unable to revert used pack buffers to the previous state (the only other possible side effect is the addition of new, empty, packs).
 
bool insideAddBlock () const
 Returns true if addValueSetBegin() has been called without a matching addValueSetEnd() call.
 
int nextNewPack () const
 Returns the number of the next unused pack id.
 
bool initialized () const
 Returns true if the group has been initialized with a call to init()
 
int numValues () const
 Returns the size (number of "entries") of the stored value sets.
 
virtual void clear ()
 Removes all value sets from the group.
 
virtual void clearData ()
 Clears all value sets, returning their size to 0. The value sets themselves remain on the group.
 
virtual bool saveState (GmValueSet::SaveStateMode mode, const GmLogCategory &logger)
 Saves the state for all sets in the group.
 
const QMap< QString, int > & dataMap () const
 Returns a map indexed by value set data id, storing the id position in the value set list.
 
bool contains (QString id) const
 Returns true if the group contains a value set for an attribute named id.
 
const QVector< GmValueSet * > & valueSets () const
 Returns a list with the stored value sets. The map returned by dataMap() is an index onto this list. Can contain NULL values if addValueSet() was called with a NULL info pointer (although strange, this is useful for handling node attributes for meshes with ghost nodes).
 
GmValueSetvalueSet (QString id) const
 Returns the value set associated with the given data id. Returns NULL if not found.
 
virtual size_t printMemoryStatistics (const GmLogCategory &logger, GmLogLevel level) const
 Prints memory usage for this value set to the given logger. Returns the used memory as reported by usedMemory()
 
virtual size_t usedMemory () const
 Returns an estimative of the memory used by the set group in bytes.
 

Protected Member Functions

virtual GmValueSetcreateValueSet (GmValueInfo *info, GmPackedBuffer *pack)
 Virtual function used to create the stored value set. Can be overwritten by descendant classes.
 
- Protected Member Functions inherited from GmValueSetGroup
GmPackedBuffergetPack (int packId)
 Returns, crating if necessary, the pack associated with the given id. Returns NULL if no pack is needed.
 

Private Member Functions

int ruleSet () const
 
virtual bool init (int)
 Initializes all the ValueSets, being responsible for allocating memory and initializing data. Either all sets are allocated or none are.
 
virtual bool addValues (int)
 Adds the given number of values to the sets, initializing them to the default value. Returns false on errors. On errors previous values are kept. Keep in mind that either all sets are resized or none are.
 
virtual void removeValues (int, int)
 Removes numValues from the set, starting from (and including) index. Can not fail (but might not release memory).
 
virtual void restoreSize (int)
 Restores the size of the sets to the previous size before addValues.
 

Additional Inherited Members

- Protected Attributes inherited from GmValueSetGroup
GmSimulationData_simData
 The simulation data object. Needed for value sets accepting function values. Might be NULL.
 
GmMesh_mesh
 The associated mesh object. Needed for most value sets accepting function values (except property sets). Might be NULL.
 
bool _init
 Have we been initialized yet?
 
int _insideBlock
 Are we inside an addValueSetBegin / End block? If inside, stores the index in _valueSets of the first vs added after the begin. Stores -1 if outside a block.
 
int _numValues
 The size of the stored value sets.
 
QMap< QString, int > _idMap
 Maps stored value set ids to their position in _valueSets.
 
QVector< GmValueSet * > _valueSets
 The list of stored value sets.
 
QMap< int, GmPackedBuffer * > _packs
 A map indexing packed buffers by their id.
 

Detailed Description

A derived class from GmValueSetGroup storing GmGaussValueSet objects.

Besides storing GmGaussValueSet objects, this class uses a different API for initializing and resing the stored value sets. Instead of receiving sizes, they are obtained from the associated mesh Gauss index, but only if the group effectively has stored value sets. This helps to prevent the instanciation of Gauss indices for rule sets that do not have associated attributes.

Member Function Documentation

◆ addValues()

virtual bool GmGaussValueSetGroup::addValues ( int numAddedValues)
inlineprivatevirtual

Adds the given number of values to the sets, initializing them to the default value. Returns false on errors. On errors previous values are kept. Keep in mind that either all sets are resized or none are.

Reimplemented from GmValueSetGroup.

◆ addValueSet()

bool GmGaussValueSetGroup::addValueSet ( QString id,
GmValueInfo * info )
virtual

Adds a new value set to the group. Does not accepts a NULL info value. All added value sets MUST share the same integration rule set. Otherwise, see comments on GmValueSetGroup::addValueSet()

Reimplemented from GmValueSetGroup.

◆ createValueSet()

virtual GmValueSet * GmGaussValueSetGroup::createValueSet ( GmValueInfo * info,
GmPackedBuffer * pack )
inlineprotectedvirtual

Virtual function used to create the stored value set. Can be overwritten by descendant classes.

Reimplemented from GmValueSetGroup.

◆ init()

virtual bool GmGaussValueSetGroup::init ( int numValues)
inlineprivatevirtual

Initializes all the ValueSets, being responsible for allocating memory and initializing data. Either all sets are allocated or none are.

Returns false if it was not possible to allocate memory.

Reimplemented from GmValueSetGroup.

◆ removeValues()

virtual void GmGaussValueSetGroup::removeValues ( int index,
int numValues )
inlineprivatevirtual

Removes numValues from the set, starting from (and including) index. Can not fail (but might not release memory).

Reimplemented from GmValueSetGroup.

◆ restoreSize()

virtual void GmGaussValueSetGroup::restoreSize ( int oldSize)
inlineprivatevirtual

Restores the size of the sets to the previous size before addValues.

Reimplemented from GmValueSetGroup.


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