GemaMesh
The GeMA Mesh Plugin
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GmpMeshLoader< Vector > Class Template Reference

Auxiliary class used to load mesh data from a Lua file. More...

#include <gmpMeshLoader.h>

Collaboration diagram for GmpMeshLoader< Vector >:
Collaboration graph
[legend]

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, GmpMeshData< Vector > *nd, GmpCellMeshData< Vector > *cd, GmpMeshLoaderCellAllocator cellAllocator)
 Loads the mesh data from the supplied Lua table. More...
 

Protected Member Functions

bool loadMeshDataAux (LuaTable &table, GmMesh *mesh, GmpMeshLoaderCellAllocator cellAllocator)
 Auxiliar function to loadMeshData(). More...
 
bool loadCoordData (LuaTable &table)
 Helper function to load coordinate metadata.
 
bool loadStateVarDefData (LuaTable &table, GmMesh *mesh)
 Helper function to load state vars structure definition.
 
bool loadAttributeDefData (LuaTable &table, const char *tabName, GmValueSetKind setKind, GmMesh *mesh)
 Helper function to load attribute structure definition.
 
bool loadNodeData (LuaEnv *env, const QVariant &table, GmMesh *mesh)
 Helper function to load per node data (coordinates & attributes)
 
bool loadGhostData (LuaEnv *env, const QVariant &table, GmMesh *mesh)
 Helper function to load per node ghost data (coordinates & attributes)
 
bool loadNodeSets (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 loadPropertySetData (LuaTable &table, GmMesh *mesh)
 Loads property set information into the property set list and checks if all attributes are unique.
 
bool loadGaussAttributesData (LuaTable &table, GmElementMesh *mesh)
 Loads Gauss attribute definitions, filling tha _gaussList table & inserting them on the mesh.
 
bool loadNumCellsByType (LuaTable &table, GmMesh *mesh)
 Loads cell count statistic into the vectors that sumarizes the number of cells per type and number of cells per named group. It also updates the global number of cells.
 
bool loadCellData (LuaTable &table, GmCellMesh *mesh, GmpMeshLoaderCellAllocator cellAllocator)
 
bool loadBoundaryData (LuaTable &table, GmCellMesh *mesh, const char *tableName, GmCellBoundaryType cellType)
 Loads data defining boundary groups.
 
bool loadIntegrationRuleData (LuaTable &table, GmElementMesh *mesh)
 Reads information about integration rules for an element mesh.
 
bool loadFromDump (QString dumpFile, GmMesh *mesh)
 Loads the mesh definition from the given dump file.
 
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.
 
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.
 
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) More...
 
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, multiple tables or by calling the associated Lua function) More...
 
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.
 
QList< GmValueInfo * > _infoList
 Stores attributes && state vars metadata while they where not yet claimed by a ValueSet.
 
QList< GmValueInfo * > _ghostList
 Stores ghost attributes && state vars metadata while they where not yet claimed by a ValueSet.
 
QList< GmValueInfo * > _gaussList
 Stores Gauss attributes metadata while they where not yet claimed by a ValueSet.
 
GmpMeshData< Vector > * _nd
 The node data to be filled.
 
GmpCellMeshData< Vector > * _cd
 The cell data to be filled.
 

Detailed Description

template<template< class > class Vector>
class GmpMeshLoader< Vector >

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' 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.

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; 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 conectivity 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 conectivity, 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. boundaryFaceData: Similar to boundaryEdgeData but storing face values and not edge values. 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.

For an example that contains most of the fields described above, see: gema\tests\regressionTests\bindingTests\basicData.lua

Member Function Documentation

◆ itable()

template<template< class > class Vector>
int GmpMeshLoader< Vector >::itable ( LuaEnv env,
DataIt it 
)
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 integer value is removed from the Lua stack. IMPORTANT2: This function can be called it._size times, no more.

◆ loadMeshData()

template<template< class > class Vector>
bool GmpMeshLoader< Vector >::loadMeshData ( LuaTable table,
GmMesh mesh,
GmpMeshData< Vector > *  nd,
GmpCellMeshData< Vector > *  cd,
GmpMeshLoaderCellAllocator  cellAllocator 
)
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 and n cell allocation function should be provided (cellAllocator can be NULL if the loader should read nodes only), and it must be possible to cast the mesh parameter to a GmCellMesh.

◆ loadMeshDataAux()

template<template< class > class Vector>
bool GmpMeshLoader< Vector >::loadMeshDataAux ( LuaTable table,
GmMesh mesh,
GmpMeshLoaderCellAllocator  cellAllocator 
)
protected

Auxiliar function to loadMeshData().

Makes the error handling easier since cleanup on errors should be done by the caller

◆ ttable()

template<template< class > class Vector>
LuaTable GmpMeshLoader< Vector >::ttable ( LuaEnv env,
DataIt it 
)
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.


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