GemaCoreLib
The GeMA Core library
gmCell.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_CELL_H_
25 #define _GEMA_CELL_H_
26 
27 
28 #include "gmCellGeometry.h"
29 
30 class GmValueAccessor;
31 class GmIntegrationRule;
32 
33 class GmCellMesh;
34 struct lua_State;
35 
36 
39 {
44 };
45 
48 {
52 };
53 
54 
82 {
83 public:
84 
86  virtual ~GmCell() {}
87 
92  virtual int cellId() const = 0;
93 
95  virtual GmCellMesh* mesh() const = 0;
96 
101  virtual bool active() const = 0;
102 
111  virtual void pushProxy(lua_State* L, const GmLogCategory& logger) = 0;
112 
114  virtual GmCellType type() const = 0;
115 
117  const char* typeStr() const { return typeToStr(type()); }
118 
120  virtual GmCellGeometry geometry() const { return GmCellGeometry(type()); }
121 
123  virtual int numNodes() const = 0;
124 
126  virtual int numGhostNodes() const { return 0; }
127 
129  virtual int totalNumNodes() const { return numNodes() + numGhostNodes(); }
130 
148  virtual int nodeIndex(int localIndex) const = 0;
149 
156  virtual void nodes(int* nodeList, bool ghost) const = 0;
157 
168  virtual int propertyIndex(int propertySet) const = 0;
169 
173  virtual void setActive(bool active) = 0;
174 
183  virtual bool setNodes(const int* nodeList)
184  {
185  Q_UNUSED(nodeList);
186  return false;
187  }
188 
203  virtual int addGhostNode(int globalIndex)
204  {
205  Q_UNUSED(globalIndex);
206  return -1;
207  }
208 
217  virtual void removeGhostNode(int localIndex)
218  {
219  Q_UNUSED(localIndex);
220  }
221 
232  virtual bool setProperties(const int* propList, int nprop)
233  {
234  Q_UNUSED(propList); Q_UNUSED(nprop);
235  return false;
236  }
237 
238  GmCell* adjacentCell(int sideIndex, int* adjSideIndex = NULL) const;
239 
240  double length(const GmValueAccessor* coordAccessor, int edgeIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
241  double length(const GmMatrix& X, int edgeIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
242 
243  double area(const GmValueAccessor* coordAccessor, int faceIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
244  double area(const GmMatrix& X, int faceIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
245 
246  double volume(const GmValueAccessor* coordAccessor, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
247  double volume(const GmMatrix& X, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
248 
249  double characteristicLength(const GmValueAccessor* coordAccessor, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
250  double characteristicLength(const GmMatrix& X, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
251 
252  double characteristicDimension(const GmValueAccessor* coordAccessor, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
253  double characteristicDimension(const GmMatrix& X, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
254 
255  void centroidCartesian(const GmValueAccessor* coordAccessor, GmVector& coord, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
256  void centroidCartesian(const GmMatrix& X, GmVector& coord, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
257 
262  virtual bool isValid(const GmValueAccessor* nodeAccessor, double tol = 1e-5) const;
263 
268  virtual double quality(const GmValueAccessor* nodeAccessor, double tol = 1e-5) const;
269 
274  virtual bool contains(const GmValueAccessor* nodeAccessor, const GmVector& coord) const
275  {
276  GmMatrix X; fillNodeMatrix(nodeAccessor, X, true);
277  return geometry().contains(X, coord);
278  }
279 
280  // There once was a "projected" method that, given a coordinate of a point outside the
281  // cell, should return the coordinate of that point projected on the cell, together with
282  // their distances. Since that method was not used and was never really validated, it was
283  // removed from the cell API. The basic (unvalidated) method implementation core still
284  // remains in the GmGometryUtils namespace though.
285 
286  void fillNodeMatrix (const GmValueAccessor* nodeAccessor, GmMatrix& m, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
287  void fillFaceNodeMatrix(const GmValueAccessor* nodeAccessor, GmMatrix& m, int faceIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
288  void fillEdgeNodeMatrix(const GmValueAccessor* nodeAccessor, GmMatrix& m, int edgeIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
289 
290  void fillDeformedNodeMatrix (const GmValueAccessor* nodeAccessor, const GmValueAccessor* uAccessor, GmMatrix& m, GmVector& u, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
291  void fillDeformedFaceNodeMatrix(const GmValueAccessor* nodeAccessor, const GmValueAccessor* uAccessor, GmMatrix& m, GmVector& u, int faceIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
292  void fillDeformedEdgeNodeMatrix(const GmValueAccessor* nodeAccessor, const GmValueAccessor* uAccessor, GmMatrix& m, GmVector& u, int edgeIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
293 
294  static int typeToNumNodes(GmCellType type);
295  static const char* typeToStr(GmCellType type);
296  static int strToType(QString str);
297 
298 
299  //-------------------------------------------------------------------
300  // State dump helper functions. The following functions are added
301  // to help the implementation of mesh state dumping based on the
302  // standard mesh plugin. They really don't belong here, but can't be
303  // easily added to GmpCellBase (from the GemaMesh plugin) due to its
304  // template nature and the need for them to be called from a GmCell*
305  // pointer (or any other non templated class). An alternative would
306  // be to collect them in an auxiliary class and make GmpCellBase
307  // to also inherit from that class. That works, but using multiple
308  // inheritance would add another virtual table pointer to the cell
309  // object, increasing its size.
310  //-------------------------------------------------------------------
311 
313  virtual int meshId() const = 0;
314 
324  virtual void replaceCellId(int id, bool keepActiveFlag) { Q_UNUSED(id); Q_UNUSED(keepActiveFlag); }
325 
337  virtual void replaceGhostNodes(int* ghostNodes, int numNodes) { Q_UNUSED(ghostNodes); Q_UNUSED(numNodes); }
338 };
339 
340 
341 #endif
342 
virtual int numGhostNodes() const
Returns the number of ghost nodes of this cell, if any.
Definition: gmCell.h:126
virtual void replaceCellId(int id, bool keepActiveFlag)
Updates the cell id. For those who really know what they are doing. This function is a very specific ...
Definition: gmCell.h:324
The cell geometry is linear, independently of the element type.
Definition: gmCell.h:51
virtual int totalNumNodes() const
Returns the total number of nodes of the cell, including normal nodes & ghost nodes.
Definition: gmCell.h:129
virtual int addGhostNode(int globalIndex)
Adds a new ghost node to the cell, returning the new node local index or -1 if there was a problem ad...
Definition: gmCell.h:203
The coordinate matrix will be filled with cell geometry and ghost nodes.
Definition: gmCell.h:43
Base interface for mesh cells.
Definition: gmCell.h:81
The coordinate matrix will be filled with cell geometry nodes only (the default, and includes extra d...
Definition: gmCell.h:40
virtual bool contains(const GmValueAccessor *nodeAccessor, const GmVector &coord) const
Returns true if the cell contains the point specified by the given cartesian coordinates 'coord'....
Definition: gmCell.h:274
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
A class used to return static metadata information about a cell geometry, along with some methods for...
Definition: gmCellGeometry.h:54
GmCellFillMode
Operation modes for the fillNodeMatrix() method.
Definition: gmCell.h:38
Integration rule base classe.
Definition: gmIntegrationRule.h:88
The operation mode is defined by a mesh property defining whether cell geometry is linear or not,...
Definition: gmCell.h:49
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
The coordinate matrix will be filled with cell ghost nodes only.
Definition: gmCell.h:42
virtual GmCellGeometry geometry() const
Returns an object that contains detailed cell geometry information.
Definition: gmCell.h:120
#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
virtual ~GmCell()
Virtual destructor.
Definition: gmCell.h:86
virtual bool setProperties(const int *propList, int nprop)
Function allowing editable meshes to set the property indices of newlly created cells.
Definition: gmCell.h:232
The cell geometry is definied by the element type.
Definition: gmCell.h:50
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition: gmCellType.h:30
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
The coordinate matrix will be filled with cell vertex nodes + extra dof nodes only (linear corner nod...
Definition: gmCell.h:41
GmCellGeometryMode
Operation modes for geometry related functions like length(), area(), volume(), etc.
Definition: gmCell.h:47
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
Declaration of the GmCellGeometry base class.
const char * typeStr() const
Returns a name describing the cell type.
Definition: gmCell.h:117
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
virtual void removeGhostNode(int localIndex)
Removes a ghost node from the cell definition given its local index.
Definition: gmCell.h:217
virtual void replaceGhostNodes(int *ghostNodes, int numNodes)
Replaces the full set of ghost nodes of the cell. This function is a very specific function that shou...
Definition: gmCell.h:337
virtual bool setNodes(const int *nodeList)
Function allowing editable meshes to set the node list of newlly created cells.
Definition: gmCell.h:183