GemaCoreLib
The GeMA Core library
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmDiscontinuitySet Class Reference

Base interface for providing discontinuity geometry information for spatial indices. More...

#include <gmDiscontinuitySet.h>

Collaboration diagram for GmDiscontinuitySet:
Collaboration graph
[legend]

Public Types

enum  DiscontinuityType { GM_DISC_POLYLINE, GM_DISC_TRISURFACE, GM_DISC_EDGELIST, GM_DISC_FACELIST }
 Discontinuity type (defining how the disc. geometry is defined) More...
 
typedef QVarLengthArray< GmCompact2DSegmentCellIntersection *, 1 > SegmentCell2DIntersectionList
 Type for storing the set of 2D polyline-element intersections We use a QVarLengthArray since it has a smaller memory footprint than QVector If this type is changed (even if the pre alloc size of 1 is changed), please update GmDiscontinuitySet::usedElementMapMemory() accordingly.
 

Public Member Functions

 ~GmDiscontinuitySet ()
 Destructor.
 
QString id () const
 Returns the discontinuity set name.
 
QString description () const
 Returns the discontinuity set description.
 
DiscontinuityType type () const
 Returns the discontinuity geometry definition type.
 
GmCellMeshmesh () const
 Returns the mesh that this discontinuity set is tied to.
 
GmSpatialIndexspatialIndex () const
 Returns the mesh spatial index that this discontinuity set is tied to.
 
bool autoAddElements () const
 Returns true if the dicontinuity-cell intersections are added as new elements to the mesh.
 
bool extraDofsInAddedElements () const
 Returns true if added interface elements for type() == EDGELIST or FACELIST should have extra dof nodes.
 
double snapTolerance () const
 Returns the percentual tolerance used for snapping intersection points to nodes, edges or faces. More...
 
bool noInternalNodes () const
 Return true if internal intersections between segments are "broken".
 
bool internalIntersections () const
 
bool discardOriginalGeometry () const
 Returns true if the original intersection geometry data will be discarded after intersection handling.
 
int numDiscontinuities () const
 Returns the number of discontinuities (lines) stored in the object.
 
const QVector< GmDiscontinuity * > & discontinuities () const
 Returns the stored list of discontinuities.
 
int discontinuityIndex (QString id) const
 Given a discontinuity id, finds its index in the set. Returns -1 if not found.
 
GmDiscontinuitydiscontinuity (int index)
 Returns the given discontinuity. Index shoulde be between 0 and numDiscontinuities() - 1.
 
const GmDiscontinuitydiscontinuity (int index) const
 Returns the given discontinuity as a const object. Index shoulde be between 0 and numDiscontinuities() - 1.
 
QStringList attributeIds () const
 Returns a list with the id names for every attribute associated with the discontinuity set. No special order is enforced.
 
GmValueInfoattributeInfo (QString id) const
 Returns the metadata describing the discontinuity attribute named id If the id does not refer to a known attribute, returns NULL.
 
GmDiscontinuityAccessorattributeAccessor (QString id, Unit desiredUnit, const GmLogCategory &logger) const
 Creates an accessor object for the discontinuity attribute named id. More...
 
GmDiscontinuityAccessorattributeAccessor (QString id, int snum, bool locked, Unit desiredUnit, const GmLogCategory &logger) const
 Overloads attributeAccessor(QString, Unit, ...) to return an accessor for the requested previous state of a value. More...
 
int numAttributeStates (QString id) const
 Returns the number of existing states for the requested id or -1 if the id doesn't exists.
 
int numPropertySets () const
 Returns the number of property sets attached to this discontinuity set.
 
const QVector< GmPropertySet * > & propertySets () const
 Returns a reference to the list of property sets associated to this set. More...
 
int propertySetIndex (QString id) const
 
GmValueInfopropertyInfo (QString id) const
 Returns the metadata of the property named by id. More...
 
GmDiscontinuityAccessorpropertyAccessor (QString id, Unit desiredUnit, const GmLogCategory &logger) const
 Returns an accessor object for the property named by id. More...
 
bool buildIntersectionMaps (const GmLogCategory &logger)
 Builds the maps with element discontinuity segment intersections.
 
const SegmentCell2DIntersectionListcell2DPolylineIntersections (const GmCell *c) const
 Returns the set of 2D polyline - element intersections for cell c or an empty array if there is no intersection.
 
GmSegmentCell2DIntersectionCoordAccessorcell2DPolylineCoordAccessor (Unit desiredUnit, const GmLogCategory &logger) const
 Returns a "light" accessor that can be used to retrieve segment x cell intersection coordinate data in a different unit than the original mesh coordinate unit. As any accessor, the returned object should be properly disposed (deleted) by the caller. Returns NULL if the deired unit is incompatible with the mesh unit.
 
