GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmBoundaryCondition.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_BOUNDARY_CONDITION_H_
25#define _GEMA_BOUNDARY_CONDITION_H_
26
27#include "gmCoreConfig.h"
28#include "gmLog.h"
29#include "gmStateDumpItem.h"
30
31#include <QString>
32#include <unit.h>
33#include <assert.h>
34
35class GmMesh;
36class GmCell;
38class GmCellBoundary;
39class GmNodeSet;
40class GmValueInfo;
41class GmValueSet;
42class GmValueAccessor;
44class LuaTable;
45
46class BcNodeSet;
47class BcCellBoundary;
48class BcTaggedPtr;
49class GmNanBoxedValue;
53
58{
59public:
61 enum BcType
62 {
67 // -- If changes are made to this enum, please remember to adjust
68 // bcTypeToStr() and strToBcType()
69 };
70
72
74 QString id() const { return _id; }
75
77 QString description() const { return _description; }
78
80 QString type() const { return _type; }
81
83 GmMesh* mesh() const { return _mesh; }
84
86 BcType bcType() const { return _bcType; }
87
89 int numValues() const { return _numValues; }
90
92 int numProperties() const { return _userPropertiesData.size(); }
93
94 QStringList propertyIds () const;
95 GmValueInfo* propertyInfo(QString propertyId) const;
96
97 bool addProperty(GmValueInfo* info, GmSimulationData* data, const GmLogCategory& logger);
98
99 int numNodes (int bcIndex) const;
100 int node (int bcIndex, int nodeIndex) const;
101 GmCell* cell (int bcIndex) const;
102 int numBoundaryCells (int bcIndex) const;
103 GmCell* boundaryCell (int bcIndex, int cellIndex) const;
104 int boundaryCellBorder(int bcIndex, int cellIndex) const;
105
106 const GmCellBoundary* boundary(int bcIndex) const;
107 GmCellBoundary* boundary(int bcIndex);
108 const GmNodeSet* nodeSet (int bcIndex) const;
109 GmNodeSet* nodeSet (int bcIndex);
110
111 void clear();
112
113 void setNode (int bcIndex, int node);
114 void setNode (int bcIndex, GmCellBoundary* boundary);
115 void setNode (int bcIndex, GmNodeSet* nodeSet);
116 void setNode (int bcIndex, int numNodes, int* nodes);
117 void setCell (int bcIndex, int cell);
118 void setBoundary(int bcIndex, int cell, int border);
119 void setBoundary(int bcIndex, GmCellBoundary* boundary);
120 void setBoundary(int bcIndex, int numCells, int* cells, int* borders);
121
122 void reloadNodeBoundaryData(int bcIndex);
123
124 int addLines(int n = 1);
125 void removeLines(int bcIndex, int n = 1);
126
131 int addNodeLine(int node) { int index = addLines(); if(index >= 0) setNode(index, node); return index; }
132
138 int addNodeLine(GmCellBoundary* boundary) { int index = addLines(); if(index >= 0) setNode(index, boundary); return index; }
139
145 int addNodeLine(GmNodeSet* nodeSet) { int index = addLines(); if(index >= 0) setNode(index, nodeSet); return index; }
146
152 int addNodeLine(int numNodes, int* nodes) { int index = addLines(); if(index >= 0) setNode(index, numNodes, nodes); return index; }
153
158 int addCellLine(int cell) { int index = addLines(); if(index >= 0) setCell(index, cell); return index; }
159
165 int addBoundaryLine(int cell, int border) { int index = addLines(); if(index >= 0) setBoundary(index, cell, border); return index; }
166
171 int addBoundaryLine(GmCellBoundary* boundary) { int index = addLines(); if(index >= 0) setBoundary(index, boundary); return index; }
172
178 int addBoundaryLine(int numCells, int* cells, int* borders) { int index = addLines(); if(index >= 0) setBoundary(index, numCells, cells, borders); return index; }
179
180 void print(const GmLogCategory& logger, GmLogLevel level, int summary) const;
181
182 size_t printMemoryStatistics(const GmLogCategory& logger, GmLogLevel level) const;
183 size_t usedMemory() const;
184
185 static QString bcTypeToStr(BcType type);
186 static int strToBcType(QString str);
187
188private:
189 Q_DISABLE_COPY(GmBoundaryConditionBase);
190
191protected:
192 GmBoundaryConditionBase(QString id, QString description, QString type, GmMesh* mesh, BcType bcType);
193
194 virtual void clearObjects();
195 void clearIndex(int bcIndex);
196
197 template <class T>
198 static T* loadStructureFromBaseTable(LuaTable& tab, GmSimulationData* data, int dataType, const GmLogCategory& logger,
199 int* merge, QString& dataTabName, QList<GmValueAccessor*>& acList,
200 QString msgPrefix = "", const QList<GmValueInfo*>& appPointInfoList = QList<GmValueInfo*>());
201
202 template <class T>
203 static T* loadFromBaseTable(LuaTable& tab, GmSimulationData* data, const GmLogCategory& logger,
204 QString msgPrefix = "", const QList<GmValueInfo*>& appPointInfoList = QList<GmValueInfo*>());
205
206 template <class T>
207 static T* loadFromHdf5File(LuaTable& tab, GmSimulationData* data, GmHdf5ModelReader* hdf5Reader, const GmLogCategory& logger,
208 QString msgPrefix = "", const QList<GmValueInfo*>& appPointInfoList = QList<GmValueInfo*>());
209
210 template <class T>
211 static T* loadFromDumpFile(LuaTable& tab, GmSimulationData* data, QString dumpFile, const GmLogCategory& logger,
212 QString msgPrefix = "", const QList<GmValueInfo*>& appPointInfoList = QList<GmValueInfo*>());
213
215 virtual QString msgPrefix() const { return ""; }
216
218 virtual void printExtraHeaderInfo(const GmLogCategory& logger, GmLogLevel level) const { Q_UNUSED(logger); Q_UNUSED(level); }
219
221 virtual void printExtraPropertyValues(const GmLogCategory& logger, GmLogLevel level) const { Q_UNUSED(logger); Q_UNUSED(level); }
222
223 size_t appPointUsedMemory() const;
224
225 GmValueAccessor* userValueAccessor(QString propertyId, Unit desiredUnit, const GmLogCategory& logger) const;
226
227 QString nodeListStr (int bcIndex, int titleSize, bool align, bool* cropped) const;
228 QString cellBoundaryListStr(int bcIndex, int titleSize, bool* cropped) const;
229
230 bool mergeLines(LuaTable& tab, int tabSize, const QList<GmValueAccessor*>& acList, int maxLines,
231 const GmLogCategory& logger, QVector<int>& transTable, QVector<int>& countTable);
232
233 bool parseValueFromVariant(GmValueAccessor* ac, const QVariant& v, GmNanBoxedValue* data, const GmLogCategory& logger);
234
235 friend class GmBoundaryConditionAccessor;
237 int appPointIndex(int bcIndex, int listIndex) const;
238
239 // The following functions allow for the model writer object to have access to internal node and
240 // boundary sets created when MERGING BC lines. Those are needed by the model writer but are not
241 // general purpose methods, exposing an internal implementation detail.
242 friend class GmHdf5ModelWriter;
243 const QVector<const GmNodeSet*>& mergedNodeSets() const { return _mergedNodeSets; }
244 const QVector<const GmCellBoundary*>& mergedBoundaries() const { return _mergedBoundaries; }
245
246 const GmNodeSet* mergedNodeSet (int bcIndex) const;
247 const GmCellBoundary* mergedBoundary(int bcIndex) const;
248
249 // State dumping capabilities delegated to GmBoundaryConditionStateDumpItem in order to
250 // keep GmBoundaryConditionBase simpler
252
258
260
265
268
283};
284
287{
288public:
290 GmBoundaryCondition(QString id, QString description, QString type, GmMesh* mesh,
291 BcType bcType)
292 : GmBoundaryConditionBase(id, description, type, mesh, bcType), _hasTaggedFunctionAccessors(false) {}
293
294 virtual ~GmBoundaryCondition();
295
296 GmBoundaryConditionAccessor* propertyAccessor(QString propertyId, Unit desiredUnit, const GmLogCategory& logger) const;
297
299 bool hasTags() const { return !_taggedProperties.isEmpty(); }
300
305 bool tagNeedsPerNodeEvaluation() const { return _hasTaggedFunctionAccessors; }
306
307 quint64 tagMask(int bcIndex, int listIndex) const;
308
309 static GmBoundaryCondition* loadFromTable(LuaTable& tab, GmSimulationData* data, const GmLogCategory& logger);
310 static GmBoundaryCondition* loadFromTableAndHdf5File(LuaTable& tab, GmSimulationData* data, GmHdf5ModelReader* hdf5Reader, const GmLogCategory& logger);
311 static GmBoundaryCondition* loadFromTableAndDumpFile(LuaTable& tab, GmSimulationData* data, QString dumpFile, const GmLogCategory& logger);
312
313private:
314 static void adjustTagInfo(GmBoundaryCondition* bc, const GmLogCategory& logger);
315
319};
320
321
326{
327public:
330
332
333 virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
334
335 virtual bool fillDumpControlMapData (QVariantMap* map, const GmLogCategory& logger);
336 virtual bool dumpControlMapDataLoaded(QVariantMap* map, const GmLogCategory& logger);
337
338 virtual bool stateLoaded(GmStateDump* state);
339
340private:
342 QVariantMap _controlMap;
347};
348
349
350
351#endif
352
Aux class used to store a cell boundary created from a user given list of cells/borders.
Definition gmBoundaryCondition.cpp:200
Aux class used to store a node set created either from a GmCellBoundary or from a user given node lis...
Definition gmBoundaryCondition.cpp:82
A wrapper class around QtTaggedPtr providing specific constructors to the type of Gema pointers that ...
Definition gmBoundaryCondition.cpp:297
The GmBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more conven...
Definition gmBoundaryConditionAccessor.h:74
A base class used to implement the common part between GmBoundaryCondition and GmContactBoundaryCondi...
Definition gmBoundaryCondition.h:58
QVector< GmValueSet * > _appPointPropertiesData
List with set of values tied to the application points. Filled only when those are different from _us...
Definition gmBoundaryCondition.h:263
int addNodeLine(int numNodes, int *nodes)
Adds a new boundary condition line to a GM_BC_NODE object, filling the node information from the give...
Definition gmBoundaryCondition.h:152
int addBoundaryLine(int cell, int border)
Adds a new boundary condition line to a GM_BC_EDGE/GM_BC_FACE object, filling the boundary informatio...
Definition gmBoundaryCondition.h:165
QString _id
The boundary condition id (name)
Definition gmBoundaryCondition.h:253
bool _appPointUserProperties
Set to true if user properties are tied to application points, false otherwise
Definition gmBoundaryCondition.h:264
QVarLengthArray< BcTaggedPtr, 1 > * _appPointData
A vector with size _numValues storing the boundary condition application points.
Definition gmBoundaryCondition.h:282
int addNodeLine(GmCellBoundary *boundary)
Adds a new boundary condition line to a GM_BC_NODE object, filling the node information from a bounda...
Definition gmBoundaryCondition.h:138
QString _type
The type of this conditions, to be interpreted by a physics object.
Definition gmBoundaryCondition.h:255
QString _description
A description of the boundary conditions.
Definition gmBoundaryCondition.h:254
GmMesh * mesh() const
Returns the mesh that this boundary conditions are tied to.
Definition gmBoundaryCondition.h:83
QMap< QString, int > _userPropertiesMap
Map translating ids from properties into their position in _userPropertiesData.
Definition gmBoundaryCondition.h:261
BcType _bcType
The type of bc. Defines if the bc should be applied over nodes, edges or faces.
Definition gmBoundaryCondition.h:257
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 informatio...
Definition gmBoundaryCondition.h:178
int numProperties() const
Returns the number of properties (columns) stored for each condition in the object.
Definition gmBoundaryCondition.h:92
virtual QString msgPrefix() const
The contents of the %1 argument on the "%1boundary condition" string used on error messages.
Definition gmBoundaryCondition.h:215
QString type() const
Returns the boundary condition type, to be interpreted by a physics object.
Definition gmBoundaryCondition.h:80
virtual void printExtraHeaderInfo(const GmLogCategory &logger, GmLogLevel level) const
Aux function to print(), giving a chance for derived classes to add additional header data.
Definition gmBoundaryCondition.h:218
BcType
Boundary condition type defining where a BC is applied (node, edge or face)
Definition gmBoundaryCondition.h:62
@ GM_BC_NODE
The boundary condition will be applied over a node.
Definition gmBoundaryCondition.h:63
@ GM_BC_CELL
The boundary condition will be applied over a cell.
Definition gmBoundaryCondition.h:66
@ GM_BC_EDGE
The boundary condition will be applied over an edge.
Definition gmBoundaryCondition.h:64
@ GM_BC_FACE
The boundary condition will be applied over a face.
Definition gmBoundaryCondition.h:65
QVector< GmValueSet * > _userPropertiesData
List with set of values for the user properties.
Definition gmBoundaryCondition.h:262
int addCellLine(int cell)
Adds a new boundary condition line to a GM_BC_CELL object, filling the cell information....
Definition gmBoundaryCondition.h:158
int addNodeLine(GmNodeSet *nodeSet)
Adds a new boundary condition line to a GM_BC_NODE object, filling the node information from a node s...
Definition gmBoundaryCondition.h:145
int _numValues
The number of boundary conditions stored in this object.
Definition gmBoundaryCondition.h:259
BcType bcType() const
Returns the type of bc, defining if the bc should be applied over nodes, edges or faces.
Definition gmBoundaryCondition.h:86
QString description() const
Returns the boundary condition description.
Definition gmBoundaryCondition.h:77
int addNodeLine(int node)
Adds a new boundary condition line to a GM_BC_NODE object, filling the node information....
Definition gmBoundaryCondition.h:131
QString id() const
Returns the boundary condition name.
Definition gmBoundaryCondition.h:74
int addBoundaryLine(GmCellBoundary *boundary)
Adds a new boundary condition line to a GM_BC_EDGE/GM_BC_FACE object, filling the boundary informatio...
Definition gmBoundaryCondition.h:171
QVector< const GmCellBoundary * > _mergedBoundaries
A list with internal boundary objects created by the MERGE process.
Definition gmBoundaryCondition.h:267
int numValues() const
Returns the number of boundary conditions (lines) stored in the object.
Definition gmBoundaryCondition.h:89
GmMesh * _mesh
The mesh that this boundary conditions are tied to.
Definition gmBoundaryCondition.h:256
virtual void printExtraPropertyValues(const GmLogCategory &logger, GmLogLevel level) const
Aux function to print(), giving a chance for derived classes to add property values when _appPointUse...
Definition gmBoundaryCondition.h:221
QVector< const GmNodeSet * > _mergedNodeSets
A list with internal node set objects created by the MERGE process. Does NOT include node sets create...
Definition gmBoundaryCondition.h:266
A class used to represent a set of boundary conditions of the same type, tied to the same mesh.
Definition gmBoundaryCondition.h:287
bool _hasTaggedFunctionAccessors
Flag set to true for node BCs with tags that have a ignore clause and function based accessors.
Definition gmBoundaryCondition.h:318
QVector< GmBoundaryConditionAccessor * > _taggedAccessors
Accessors for tagged properties. Not NULL only for NODE BCs where the tag ignores default or zero val...
Definition gmBoundaryCondition.h:317
QVector< int > _taggedProperties
The index in the value set list of the set of properties with tags.
Definition gmBoundaryCondition.h:316
GmBoundaryCondition(QString id, QString description, QString type, GmMesh *mesh, BcType bcType)
Constructor. See parameter description on the GmBoundaryConditionBase constructor documentation.
Definition gmBoundaryCondition.h:290
bool hasTags() const
Returns true if any of the B.c. properties has a tag.
Definition gmBoundaryCondition.h:299
bool tagNeedsPerNodeEvaluation() const
Returns true, for node BCs only, when the tag set includes properties with either ignoreDef or ignore...
Definition gmBoundaryCondition.h:305
An auxiliar class used to host the needed code for duming a boundary condition to a state dump....
Definition gmBoundaryCondition.h:326
QVariantMap _controlMap
Variant map used for storing the dump control data for the bc object.
Definition gmBoundaryCondition.h:342
GmBoundaryCondition * _bc
The boundary condition.
Definition gmBoundaryCondition.h:341
QVector< void * > _auxObj
Temporarily stores pointers to either BcNodeSet or BcCellBoundary objects during bc data loading.
Definition gmBoundaryCondition.h:346
char * _appPointDataPtr
A pointer to the _bc->_appPointData vector data converted to a char*.
Definition gmBoundaryCondition.h:344
QMap< uintptr_t, QString > _translationMap
Translation map for app point pointers (Uses uintptr_t instead of BcTaggedPtr::Data since that class ...
Definition gmBoundaryCondition.h:343
GmStateDumpBufferDataItem * _auxObjDumpItem
The dump item used to save BcNodeSet / BcCellBoundary data.
Definition gmBoundaryCondition.h:345
This class stores a set of cell edges or cell faces that together form a piece of the boundary of a m...
Definition gmCellBoundary.h:44
Base interface for mesh cells.
Definition gmCell.h:88
The GmContactBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more...
Definition gmContactBoundaryConditionAccessor.h:35
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition gmStateDumpItem.h:53
A helper class used to parse and retrieve data from am hdf5 model file. Used by the mesh plugin to re...
Definition gmHdf5ModelReader.h:53
A class used to export parts of a GeMA model to an HDF5 file. Its API includes both GeMA centric func...
Definition gmHdf5ModelWriter.h:58
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for Mesh type plugins.
Definition gmMesh.h:48
A wrapper class around QtNanBoxedValue providing specific constructors to store user functions / user...
Definition gmNanBoxedValue.h:41
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition gmNodeSet.h:34
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
Class responsible for storing one or more user buffer objects.
Definition gmStateDumpItem.h:492
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition gmStateDump.h:54
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition gmValueSet.h:54
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of support functions and macros for information logging.
GmLogLevel
Available log levels list.
Definition gmLog.h:36
Declaration of the GmStateDumpBaseDataItem and basic derived classes.