![]() |
GemaMesh
The GeMA Mesh Plugin
|
Auxiliary class used to load mesh data from a Lua file. More...
#include <gmpMeshLoader.h>

Classes | |
| struct | DataIt |
| Iterator structure returned by tableSize and consumed by ttable / itable. More... | |
Public Member Functions | |
| GmpMeshLoader (GmSimulationData *simulation, const GmLogCategory &logger) | |
| Constructor. Creates a mesh loader. Data will be loaded when loadMeshData is called. | |
| virtual | ~GmpMeshLoader () |
| Destructor. Data should not be destroyed since it should be retrieved by the mesh. | |
| virtual bool | loadMeshData (LuaTable &table, GmMesh *mesh, GmpNodeMeshData< Vector > *nd, GmpCellMeshData< Vector > *cd, GmPCR **meshPcr, bool *newPcr) |
| Loads the mesh data from the supplied Lua table. | |
Protected Types | |
| enum | LoadMode { LOAD_FROM_LUA , LOAD_FROM_DUMP , LOAD_FROM_HDF5 } |
| Enum defining from where the data should be loaded. More... | |
Protected Member Functions | |
| bool | loadMeshDataAux (LuaTable &table, GmMesh *mesh, LoadMode loadFrom, QString srcFile, GmPCR **meshPcr, bool *newPcr) |
| Auxiliar function to loadMeshData(). | |
| bool | loadMetaData (LuaTable &table, GmMesh *mesh) |
| Loads from the Lua model the basic metadata information needed for further reading of the model from the Lua file, HDF5 file or from a dump file. | |
| bool | loadCoordMetaData (LuaTable &table, GmMesh *mesh) |
| Helper function to load coordinate metadata. | |
| bool | loadNodeValueInfoMetaData (LuaTable &table, GmMesh *mesh) |
| Helper function to load value info objects for node attributes and state vars tied to the mesh. | |
| bool | loadCellValueInfoMetaData (LuaTable &table, GmCellMesh *mesh) |
| Helper function to load value info objects for node attributes and state vars tied to the mesh. | |
| bool | loadGaussValueInfoMetaData (LuaTable &table, GmElementMesh *mesh) |
| Helper function to load value info objects for Gauss attributes tied to the mesh. | |
| bool | loadPropertySetMetaData (LuaTable &table, GmCellMesh *mesh) |
| Loads property set information into the property set list and checks if all attributes are unique. | |
| bool | loadIntegrationRulesIntoMesh (LuaTable &table, GmElementMesh *mesh) |
| Reads information about integration rules for an element mesh and adds them to the mesh. | |
| bool | loadTopologyConfigOptions (LuaTable &table, GmCellMesh *mesh) |
| Loads topology related attributes from the mesh table, filling the respective parameters from _cd. The _topoBuildEdgeMap / _topoCheckOptions configurations must be set even if we are not creating the topology now since it might be needed afterwards (on demand loading or mesh load from a dump). Also updates _buildTopo to true if the user requested for immediate topology building. | |
| bool | initPcrObject (LuaTable &table, GmMesh *mesh, bool partition) |
| Loads the PCR object from the supplied table or from the global config if empty on table. The partition flag states whether the PCR object must support partitioning or not. Fills the _pcr and _newPcr attributes. Already initializes the pcr object with the current mesh. Returns false on errors. | |
| bool | traverseAttributeDefinitions (LuaTable &table, const char *tableName, GmValueSetKind setKind, std::function< bool(GmValueInfo *)> adder) |
| Parses the set of (node, cell, gauss) attribute definitions present on the given Lua table, calling the adder function to place the associated ValueInfo objects on their proper place. The source table with the attribute definitions is named by tableName, and the attribute type given by setKind. The adder function MUST take OWNERSHIP of the given info object. That means that if it does not store that info object in a list, it should delete the object. If the adder function returns false, the traversal will continue for all the definitions but the traverse function will return false at the end. | |
| bool | traverseStateVarDefinitions (LuaTable &table, GmValueSetKind setKind, std::function< bool(GmValueInfo *)> adder) |
| Parses the set of node or cell state var definitions tied to the mesh, calling the adder function to place the associated ValueInfo objects on their proper place. The setKind parameter defines if we are handling node or cell vars. The adder function MUST take OWNERSHIP of the given info object. That means that if it does not store that info object in a list, it should delete the object. If the adder function returns false, the traversal will continue for all the state vars but the traverse function will return false at the end. | |
| bool | addNodeValueSetsToMesh (GmMesh *mesh) |
| Adds a new value set to the mesh for every value info stored on _nodeList. | |
| bool | addCellValueSetsToMesh (GmCellMesh *mesh) |
| Adds a new value set to the mesh for every value info stored on _cellList Also calls mesh->initCellValueSets(), a required step even if there are no objects in the list. | |
| bool | addGaussValueSetsToMesh (GmElementMesh *mesh) |
| Adds a new value set to the mesh for every value info stored on _gaussList Also calls mesh->initGaussAttributeSets(), a required step even if there are no objects in the list. | |
| void | loadNumNodesFromLua (LuaTable &table, int *nnodes, int *nghost) |
| Helper function to load the number of nodes and ghost nodes from the Lua model, filling nnodes and nghost. | |
| bool | loadNodeCoordinatesFromLua (LuaTable &table, GmMesh *mesh, int nnodes, int nghost) |
| Helper function to load geometric & ghost node coordinates. If the mesh was partitioned, the PCR object defines which nodes should be loaded and which ignored. nnodes and nghost are the effective number of nodes after partitioning. | |
| bool | loadNodeDataFromLua (LuaTable &table, GmMesh *mesh) |
| Helper function to load per node data (attributes & state vars) | |
| bool | loadNodeSetsFromLua (LuaTable &table, GmMesh *mesh) |
| Loads node set information from the "nodeSetData" field. Expects node information to have already been loaded. Cell information should also be loaded in order for it to be possible to init a node set with the nodes in a cell group. | |
| bool | loadCellNodeIncidencesFromLua (LuaTable &table, GmCellMesh *mesh, int *numCellsByType) |
| Loads cell node incidences, including ghost nodes and cell properties If numCellsByType is not NULL, the mesh was already partitioned and this vector, with size equal to GM_NUM_CELL_TYPES, contains the description of our current partition number of cells per type. | |
| bool | loadCellDataFromLua (LuaTable &table, GmCellMesh *mesh) |
| Loads cell data from the cell table. | |
| bool | loadCellGroupsFromLua (LuaTable &table, GmCellMesh *mesh, const QStringList &filter, bool skipFilter) |
| Loads cell group data from both the cellData and cellGroupData tables, possibly filtered by the given list. If the list is empty, all groups will be loaded. If not, only those groups will be loaded if skipFilter is false and all groups except those in the list if skipFilter is true. Names on the filter but not on the model will be silently ignored. When skipFilter is true, assumes that the groups in skip filter are pre-loaded in the mesh. | |
| bool | loadBoundaryDataFromLua (LuaTable &table, GmCellMesh *mesh, const char *tableName, GmCellBoundaryType cellType) |
| Loads data defining boundary groups. | |
| bool | loadNumCellsByType (LuaTable &table, GmCellMesh *mesh, int *numCellsByType) |
| Loads cell count statistic into numCellsByType (assumed to be filled with 0). | |
| void | adjustSingleCellType (LuaTable &table, GmCellMesh *mesh, int *numCellsByType) |
| If the user enabled the singleCellType option, let's check it against the actual cell types. | |
| void | getCellAndNodeCountFromPCR (int *nnodes, int *nghost, int *cellsByType) |
| Gathers the number of nodes and cells after mesh partitioning from the PCR object, filling nnodes with the number of geometry nodes, nghost with the number of ghost nodes and cellsByType with the number of cells of each type. Assumes cellsByType to be a vector with size equal to GM_NUM_CELL_TYPES, filled with zeros. Expects that the cells in _cd to be the unpartitioned set of cells. | |
| bool | loadBoundaryDataFromCellList (LuaEnv *env, QVariant &cellListData, GmCellMesh *mesh, GmCellBoundaryType cellType, QString id) |
| Loads data defining a single boundary group from the cell list. | |
| bool | loadBoundaryDataFromBorderFilter (LuaFunction &filter, int borderId, GmCellMesh *mesh, GmCellBoundaryType cellType, QString id) |
| Loads data defining a single boundary group from the cell list. | |
| bool | loadCellGroupsFromCellDefinition (LuaTable &table, GmCellMesh *mesh, const QStringList &filter, bool skipFilter) |
| Loads cell data from the cell table. See comments on loadCellGroupsFromLua() for filter description. | |
| bool | loadAdditionalCellGroupDataFromCellList (LuaEnv *env, QVariant &cellListData, GmCellMesh *mesh, QString id) |
| Reads an additional cell group definition from cellGroupData.cellList. | |
| bool | loadAdditionalCellGroupDataFromFilter (LuaFunction &filter, GmCellMesh *mesh, QString id) |
| Reads an additional cell group definition by applying cellGroupData.extractFilter to the full set of mesh cells. | |
| bool | loadFromDump (QString dumpFile, GmMesh *mesh) |
| Loads the mesh definition from the given dump file. | |
| GmHdf5ModelReader * | initHdf5Reader (QString hdf5File, GmMesh *mesh, const GmHdf5ModelReader::MeshInfo **info) |
| Initializes the Hdf5 reader object and loads basic information from the file. Returns the reader object and fills info with the basic file data. The returned pointer must be deleted by the caller. | |
| bool | loadNodeCoordinatesFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmMesh *mesh, int nnodes, int nghost) |
| Loads geometry and ghost node coordinates from the given hdf5 file. If the mesh was partitioned, the PCR object defines which nodes should be loaded and which ignored. nnodes and nghost are the effective number of nodes after partitioning. | |
| bool | loadNodeDataFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmMesh *mesh) |
| Loads initial node attribute data from the given hdf5 file. | |
| bool | loadNodeSetsFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmMesh *mesh) |
| Loads node sets from the given hdf5 file. | |
| bool | loadCellNodeIncidencesFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmCellMesh *mesh, int *numCellsByType) |
| Loads cell nodal incidence from the given hdf5 file including ghost nodes if any. If numCellsByType is not NULL, the mesh was already partitioned and this vector, with size equal to GM_NUM_CELL_TYPES, contains the description of our current partition number of cells per type. | |
| bool | loadCellDataFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmCellMesh *mesh) |
| Loads initial cell attribute data from the given hdf5 file. | |
| bool | loadGaussDataFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmElementMesh *mesh, const QVector< int > &cellTypeList) |
| Loads initial gauss attribute data from the given hdf5 file. If the mesh was partitioned, cellTypeList should be a vector with size equal to the number of cells in the global, unpartitioned, mesh, filled with cell types in their original mesh order. Otherwise, it should be empty. | |
| bool | loadInactiveCellsFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmCellMesh *mesh) |
| Loads inactive cell information from the given hdf5 file. | |
| bool | loadCellGroupsFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmCellMesh *mesh, const QStringList &filter, bool skipFilter) |
| Loads cell group definitions from the given hdf5 file. See comments on loadCellGroupsFromLua() for filter description. | |
| bool | loadBoundaryDataFromHdf5 (GmHdf5ModelReader *reader, const GmHdf5ModelReader::MeshInfo *info, GmCellMesh *mesh) |
| Loads cell edge and face border definitions from the given hdf5 file. | |
| bool | reorderNodes (GmMesh *mesh) |
| Reorder nodes using the configured PCR object. Notice that this call might or might not reorder nodes, depending on the configuration of the PCR object. The applied algorithm also depends on the PCR object. If a reorder is done, also reorders nodes on the coordinate vector. | |
| bool | reorderCells (GmMesh *mesh) |
| Reorder cells using the configured PCR object. Notice that this call might or might not reorder cells, depending on the configuration of the PCR object. The applied algorithm also depends on the PCR object. If a reorder is done, also reorders cells on the cells vector, nodes on the node incidence vector, properties on the cell properties vector and any pre-loaded cell groups. | |
| int | parseIntegrationRuleInfo (QVariant v, int *irType, int *r1, int *r2, int *r3) |
| Helper function to extract integration rule parameters from a variant received from the integration rules Lua table. | |
| int | parseSide (LuaTable &tab, GmCellBoundaryType cellType, int *cellIndex, int *sideIndex, QString id, GmCellMesh *mesh, int entryIndex) |
| Parse and check a cell index, side index pair. Cell indices are translated by the PCR object. The id, mesh and entryIndex parameters are used on error messages only. Returns 1 if the pair is ok, 0 if the given entry is invalid or -1 if the cell is valid but it doesn't belongs to the current partition or is a remote halo cells, if so configured. | |
| DataIt | tableSize (LuaEnv *env, const QVariant &v, const char *field) |
| Given a QVariant that can be a table or a function, returns the table size or the result returned by the function when called without parameters. The field second parameter is used for error message purposes only. If the table has a "multiple" field set to true, the data will be gathered by the merge of the subtables in v. The multiple feature is only supported by tables of tables (data retrieved by ttable()), and not for tables of integers (data retrieved by itable()) | |
| LuaTable | ttable (LuaEnv *env, DataIt &it) |
| Given a data iterator created by a previous call to tableSize(), returns the next available data item (either from a single table, multiple tables or by calling the associated Lua function) | |
| int | itable (LuaEnv *env, DataIt &it) |
| Given a data iterator created by a previous call to tableSize(), returns the next available data item (either from a single table or by calling the associated Lua function - no current support for multiple tables) | |
| void | tableInc (LuaEnv *env, DataIt &it) |
| Increments it (returned by tabjeSize()), without returning the current value. | |
| void | cleanup (GmMesh *mesh) |
| Frees all memory allocated by the object. This function should be called on error situations. It can handle correctly the ownership of information objects present in _infoList/_ghostList/_gaussList no matter if they are already claimed by a value set or not. | |
Protected Attributes | |
| GmSimulationData * | _simulation |
| Pointer to simulation data. | |
| const GmLogCategory & | _logger |
| The logger object used to emmit messages. | |
| GmpNodeMeshData< Vector > * | _nd |
| The node data to be filled. | |
| GmpCellMeshData< Vector > * | _cd |
| The cell data to be filled. | |
| GmPCR * | _pcr |
| The PCR object created / referenced from the model by loadPcrObject();. | |
| bool | _newPcr |
| Was this PCR object created by us? | |
| bool | _buildTopo |
| Should we build the topology after mesh loading? | |
| QVector< GmValueInfo * > | _nodeList |
| Stores node attributes & state vars metadata while they where not yet claimed by a ValueSet. | |
| QVector< GmValueInfo * > | _ghostList |
| Stores ghost attributes & state vars metadata while they where not yet claimed by a ValueSet. | |
| QVector< GmValueInfo * > | _cellList |
| Stores cell attributes & state vars metadata while they where not yet claimed by a ValueSet. | |
| QVector< GmValueInfo * > | _gaussList |
| Stores Gauss attributes metadata while they where not yet claimed by a ValueSet. | |
Auxiliary class used to load mesh data from a Lua file.
The template parameter defines the kind of vector object used to store per node/cell data. It can be either GmSingleVector or GmDualVector
Mesh fields parsed by this plugin (the first 3, id, typeName and description, are parsed by the library and not by this plugin):
id: The mesh name
typeName: Plugin that will be used to load this mesh. Should be equal to 'GemaMesh.xxx', where xxx = nodes, cell or elem. description: The mesh description
dumpFile: When given, all the geometry information will be loaded from the given dump file by using the GmStateDump class. Data from the 'nodeData', 'ghostData', 'cellData', 'boundaryEdgeData', 'boundaryFaceData', 'cellGroupData' and 'nodeSetData' fields is ignored. Other fields are necessary and MUST have the same values that where used when the dump file was originally created. hdf5File: Similar to dumpFile but reading the data from a .gh5 file
topology: Should the mesh support topological queries? Default = false. topologyBuildEdgeMap : If the topology structure is ever built for a solid mesh, should it include the edge->half-face map? Default = false; topologyCheckOptions : Check level when building the topology structure. Options are "basic" (default), "simple", "full", "basic warn", "simple warn" or "full warn". The default can be changed by the configuration option topologyCheckOptions.
singleCellType: When set to true, GeMA can perform some space optimizations by assuming that the mesh includes only a single cell type (which can be checked) and, more importantly, that cells with different types will NOT be added to the mesh later during the orchestration. Default = false.
coordinateDim: The number of dimensions for each node coordinate coordinateUnit: The unit in which node coordinates are expressed coordinateFormat: A format string used when printing node coordinates
useGhostNodes: Should the mesh support ghost nodes? Default = false hOrder: Required only when using hierarchical elements (should be nil otherwise, ignored for non element meshes). Contains a table with two entries: P and Q, both integers specifying the hierarchical element order. Implies useGhostNodes = true.
stateVars: A table with the list of the state var ids that will be stored in each mesh node cellProperties: A table with the list of the property set ids that will be stored in each mesh cell
nodeAttributes: A table with the definition of the attributes associated with a mesh node cellAttributes: A table with the definition of the attributes associated with a mesh cell gaussAttributes: A table with the definition of the attributes associated with an element integration point
nodeData: A table storing node information for the mesh. This table has one sub-table for each node, storing, in this order, the node coordinates, node attribute values and node state var initial values. Alternatively, this field can be a function that when called with an index 'i' returns the 'ith' table element and when called without parameters the table size. It can also be given by a table with multiple 'standard' nodeData tables that will be concatenated by the loader.
ghostData: A table similar to nodeData storing ghost node coordinates and attributes / state var initial values. Will be parsed only if useGhostNodes is true.
cellData: A table storing cell connectivity information, cell grouping and cell initial attribute values. Each table entry is a sub-table with the following subfields: cellType - The type of the cells in this entry. cellGroup - The name of the group that this cells belongs to. Different table entries with same group name are merged in the same group by the reader. A group name is optional. xxx - When 'xxx' equals the name of a property set included in cellProperties, this field value will be the default property index associated with cells in the cellList that do not explicitly set the property index. A property index can be an integer index or an id name. cellList - The list of element connectivity, attribute values and property values definition. This list is a table with an entry for each element of this cellType/cellGroup, containing, in this order, the set of node numbers that define the cell, respecting the order expected by the cell type, followed by cell attribute values. Property set values should be given by a named (property set, index) pair. If useGhostNodes is set to true, a special key 'ghostNodes' can optionally receive a table with a set of cell ghost nodes. Alternatively, this field can be a function that when called with an index 'i' returns the 'ith' table element and when called without parameters the table size.
elementRules: A table defining the set of available integration rules for this mesh elements. Each table entry is a sub-table with one integration rule definition for every mesh element type. faceRules: A table defining the set of available integration rules that should be applied to element faces. Each table entry is a sub-table with one integration rule definition for every 3D mesh element type. edgeRules: A table defining the set of available integration rules that should be applied to element edges. Each table entry is a sub-table with one integration rule definition for every 2D and 3D mesh element types.
boundaryEdgeData: A table storing a set of named collections of cell borders. Each table entry is a sub-table that stores an id and a cellList where each entry is a cell id + a border id inside this cell. It can also be a function that when called with an index 'i' returns the i'th table element and when called without parameters the table size. The cell list can be replaced by a filter function given by extractFilter. This function is then applied over mesh border edges and defines which of those edges will make into the named boundary. The function API follows the documentation from GmLuaIteratorFilter. If the function is present, the extractBorder field can be used to further narrow the set of candidate edges. Its value can be either a border index or a cell id + border pair from an edge belonging to the desired border.
boundaryFaceData: Similar to boundaryEdgeData but storing face values and not edge values.
cellGroupData: A table storing a set of named collections of cells that will be merged with the cell groups defined in the cellData table. Notice that entries from this table should represent new cell groups. Each table entry is a sub-table that stores a new cel group id and a cellList where each entry is a cell id. It can also be a function that when called with an index 'i' returns the i'th table element and when called without parameters the table size. Like for boundaryEdgeData, the cell list can be replaced by a filter defined by the extractFilter field. It is used to select the set of cells added to the cell group. The function API also follows the documentation from GmLuaIteratorFilter.
nodeSetData: A table storing a set of named collections of nodes. Each table entry is a sub-table that stores an id and a nodeList where each entry is a node id. Ghost nodes are represented by negative values, so a value of -2 represents the second mesh ghost node. Alternatively, the nodeList can be given by a cellGroupSet name. All the nodes from that cell group's elements will be included in the set. It can also be a function that when called with an index 'i' returns the i'th table element and when called without parameters the table size.
pcr: The name of the PCR (Partition-Color-Renumber) object that should be used for partitioning, coloring and/or renumbering node and cell data. If missing, the default plugin, as specified on the config file, will be used instead. pcrOptions: An easy way to configure the PCR object without the need for declaring it explicitly with the pcr attribute. If not nil, it should be a table with the set of options that will be passed to the new default PCR object, instanced from the plugin named in the configuration. This options will be merged with the default plugin options and can override definitions on the default options table.
For an example that contains most of the fields described above, see: gema\tests\regressionTests\bindingTests\basicData.lua
|
protected |
|
protected |
Adds a new value set to the mesh for every value info stored on _nodeList.
|
protected |
Given a data iterator created by a previous call to tableSize(), returns the next available data item (either from a single table or by calling the associated Lua function - no current support for multiple tables)
IMPORTANT: The returned integer value is removed from the Lua stack. IMPORTANT2: This function can be called it._size times, no more.
|
virtual |
Loads the mesh data from the supplied Lua table.
Node and cell data are read directly into the supplied structures. Attributes are directly loaded into the mesh using the standard service for attribute handling. If cells should also be loaded, cd should be provided and it must be possible to cast the mesh parameter to a GmCellMesh. A PCR object will also be created or obtained from the model. It will be used to update the mesh pcr reference and whether it was created by the loader or not.
|
protected |
Auxiliar function to loadMeshData().
Makes the error handling easier since cleanup on errors should be done by the caller
|
protected |
Loads from the Lua model the basic metadata information needed for further reading of the model from the Lua file, HDF5 file or from a dump file.
IMPORTANT: Expects that _nd->_ghostEnabled has already been filled, together with the cell allocator and cell size for cell meshes.
The following information is read:
|
protected |
Given a data iterator created by a previous call to tableSize(), returns the next available data item (either from a single table, multiple tables or by calling the associated Lua function)
IMPORTANT: The returned table references a table left by the function on top of the Lua stack. IMPORTANT2: This function can be called it._size times, no more.