GemaCoreLib
The GeMA Core library
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 
35 class GmMesh;
36 class GmCell;
38 class GmCellBoundary;
39 class GmNodeSet;
40 class GmValueInfo;
41 class GmValueSet;
42 class GmValueAccessor;
43 class GmSimulationData;
44 class LuaTable;
45 
46 class BcNodeSet;
47 class BcCellBoundary;
48 class BcTaggedPtr;
49 class GmNanBoxedValue;
52 
57 {
58 public:
60  enum BcType
61  {
66  // -- If changes are made to this enum, please remember to adjust
67  // bcTypeToStr() and strToBcType()
68  };
69 
70  virtual ~GmBoundaryConditionBase();
71 
73  QString id() const { return _id; }
74 
76  QString description() const { return _description; }
77 
79  QString type() const { return _type; }
80 
82  GmMesh* mesh() const { return _mesh; }
83 
85  BcType bcType() const { return _bcType; }
86 
88  int numValues() const { return _numValues; }
89 
91  int numProperties() const { return _userPropertiesData.size(); }
92 
93  QStringList propertyIds () const;
94  GmValueInfo* propertyInfo(QString propertyId) const;
95 
96  bool addProperty(GmValueInfo* info, GmSimulationData* data, const GmLogCategory& logger);
97 
98  int numNodes (int bcIndex) const;
99  int node (int bcIndex, int nodeIndex) const;
100  GmCell* cell (int bcIndex) const;
101  int numBoundaryCells (int bcIndex) const;
102  GmCell* boundaryCell (int bcIndex, int cellIndex) const;
103  int boundaryCellBorder(int bcIndex, int cellIndex) const;
104 
105  const GmCellBoundary* boundary(int bcIndex) const;
106  GmCellBoundary* boundary(int bcIndex);
107  const GmNodeSet* nodeSet (int bcIndex) const;
108  GmNodeSet* nodeSet (int bcIndex);
109 
110  void clear();
111 
112  void setNode (int bcIndex, int node);
113  void setNode (int bcIndex, GmCellBoundary* boundary);
114  void setNode (int bcIndex, GmNodeSet* nodeSet);
115  void setNode (int bcIndex, int numNodes, int* nodes);
116  void setCell (int bcIndex, int cell);
117  void setBoundary(int bcIndex, int cell, int border);
118  void setBoundary(int bcIndex, GmCellBoundary* boundary);
119  void setBoundary(int bcIndex, int numCells, int* cells, int* borders);
120 
121  void reloadNodeBoundaryData(int bcIndex);
122 
123  int addLines(int n = 1);
124  void removeLines(int bcIndex, int n = 1);
125 
130  int addNodeLine(int node) { int index = addLines(); if(index >= 0) setNode(index, node); return index; }
131 
137  int addNodeLine(GmCellBoundary* boundary) { int index = addLines(); if(index >= 0) setNode(index, boundary); return index; }
138 
144  int addNodeLine(GmNodeSet* nodeSet) { int index = addLines(); if(index >= 0) setNode(index, nodeSet); return index; }
145 
151  int addNodeLine(int numNodes, int* nodes) { int index = addLines(); if(index >= 0) setNode(index, numNodes, nodes); return index; }
152 
157  int addCellLine(int cell) { int index = addLines(); if(index >= 0) setCell(index, cell); return index; }
158 
164  int addBoundaryLine(int cell, int border) { int index = addLines(); if(index >= 0) setBoundary(index, cell, border); return index; }
165 
170  int addBoundaryLine(GmCellBoundary* boundary) { int index = addLines(); if(index >= 0) setBoundary(index, boundary); return index; }
171 
177  int addBoundaryLine(int numCells, int* cells, int* borders) { int index = addLines(); if(index >= 0) setBoundary(index, numCells, cells, borders); return index; }
178 
179  void print(const GmLogCategory& logger, GmLogLevel level, int summary) const;
180 
181  size_t printMemoryStatistics(const GmLogCategory& logger, GmLogLevel level) const;
182  size_t usedMemory() const;
183 
184  static QString bcTypeToStr(BcType type);
185  static int strToBcType(QString str);
186 
187 private:
188  Q_DISABLE_COPY(GmBoundaryConditionBase);
189 
190 protected:
191  GmBoundaryConditionBase(QString id, QString description, QString type, GmMesh* mesh, BcType bcType);
192 
193  virtual void clearObjects();
194 
195  template <class T>
196  static T* loadFromBaseTable(LuaTable& tab, GmSimulationData* data, const GmLogCategory& logger,
197  QString msgPrefix = "", const QList<GmValueInfo*>& appPointInfoList = QList<GmValueInfo*>());
198 
199  template <class T>
200  static bool loadFromDumpFile(T* bc, QString dumpFile, GmSimulationData* data, const GmLogCategory& logger,
201  QString msgPrefix);
202 
204  virtual QString msgPrefix() const { return ""; }
205 
207  virtual void printExtraHeaderInfo(const GmLogCategory& logger, GmLogLevel level) const { Q_UNUSED(logger); Q_UNUSED(level); }
208 
210  virtual void printExtraPropertyValues(const GmLogCategory& logger, GmLogLevel level) const { Q_UNUSED(logger); Q_UNUSED(level); }
211 
212  size_t appPointUsedMemory() const;
213 
214  GmValueAccessor* userValueAccessor(QString propertyId, Unit desiredUnit, const GmLogCategory& logger) const;
215 
216  QString nodeListStr (int bcIndex, int titleSize, bool align, bool* cropped) const;
217  QString cellBoundaryListStr(int bcIndex, int titleSize, bool* cropped) const;
218 
219  bool mergeLines(LuaTable& tab, int tabSize, const QList<GmValueAccessor*>& acList, int maxLines,
220  const GmLogCategory& logger, QVector<int>& transTable, QVector<int>& countTable);
221 
222  bool parseValueFromVariant(GmValueAccessor* ac, const QVariant& v, GmNanBoxedValue* data, const GmLogCategory& logger);
223 
224  friend class GmBoundaryConditionAccessor;
226  int appPointIndex(int bcIndex, int listIndex) const;
227 
228  // State dumping capabilities delegated to GmBoundaryConditionStateDumpItem in order to
229  // keep GmBoundaryConditionBase simpler
230  friend class GmBoundaryConditionStateDumpItem;
231 
237 
239 
244 
259 };
260 
263 {
264 public:
266  GmBoundaryCondition(QString id, QString description, QString type, GmMesh* mesh,
267  BcType bcType)
268  : GmBoundaryConditionBase(id, description, type, mesh, bcType), _hasTaggedFunctionAccessors(false) {}
269 
270  virtual ~GmBoundaryCondition();
271 
272  GmBoundaryConditionAccessor* propertyAccessor(QString propertyId, Unit desiredUnit, const GmLogCategory& logger) const;
273 
275  bool hasTags() const { return !_taggedProperties.isEmpty(); }
276 
281  bool tagNeedsPerNodeEvaluation() const { return _hasTaggedFunctionAccessors; }
282 
283  quint64 tagMask(int bcIndex, int listIndex) const;
284 
285  static GmBoundaryCondition* loadFromTable(LuaTable& tab, GmSimulationData* data, const GmLogCategory& logger);
286 
287 private:
291 };
292 
293 
298 {
299 public:
302 
304 
305  virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
306 
307  virtual bool fillDumpControlMapData (QVariantMap* map, const GmLogCategory& logger);
308  virtual bool dumpControlMapDataLoaded(QVariantMap* map, const GmLogCategory& logger);
309 
310  virtual bool stateLoaded(GmStateDump* state);
311 
312 private:
314  QVariantMap _controlMap;
319 };
320 
321 
322 
323 #endif
324 
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
QString _id
The boundary condition id (name)
Definition: gmBoundaryCondition.h:232
Aux class used to store a cell boundary created from a user given list of cells/borders.
Definition: gmBoundaryCondition.cpp:190
QString id() const
Returns the boundary condition name.
Definition: gmBoundaryCondition.h:73
The boundary condition will be applied over an edge.
Definition: gmBoundaryCondition.h:63
A base class used to implement the common part between GmBoundaryCondition and GmContactBoundaryCondi...
Definition: gmBoundaryCondition.h:56
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition: gmValueSet.h:53
QMap< QString, int > _userPropertiesMap
Map translating ids from properties into their position in _userPropertiesData.
Definition: gmBoundaryCondition.h:240
BcType bcType() const
Returns the type of bc, defining if the bc should be applied over nodes, edges or faces.
Definition: gmBoundaryCondition.h:85
GmMesh * _mesh
The mesh that this boundary conditions are tied to.
Definition: gmBoundaryCondition.h:235
The GmStateDump class presents a higher level of abstraction over GmMemoryDump, storing accessor data...
Definition: gmStateDump.h:52
An auxiliar class used to host the needed code for duming a boundary condition to a state dump....
Definition: gmBoundaryCondition.h:297
QVariantMap _controlMap
Variant map used for storing the dump control data for the bc object.
Definition: gmBoundaryCondition.h:314
bool _hasTaggedFunctionAccessors
Flag set to true for node BCs with tags that have a ignore clause and function based accessors.
Definition: gmBoundaryCondition.h:290
Declaration of usefull configuration definitions for the Core library.
QString type() const
Returns the boundary condition type, to be interpreted by a physics object.
Definition: gmBoundaryCondition.h:79
int _numValues
The number of boundary conditions stored in this object.
Definition: gmBoundaryCondition.h:238
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:43
Base interface for mesh cells.
Definition: gmCell.h:81
This class stores a set of nodes belonging to a mesh. The nodes can belong to the mesh boundary but t...
Definition: gmNodeSet.h:32
char * _appPointDataPtr
A pointer to the _bc->_appPointData vector data converted to a char*.
Definition: gmBoundaryCondition.h:316
int addCellLine(int cell)
Adds a new boundary condition line to a GM_BC_CELL object, filling the cell information....
Definition: gmBoundaryCondition.h:157
QString _type
The type of this conditions, to be interpreted by a physics object.
Definition: gmBoundaryCondition.h:234
A class used to represent a set of boundary conditions of the same type, tied to the same mesh.
Definition: gmBoundaryCondition.h:262
Declaration of the GmStateDumpBaseDataItem and basic derived classes.
virtual bool addStateItemsToGroup(GmStateDump *state, int groupId)=0
Initialization method, called once, allowing the object to add its state items to the given group of ...
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:207
int addNodeLine(int node)
Adds a new boundary condition line to a GM_BC_NODE object, filling the node information....
Definition: gmBoundaryCondition.h:130
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
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:170
virtual bool stateLoaded(GmStateDump *state)
Virtual method called just after succesfully completing a load operation on the given state....
Definition: gmStateDumpItem.h:85
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
The boundary condition will be applied over a face.
Definition: gmBoundaryCondition.h:64
bool _appPointUserProperties
Set to true if user properties are tied to application points, false otherwise.
Definition: gmBoundaryCondition.h:243
GmBoundaryCondition(QString id, QString description, QString type, GmMesh *mesh, BcType bcType)
Constructor. See parameter description on the GmBoundaryConditionBase constructor documentation.
Definition: gmBoundaryCondition.h:266
The GmBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more conven...
Definition: gmBoundaryConditionAccessor.h:73
int numValues() const
Returns the number of boundary conditions (lines) stored in the object.
Definition: gmBoundaryCondition.h:88
The boundary condition will be applied over a node.
Definition: gmBoundaryCondition.h:62
The boundary condition will be applied over a cell.
Definition: gmBoundaryCondition.h:65
BcType
Boundary condition type defining where a BC is applied (node, edge or face)
Definition: gmBoundaryCondition.h:60
QMap< uintptr_t, QString > _translationMap
Translation map for app point pointers (Uses uintptr_t instead of BcTaggedPtr::Data since that class ...
Definition: gmBoundaryCondition.h:315
QVector< void * > _auxObj
Temporarily stores pointers to either BcNodeSet or BcCellBoundary objects during bc data loading.
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:289
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:177
Class responsible for storing one or more user buffer objects.
Definition: gmStateDumpItem.h:465
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:210
QVector< GmValueSet * > _appPointPropertiesData
List with set of values tied to the application points. Filled only when those are different from _us...
Definition: gmBoundaryCondition.h:242
virtual QString msgPrefix() const
The contents of the %1 argument on the "%1boundary condition" string used on error messages.
Definition: gmBoundaryCondition.h:204
GmMesh * mesh() const
Returns the mesh that this boundary conditions are tied to.
Definition: gmBoundaryCondition.h:82
A wrapper class around QtNanBoxedValue providing specific constructors to store user functions / user...
Definition: gmNanBoxedValue.h:40
Aux class used to store a node set created either from a GmCellBoundary or from a user given node lis...
Definition: gmBoundaryCondition.cpp:78
QVector< GmValueSet * > _userPropertiesData
List with set of values for the user properties.
Definition: gmBoundaryCondition.h:241
void print(const GmMatrix &m, const GmLogCategory &logger, GmLogLevel level, int fieldWidth, char format, int precision)
Prints the matrix using the specified logger, level and precision fields.
Definition: gmMatrixUtils.cpp:34
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:164
bool hasTags() const
Returns true if any of the B.c. properties has a tag.
Definition: gmBoundaryCondition.h:275
QString description() const
Returns the boundary condition description.
Definition: gmBoundaryCondition.h:76
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
QString _description
A description of the boundary conditions.
Definition: gmBoundaryCondition.h:233
GmStateDumpBufferDataItem * _auxObjDumpItem
The dump item used to save BcNodeSet / BcCellBoundary data.
Definition: gmBoundaryCondition.h:317
The GmContactBoundaryConditionAccessor class is a proxy object to a value accesor implementing a more...
Definition: gmContactBoundaryConditionAccessor.h:34
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
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:144
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:151
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
A wrapper class around QtTaggedPtr providing specific constructors to the type of Gema pointers that ...
Definition: gmBoundaryCondition.cpp:281
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:137
bool tagNeedsPerNodeEvaluation() const
Returns true, for node BCs only, when the tag set includes properties with either ignoreDef or ignore...
Definition: gmBoundaryCondition.h:281
BcType _bcType
The type of bc. Defines if the bc should be applied over nodes, edges or faces.
Definition: gmBoundaryCondition.h:236
QVarLengthArray< BcTaggedPtr, 1 > * _appPointData
A vector with size _numValues storing the boundary condition application points.
Definition: gmBoundaryCondition.h:258
A basic interface used for creating dump items for objects that can be dumped by a composition of mul...
Definition: gmStateDumpItem.h:52
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
int numProperties() const
Returns the number of properties (columns) stored for each condition in the object.
Definition: gmBoundaryCondition.h:91
QVector< int > _taggedProperties
The index in the value set list of the set of properties with tags.
Definition: gmBoundaryCondition.h:288
GmBoundaryCondition * _bc
The boundary condition.
Definition: gmBoundaryCondition.h:313
Declaration of support functions and macros for information logging.