![]() |
GemaCoreLib
The GeMA Core library
|
A base class used to implement the common part between GmBoundaryCondition and GmContactBoundaryCondition. Should NOT be instanced directly. More...
#include <gmBoundaryCondition.h>
Public Types | |
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... | |
Public Member Functions | |
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. | |
GmMesh * | mesh () 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) | |
GmValueInfo * | propertyInfo (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... | |
GmCell * | cell (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... | |
GmCell * | boundaryCell (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 GmCellBoundary * | boundary (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... | |
GmCellBoundary * | boundary (int bcIndex) |
Overload of the homonimous const version. | |
const GmNodeSet * | nodeSet (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... | |
GmNodeSet * | nodeSet (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 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 | |
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. | |
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 |
Aux function to print(), giving a chance for derived classes to add additional header data. | |
virtual void | printExtraPropertyValues (const GmLogCategory &logger, GmLogLevel level) const |
Aux function to print(), giving a chance for derived classes to add property values when _appPointUserProperties is false. | |
size_t | appPointUsedMemory () const |
Returns an estimative of the size needed to store application point data. | |
GmValueAccessor * | userValueAccessor (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... | |
Static Protected Member Functions | |
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 | |
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... | |
Private Member Functions | |
Q_DISABLE_COPY (GmBoundaryConditionBase) | |
Friends | |
class | GmBoundaryConditionAccessor |
class | GmContactBoundaryConditionAccessor |
class | GmBoundaryConditionStateDumpItem |
A base class used to implement the common part between GmBoundaryCondition and GmContactBoundaryCondition. Should NOT be instanced directly.
Boundary condition type defining where a BC is applied (node, edge or face)
int GmBoundaryConditionBase::addLines | ( | int | n = 1 | ) |
Adds 'n' new lines to the boundary condition table.
The application point information MUST be filled by subsequent calls to setNode(), setCell() or setBoundary(). Property values are initialized with their default values if they are tied to application points.
Returns the index of the first added line or -1 on errors.
bool GmBoundaryConditionBase::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'.
The new property takes ownership of the info object. After this function returns, values can be added to the new property through an accessor.
It should be noted that info MUST have kind equal to GM_BC_NODE_PROPERTY or GM_BC_BOUNDARY_PROPERTY
The function returns false in case of errors (memory could not be allocated, or the object already has a value with the requested id, for example) and logs an error message. In that case, info is NOT deallocated by addProperty().
The data parameter is needed to allow the evaluation of eventual user functions associated to the property.
|
protected |
An auxilliary function to support the need in GmBoundaryConditionAccessor to find the cell / node index where the property accessor is applied.
If this boundary condition is applied over a node, bcIndex should be the boundary condition index (line inside the boundary condition table) and listIndex the index of the given node inside the node list. The function then returns the mesh index of the given node (if the node is a ghost node, it returns its linear index, as required by GmValueSetEvalContext::setDataIndex()).
For boundary conditions applied over cells, on the other hand, bcIndex is also the boundary condition index, but list index will be the index of a cell in the given border or 0 for cell based boundary conditions. The function then returns the mesh index of the given cell.
const GmCellBoundary * GmBoundaryConditionBase::boundary | ( | 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;.
IMPORTANT: This function should NOT be used to traverse cell borders in a GM_BC_EDGE or GM_BC_FACE boundary condition since they can also be defined on terms of a single or multiple (cell, border) pairs, defined without the use of a boundary object.
void GmBoundaryConditionBase::clear | ( | ) |
Clears BC application point data, including attribute values associated with application point lines.
Keep in mind that this function does not remove the set of attributes added to the boundary condition.
|
staticprotected |
Loads a boundary condition object full definition from a Lua table.
The template parameter is the derived class that will be instanced by this function.
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).
If the app point info list field is not empty, the supplied objects will be used to create value sets and initialize the _appPointPropertiesData set, together with marking the _appPointUserProperties as false. In this scenario, the user properties are NOT tied to the application points. The function takes ownership of the given info objects. They are destroyed in case of errors.
|
protected |
Aux structure to store information about merged lines
< Vector with line values
< Hash code of the _lineValues contents
< The index in merged table for the first entry with this line values
Constructor. Initializes the structure with the given hash and position, along with a COPY of the given values vector
Destructor. Deletes the values vector created by the constructor
Check if the current info is equal to the given set of values. The check is done by first comparing hashes, comparing the vectors only if the hashes are equal
int GmBoundaryConditionBase::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.
If the node is a ghost node, it will have its 'ghost bit' set.
const GmNodeSet * GmBoundaryConditionBase::nodeSet | ( | 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;.
IMPORTANT: This function should NOT be used to traverse nodes in a GM_BC_NODE boundary condition since they can also be defined on terms of single nodes / boundary objects.
int GmBoundaryConditionBase::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;.
The returned size will be greater than one when a boundary BC is defined by the way of a boundary object, whose (cell, border) pairs will form the resulting list.
int GmBoundaryConditionBase::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;.
The returned size will be greater than one when a nodal BC is defined by the way of a node set or by a boundary object, whose nodes will form the resulting list.
|
protected |
Parses the value in v following the exact same rules as GmValueAccessorBase::setValueFromVariant(), storing the parsed values in the data vector.
Expects data to have a size equal to the accessor dimension (ac->valueSize()). When storing function values for a multidimensional accessor, the pointer is replicated in every dimension.
void GmBoundaryConditionBase::print | ( | const GmLogCategory & | logger, |
GmLogLevel | level, | ||
int | summary | ||
) | const |
Prints boundary condition information to the specified logger/level.
If summary is equal to 0, all the information will be printed. Otherwise, it should be a positive number defining the maximum number of value lines that will be printed.
void GmBoundaryConditionBase::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.
The parameter bcIndex should be a value between 0 and numValues()-1. Parameters cell and border should specify a valid mesh boundary edge or face.
void GmBoundaryConditionBase::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.
The parameter bcIndex should be a value between 0 and numValues()-1. Boundary specifies a valid mesh boundary edge or face.
void GmBoundaryConditionBase::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.
The parameter bcIndex should be a value between 0 and numValues()-1. Parameters cells and borders are vectors with numCells entries and should specify valid mesh boundary edges or faces.
void GmBoundaryConditionBase::setCell | ( | int | bcIndex, |
int | cell | ||
) |
Set the cell index associated with condition 'bcIndex'. Can be used only for objects with bcType() == GM_BC_CELL.
The parameter bcIndex should be a value between 0 and numValues()-1. Cell specifies a valid mesh cell.
void GmBoundaryConditionBase::setNode | ( | int | bcIndex, |
int | node | ||
) |
Set the node index associated with condition 'bcIndex'.
Can be used only for objects with bcType() == GM_BC_NODE.
The parameter bcIndex should be a value between 0 and numValues()-1. Node specifies a valid mesh node and can be a normal node or a ghost node. For ghost nodes, the given value should have its ghost bit set (ghost nodes are always stored in the B.C with its high bit set, like nodes stored in a cell.
void GmBoundaryConditionBase::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.
The parameter bcIndex should be a value between 0 and numValues()-1.
void GmBoundaryConditionBase::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.
The parameter bcIndex should be a value between 0 and numValues()-1.
void GmBoundaryConditionBase::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.
The parameter bcIndex should be a value between 0 and numValues()-1. The boundary condition takes the ownership of the node list.
size_t GmBoundaryConditionBase::usedMemory | ( | ) | const |
Returns an estimative of the memory used by the boundary condition in bytes.
It returns in general the variable memory that depends on the number of bc entries but does not include all constant overheads used by the class for control
When a boundary condition references a mesh boundary object, only the pointer cost is computed, not including the actual memory stored by the boundary object.
|
protected |
A vector with size _numValues storing the boundary condition application points.
The contents of the tagged pointers depend on _bcType. For GM_BC_NODE it can be: a node index, a pointer to a BcNodeSet (an internal class to GmBoundaryCondition) or a pointer to a node set. For GM_BC_CELL the only current option is a cell index. Finally, for GM_BC_EDGE and GM_BC_FACE, the tagged pointer can store: a pointer to a cell boundary, an integer storing together a cell index + a border index or a pointer to a BcCellBoundary (another internal class to GmBoundaryCondition).
This member is a pointer and not an object to prevent the need to include the BcTaggedPtr in the header file becouse doing so creates a dependency on the qtUtils lib by every project that include this header file.