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

A class used to represent a set of contact boundary conditions of the same type, tied to the same mesh. More...

#include <gmContactBoundaryCondition.h>

Inheritance diagram for GmContactBoundaryCondition:
Inheritance graph
[legend]
Collaboration diagram for GmContactBoundaryCondition:
Collaboration graph
[legend]

Public Member Functions

 GmContactBoundaryCondition (QString id, QString description, QString type, GmMesh *mesh, BcType bcType)
 Constructor. See parameter description on the GmBoundaryConditionBase constructor documentation.
 
virtual ~GmContactBoundaryCondition ()
 Destructor.
 
bool isGlobal () const
 Returns whether this table stores global or local boundary conditions.
 
int numPropertyValues () const
 Returns the number o property values.
 
GmContactBoundaryConditionAccessorpropertyAccessor (QString propertyId, Unit desiredUnit, const GmLogCategory &logger) const
 Returns an accessor for property values in the desired unit (can be a default unit for no unit conversion). More...
 
GmValueAccessormaterialAccessor (const GmLogCategory &logger) const
 Returns an accessor for querying/changing the material associated with each contact application point (BC lines) More...
 
const QStringListmaterialList () const
 Returns the contact material list.
 
int addPropertyLines (int n=1)
 Adds 'n' new lines to the contact boundary condition property values table. More...
 
void setMaterialList (const QStringList &matList)
 Replaces the material list. Keep in mind that the new list contents must be compatible with property material ids and with material values tied to application points. More...
 
bool setPropertyMaterialId (int contactIndex, const QString &id)
 Replaces the material id of a property value. The given string MUST be formated as 'x:y' where x and y are the names of the in contact materials represented by this property line. Both 'x' and 'y' must exist in the material list. More...
 
bool rebuildMaterialMapping (const GmLogCategory &logger)
 Rebuilds the internal mapping used by contactIndex(). Must be called after calls to setMaterialList() and/or setPropertyMaterialId() and before any subsequent call to contactIndex().
 
int contactIndex (int bcIndex1, int bcIndex2) const
 Given a pair of contact boundary condition line indices, returns the index in the user property values that contains the properties for the given material pair or -1 if no such pair exists.
 
- Public Member Functions inherited from GmBoundaryConditionBase
virtual ~GmBoundaryConditionBase ()
 Destructor.
 
QString id () const
 Returns the boundary condition name.
 
QString description () const
 Returns the boundary condition description.
 
QString type () const
 Returns the boundary condition type, to be interpreted by a physics object.
 
GmMeshmesh () const
 Returns the mesh that this boundary conditions are tied to.
 
BcType bcType () const
 Returns the type of bc, defining if the bc should be applied over nodes, edges or faces.
 
int numValues () const
 Returns the number of boundary conditions (lines) stored in the object.
 
int numProperties () const
 Returns the number of properties (columns) stored for each condition in the object.
 
QStringList propertyIds () const
 Returns the ids of the properties stored in this object (no special order is enforced)
 
GmValueInfopropertyInfo (QString propertyId) const
 Returns metadata information about a property or NULL if the property doesn't exists.
 
bool addProperty (GmValueInfo *info, GmSimulationData *data, const GmLogCategory &logger)
 Creates a new property for storing data associated with the metadata information received as a parameter in 'info'. More...
 
int numNodes (int bcIndex) const
 Returns the number of nodes over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_NODE. The parameter bcIndex should be a value between 0 and numValues()-1;. More...
 
int node (int bcIndex, int nodeIndex) const
 Returns a node from the list with node numbers over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_NODE. The parameter bcIndex should be a value between 0 and numValues()-1. The nodeIndex parameter should be a value between 0 and numNodes(bcIndex) - 1. More...
 
GmCellcell (int bcIndex) const
 Returns the cell over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_CELL. The parameter bcIndex should be a value between 0 and numValues()-1;.
 
int numBoundaryCells (int bcIndex) const
 Returns the number of cells over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_EDGE or GM_BC_FACE. The parameter bcIndex should be a value between 0 and numValues()-1;. More...
 
GmCellboundaryCell (int bcIndex, int cellIndex) const
 Returns a cell from the list with (cell, border) pairs over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_EDGE or GM_BC_FACE. The parameter bcIndex should be a value between 0 and numValues()-1. The cellIndex parameter should be a value between 0 and numBoundaryCells(bcIndex) - 1.
 