void printParameters (const GmLogCategory &logger, GmLogLevel level) const
 Prints discontinuity set basic information to the specified logger/level.
 
void print (const GmLogCategory &logger, GmLogLevel level) const
 Prints discontinuity set FULL information to the specified logger/level.
 
size_t printMemoryStatistics (const GmLogCategory &logger, GmLogLevel level) const
 Prints memory usage for this discontinuity set to the given logger. Returns the used memory as reported by usedMemory()
 
size_t usedMemory () const
 Returns an estimative of the memory used by the discontinuity set in bytes. More...
 

Static Public Member Functions

static GmDiscontinuitySetloadFromTable (LuaTable &tab, GmSimulationData *data, const GmLogCategory &logger)
 Loads a discontinuity set object full definition from a Lua table. More...
 
static QString discontinuityTypeToStr (DiscontinuityType type)
 Returns a string representing the discontinuity geometric representation type.
 

Private Member Functions

 GmDiscontinuitySet (QString id, QString description, DiscontinuityType type, GmCellMesh *mesh, GmSpatialIndex *index, bool addElements, bool extraDofs, double snapTol, bool noInternalNodes, bool internalIntersections, bool discardOriginalGeometry)
 Private constructor for use by loadFromTable.
 
bool add2DSegmentCellIntersectionsToMesh (const GmLogCategory &logger)
 Add 2D mesh polyline intersections as new bar elements to the mesh.
 
bool break2DPolylinesAtIntersections (const GmLogCategory &logger)
 Break discontinuity intersection "bars" when they intersect with other discontinuities. More...
 
bool loadGeometry (GmDiscontinuity *d, LuaTable &tab, DiscontinuityType type, const GmCellMesh *mesh, const GmLogCategory &logger)
 Loads the geometric definition of a discontinuity.
 
template<class T , class V >
T * loadIntoVector (LuaTable &tab, V validator, int n, QString discontinuityId, const char *msg, const GmLogCategory &logger)
 Allocate a vector of type T with tab.size() * n elements and reads the tab contents into it. Expects that tab is a vector with sub-tables storing n elements. Each loaded element is passed as a variant to the validator function, that should return the converted value to T. Returns NULL on error after logging a message with logger.
 
size_t usedElementMapMemory () const
 
 Q_DISABLE_COPY (GmDiscontinuitySet)
 

Private Attributes

QString _id
 The discontinuity set id (name)
 
QString _description
 A description of the discontinuity set.
 
DiscontinuityType _type
 The type of the discontinuities geometric data.
 
GmCellMesh_mesh
 The mesh that this discontinuity set is tied to.
 
GmSpatialIndex_index
 The optional spatial index used to speedup queries.
 
bool _addElements
 Should we automatically add the discontinuity geometry - cell intersections as elements to the mesh?
 
bool _addedInterfElemHaveExtraDofs
 Should added interface elements for EDGELIST/FACELIST have extra dof nodes?
 
double _snapTol
 The percentual snap tolerance for atracting intersection points to nodes, edges or faces.
 
bool _noInternalNodes
 Flag controlling if internal nodes are allowed (false) or not (true) in the intersection segments.
 
bool _internalIntersections
 Flag controlling if internal intersections should be handled or not.
 
bool _discardOriginalGeometry
 Flag controlling if the original geometry should be discarded after intersection handling for memory saving.
 
QVector< GmValueSet * > _attributes
 List with the set of defined attribute values.
 
QVector< GmPropertySet * > _propertySets
 List with the associated property sets.
 
QVector< GmDiscontinuity * > _data
 The list with discontinuity data.
 
QMap< QString, int > _attributesMap
 Maps attribute ids to their indices in _attributes.
 
QMap< QString, int > _dataMap
 Maps discontinuity names to their indices in _data.
 
QMap< int, SegmentCell2DIntersectionList_elementPolylineIntersectionsMap
 The map with per element intersections with polyline discontinuities.
 

Detailed Description

Base interface for providing discontinuity geometry information for spatial indices.

Member Enumeration Documentation

◆ DiscontinuityType

Discontinuity type (defining how the disc. geometry is defined)

Enumerator
GM_DISC_POLYLINE 

The disc. geometry is given by a polyline. Inserted elements are bars.

GM_DISC_TRISURFACE 

The disc. geometry is given by a trinagulated surface. Inserted elements are triangles or quads.

GM_DISC_EDGELIST 

The disc. geometry is given by an edge list. Inserted elements are 2d interface elements.

GM_DISC_FACELIST 

The disc. geometry is given by a face list. Inserted elements are 3d interface elements.

Member Function Documentation

◆ attributeAccessor() [1/2]