int boundaryCellBorder (int bcIndex, int cellIndex) const
 Returns a border index from the list with (cell, border) pairs over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_EDGE or GM_BC_FACE. The parameter bcIndex should be a value between 0 and numValues()-1. The cellIndex parameter should be a value between 0 and numBoundaryCells(bcIndex) - 1.
 
const GmCellBoundaryboundary (int bcIndex) const
 Returns the boundary over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_EDGE, GM_BC_FACE or GM_BC_NODE and will return NULL if the bc was not defined by a boundary object. The parameter bcIndex should be a value between 0 and numValues()-1;. More...
 
GmCellBoundaryboundary (int bcIndex)
 Overload of the homonimous const version.
 
const GmNodeSetnodeSet (int bcIndex) const
 Returns the node set over which the referenced boundary condition is applied. Must be called only for objects with bcType() == GM_BC_NODE and will return NULL if the bc was not definied by a node set. The parameter bcIndex should be a value between 0 and numValues()-1;. More...
 
GmNodeSetnodeSet (int bcIndex)
 Overload of the homonimous const version.
 
void clear ()
 Clears BC application point data, including attribute values associated with application point lines. More...
 
void setNode (int bcIndex, int node)
 Set the node index associated with condition 'bcIndex'. More...
 
void setNode (int bcIndex, GmCellBoundary *boundary)
 Set the list of nodes associated with condition 'bcIndex' from a boundary object. Can be used only for objects with bcType() == GM_BC_NODE. More...
 
void setNode (int bcIndex, GmNodeSet *nodeSet)
 Set the list of nodes associated with condition 'bcIndex' from a node set object. Can be used only for objects with bcType() == GM_BC_NODE. More...
 
void setNode (int bcIndex, int numNodes, int *nodes)
 Set the list of nodes associated with condition 'bcIndex' from a list of nodes. Can be used only for objects with bcType() == GM_BC_NODE. More...
 
void setCell (int bcIndex, int cell)
 Set the cell index associated with condition 'bcIndex'. Can be used only for objects with bcType() == GM_BC_CELL. More...
 
void setBoundary (int bcIndex, int cell, int border)
 Set the boundary associated with condition 'bcIndex'. Can be used only for objects with bcType() == GM_BC_EDGE or GM_BC_FACE. More...
 
void setBoundary (int bcIndex, GmCellBoundary *boundary)
 Set the boundary associated with condition 'bcIndex'. Can be used only for objects with bcType() == GM_BC_EDGE or GM_BC_FACE. More...
 
void setBoundary (int bcIndex, int numCells, int *cells, int *borders)
 Set the boundary associated with condition 'bcIndex'. Can be used only for objects with bcType() == GM_BC_EDGE or GM_BC_FACE. More...
 
void reloadNodeBoundaryData (int bcIndex)
 Reloads node information for a NODE boundary condition specified via a border object. Needed for the boundary condition to recognize changes in a border contents.
 
int addLines (int n=1)
 Adds 'n' new lines to the boundary condition table. More...
 
void removeLines (int bcIndex, int n=1)
 Removes n boundary condition lines, starting at bcIndex.
 
int addNodeLine (int node)
 Adds a new boundary condition line to a GM_BC_NODE object, filling the node information. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setNode().
 
int addNodeLine (GmCellBoundary *boundary)
 Adds a new boundary condition line to a GM_BC_NODE object, filling the node information from a boundary object. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setNode()
 
int addNodeLine (GmNodeSet *nodeSet)
 Adds a new boundary condition line to a GM_BC_NODE object, filling the node information from a node set object. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setNode()
 
int addNodeLine (int numNodes, int *nodes)
 Adds a new boundary condition line to a GM_BC_NODE object, filling the node information from the given node list. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setNode()
 
int addCellLine (int cell)
 Adds a new boundary condition line to a GM_BC_CELL object, filling the cell information. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setCell()
 
int addBoundaryLine (int cell, int border)
 Adds a new boundary condition line to a GM_BC_EDGE/GM_BC_FACE object, filling the boundary information from a cell/border pair. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setBoundary()
 
int addBoundaryLine (GmCellBoundary *boundary)
 Adds a new boundary condition line to a GM_BC_EDGE/GM_BC_FACE object, filling the boundary information. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setBoundary()
 