GmDiscontinuityAccessor * GmDiscontinuitySet::attributeAccessor ( QString  id,
Unit  desiredUnit,
const GmLogCategory logger 
) const

Creates an accessor object for the discontinuity attribute named id.

If the id does not refer to a known attribute, returns NULL.

If desiredUnit is a known unit, different from the basic attribute unit, the value will be automatically converted to the desired unit. If no conversion is possible, the function returns NULL. To avoid conversions, just pass Unit() as the desiredUnit.

IMPORTANT: The returned accessor should be deallocated by the caller.

Obs: This is equivalent to calling attributeAccessor(id, 0, true, desiredUnit, logger)

◆ attributeAccessor() [2/2]

GmDiscontinuityAccessor * GmDiscontinuitySet::attributeAccessor ( QString  id,
int  snum,
bool  locked,
Unit  desiredUnit,
const GmLogCategory logger 
) const

Overloads attributeAccessor(QString, Unit, ...) to return an accessor for the requested previous state of a value.

The snum parameter contains the requested state. A value of zero means the current state, 1 the previous one, 2 the one before that and so on. Valid values range from zero to the oldest state for the requested variable. Remember that for a value accessor to support states, the history parameter must be set in its value info object.

The locked parameter controls the behaviour of the accessor once a new state is created for the value. The 'lock' refers to the state number, so if locked is false and a new state is created, the accessor doesn't change and continues to point to the same data. If locked is true, the accessor will be locked to that state number so when a new state is created, the accessor changes the data its looking upon to reflect the new satte. For example, an accessor locked on the state 0 will always point to the current state and one locked to the state 1 will always point to the previous saved value.

See the overloaded function for the remaining parameters.

◆ break2DPolylinesAtIntersections()

bool GmDiscontinuitySet::break2DPolylinesAtIntersections ( const GmLogCategory logger)
private

Break discontinuity intersection "bars" when they intersect with other discontinuities.

The aux data temporarily saved for each intersection

< The list index for the intersecting segment

< The "natural" coordinate for the intersection

< The cartesian coordinate for the intersection

◆ loadFromTable()

GmDiscontinuitySet * GmDiscontinuitySet::loadFromTable ( LuaTable tab,
GmSimulationData data,
const GmLogCategory logger 
)
static

Loads a discontinuity set object full definition from a Lua table.

The new object is initialized with the data found in the table. Returns NULL and prints an error message using the supplied logger in case of errors (like an invalid disc. set definition point or boundary).

This function expects that some basic validation steps have been done elsewhere (currently at the model loading by the DiscontinuitySet Lua function).

◆ propertyAccessor()

GmDiscontinuityAccessor * GmDiscontinuitySet::propertyAccessor ( QString  id,
Unit  desiredUnit,
const GmLogCategory logger 
) const

Returns an accessor object for the property named by id.

If id does not reference a known property, returns NULL; Remember that there should be no intersection between property names of the several sets bound to a single discontinuity set, so id specifies a unique property among the several possible property sets.

If desiredUnit is a known unit, different from the basic property unit, the value will be automatically converted to the desired unit. If no conversion is possible, the function returns NULL. To avoid conversions, just pass Unit() as the desiredUnit.

IMPORTANT: The returned accessor should be deallocated by the caller.

◆ propertyInfo()

GmValueInfo * GmDiscontinuitySet::propertyInfo ( QString  id) const

Returns the metadata of the property named by id.

If id does not reference a known property, returns NULL; Rememeber that there should be no intersection between property names of the several sets bound to a single discontinuity set, so id specifies a unique property among the several possible property sets.

◆ propertySetIndex()

int GmDiscontinuitySet::propertySetIndex ( QString  id) const

Returns the index in the list returned by propertySets() of the set that includes the named property.

If the id does not reference a known property, returns -1; Rememeber that there should be no intersection between property names of the several sets bound to a single discontinuity set, so id specifies a unique property among the several possible property sets.

◆ propertySets()

const QVector<GmPropertySet*>& GmDiscontinuitySet::propertySets ( ) const
inline

Returns a reference to the list of property sets associated to this set.

The order of the property sets in the list is consistent with results returned from propertySetIndex(), i.e, if a call to propertySetIndex("a") returns 1, the second entry of the list should be the property set that includes the "a" property.

◆ snapTolerance()

double GmDiscontinuitySet::snapTolerance ( ) const
inline

Returns the percentual tolerance used for snapping intersection points to nodes, edges or faces.

Returns true if internal nodes are not allowed in the intersection segments (except for internal segment intersections)

◆ usedMemory()

size_t GmDiscontinuitySet::usedMemory ( ) const

Returns an estimative of the memory used by the discontinuity set in bytes.

It returns in general the variable memory that depends on the number of discontinuities ignoring "constant" sizes.


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