int addBoundaryLine (int numCells, int *cells, int *borders)
 Adds a new boundary condition line to a GM_BC_EDGE/GM_BC_FACE object, filling the boundary information from the given lists of cells/borders. Property values (when tied to application points) should be filled by using accessors. Returns the index of the added line or -1 on error. Equivalent to calling addLines() + setBoundary()
 
void print (const GmLogCategory &logger, GmLogLevel level, int summary) const
 Prints boundary condition information to the specified logger/level. More...
 
size_t printMemoryStatistics (const GmLogCategory &logger, GmLogLevel level) const
 Prints memory usage for this boundary condition 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 boundary condition in bytes. More...
 

Static Public Member Functions

static GmContactBoundaryConditionloadFromTable (LuaTable &tab, GmSimulationData *data, const GmLogCategory &logger)
 Loads a contact boundary condition object full definition from a Lua table. More...
 
- Static Public Member Functions inherited from GmBoundaryConditionBase
static QString bcTypeToStr (BcType type)
 Returns a string representing the bc type.
 
static int strToBcType (QString str)
 Returns the BcType from the provided string or -1 if the type is unknown.
 

Protected Member Functions

virtual QString msgPrefix () const
 The contents of the %1 argument on the "%1boundary condition" string used on error messages.
 
virtual void printExtraHeaderInfo (const GmLogCategory &logger, GmLogLevel level) const
 Print additional header info. Called by GmBoundaryConditionBase::print()
 
virtual void printExtraPropertyValues (const GmLogCategory &logger, GmLogLevel level) const
 Print property values info. Called by GmBoundaryConditionBase::print()
 
- Protected Member Functions inherited from GmBoundaryConditionBase
 GmBoundaryConditionBase (QString id, QString description, QString type, GmMesh *mesh, BcType bcType)
 
virtual void clearObjects ()
 Aux function used to delete all objects pointed to by _appPointData. All entries are set to 0.
 
size_t appPointUsedMemory () const
 Returns an estimative of the size needed to store application point data.
 
GmValueAccessoruserValueAccessor (QString propertyId, Unit desiredUnit, const GmLogCategory &logger) const
 Auxilliary function to return a value accessor for a boundary condition property.
 
QString nodeListStr (int bcIndex, int titleSize, bool align, bool *cropped) const
 Builds a string with the nodes in bcIndex, trying not to surpass titleSize. Returns in cropped whether the string was cropped or not.
 
QString cellBoundaryListStr (int bcIndex, int titleSize, bool *cropped) const
 Builds a string with the (cell id, border id) pairs in bcIndex, trying not to surpass titleSize Returns in cropped whether the string was cropped or not.
 
bool mergeLines (LuaTable &tab, int tabSize, const QList< GmValueAccessor * > &acList, int maxLines, const GmLogCategory &logger, QVector< int > &transTable, QVector< int > &countTable)
 
bool parseValueFromVariant (GmValueAccessor *ac, const QVariant &v, GmNanBoxedValue *data, const GmLogCategory &logger)
 Parses the value in v following the exact same rules as GmValueAccessorBase::setValueFromVariant(), storing the parsed values in the data vector. More...
 
int appPointIndex (int bcIndex, int listIndex) const
 An auxilliary function to support the need in GmBoundaryConditionAccessor to find the cell / node index where the property accessor is applied. More...
 

Private Member Functions

bool parseMaterialPair (QString matId, const QMap< QString, double > &matMap, int *firstIndex, int *secondIndex)
 Helper function used to break a property value id into its material indices, checking the id validity. FirstIndex and secondIndex can be NULL. In that case the id will be checked but the indices will not be returned.
 

Private Attributes

bool _global
 Is this a global or a local contact BC?
 
QStringList _materialList
 The material list data.
 
GmValueAccessor_materialAc
 The accessor for the column storing the material index associated with each BC.
 
QStringList _propertyMaterialIds
 The ids of the property values.
 
QVector< QMap< int, int > > _materialMap
 Given a material index (recovered from the material column of the application point table), stores a map with the indices of the associated materials and the position of the pair in the user property sets. For each (i, j) pair, where i is the vector index and j the map index, only values where i<=j are stored since the relationship is commutative. Although the values stored in the material column are 1-based, the vector, the map and the property set indices are all 0-based.
 

Additional Inherited Members

- Public Types inherited from GmBoundaryConditionBase
enum  BcType { GM_BC_NODE, GM_BC_EDGE, GM_BC_FACE, GM_BC_CELL }
 Boundary condition type defining where a BC is applied (node, edge or face) More...
 
- Static Protected Member Functions inherited from GmBoundaryConditionBase
template<class T >
static T * loadFromBaseTable (LuaTable &tab, GmSimulationData *data, const GmLogCategory &logger, QString msgPrefix="", const QList< GmValueInfo * > &appPointInfoList=QList< GmValueInfo * >())
 Loads a boundary condition object full definition from a Lua table. More...
 
template<class T >
static bool loadFromDumpFile (T *bc, QString dumpFile, GmSimulationData *data, const GmLogCategory &logger, QString msgPrefix)
 Fill bc with data read from the given dump file.
 
- Protected Attributes inherited from GmBoundaryConditionBase
QString _id
 The boundary condition id (name)
 
QString _description
 A description of the boundary conditions.
 
QString _type
 The type of this conditions, to be interpreted by a physics object.
 
GmMesh_mesh
 The mesh that this boundary conditions are tied to.
 
BcType _bcType
 The type of bc. Defines if the bc should be applied over nodes, edges or faces.
 
int _numValues
 The number of boundary conditions stored in this object.
 
QMap< QString, int > _userPropertiesMap
 Map translating ids from properties into their position in _userPropertiesData.
 
QVector< GmValueSet * > _userPropertiesData
 List with set of values for the user properties.
 
QVector< GmValueSet * > _appPointPropertiesData
 List with set of values tied to the application points. Filled only when those are different from _userPropertiesData.
 
bool _appPointUserProperties
 Set to true if user properties are tied to application points, false otherwise.
 
QVarLengthArray< BcTaggedPtr, 1 > * _appPointData
 A vector with size _numValues storing the boundary condition application points. More...
 

Detailed Description

A class used to represent a set of contact boundary conditions of the same type, tied to the same mesh.

Member Function Documentation

◆ addPropertyLines()

int GmContactBoundaryCondition::addPropertyLines ( int  n = 1)

Adds 'n' new lines to the contact boundary condition property values table.

The new property values are initialized with their default values and should be updated with porperty accessors. Each new property id should be set with setPropertyMaterialId().

Returns the index of the first added line or -1 on errors.

◆ loadFromTable()

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

Loads a contact boundary condition 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 bc definition point node or boundary).

This function expects that a basic validation step has been done elsewhere.

If the 'merge' field in the boundary condition description is equal to 0, no merging attempt will be made. If equal to an integer number greater than 0, a merge attempt will be made using that value as the maximum number of different lines that can be found in the merge attempt. Use a big number for an unbounded number of possible unique values (might be slow). If the field is absent, the default from the 'defBoundaryConditionMerge' field in the set of simulation options will be used (otherwise a value of 0 will be used).

◆ materialAccessor()

GmValueAccessor * GmContactBoundaryCondition::materialAccessor ( const GmLogCategory logger) const

Returns an accessor for querying/changing the material associated with each contact application point (BC lines)

The returned pointer must be deallocated by the caller.

◆ propertyAccessor()

GmContactBoundaryConditionAccessor * GmContactBoundaryCondition::propertyAccessor ( QString  propertyId,
Unit  desiredUnit,
const GmLogCategory logger 
) const

Returns an accessor for property values in the desired unit (can be a default unit for no unit conversion).

The returned pointer must be deallocated by the caller. Returns NULL if the property doesn't exists or an accessor can't be created (can't convert to the desired unit, for example).

The logger parameter exists to allow for the accessor to report errors when evaluating a function value, for example.

◆ setMaterialList()

void GmContactBoundaryCondition::setMaterialList ( const QStringList matList)

Replaces the material list. Keep in mind that the new list contents must be compatible with property material ids and with material values tied to application points.

IMPORTANT: After a new list is set and property ids are made compatible with it, a call to rebuildMaterialMapping() must be made before any subsequent calls to contactIndex().

◆ setPropertyMaterialId()

bool GmContactBoundaryCondition::setPropertyMaterialId ( int  contactIndex,
const QString matId 
)

Replaces the material id of a property value. The given string MUST be formated as 'x:y' where x and y are the names of the in contact materials represented by this property line. Both 'x' and 'y' must exist in the material list.

IMPORTANT: After a property material id change, a call to rebuildMaterialMapping() must be made before any subsequent calls to contactIndex().


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