GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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
30class GmValueAccessor;
32
33class GmCellMesh;
34struct lua_State;
35
36
45
53
54
88{
89public:
90
92 virtual ~GmCell() {}
93
98 virtual int cellId() const = 0;
99
101 virtual GmCellMesh* mesh() const = 0;
102
107 virtual bool active() const = 0;
108
117 virtual void pushProxy(lua_State* L, const GmLogCategory& logger) = 0;
118
120 virtual GmCellType type() const = 0;
121
123 const char* typeStr() const { return typeToStr(type()); }
124
126 virtual GmCellGeometry geometry() const { return GmCellGeometry(type()); }
127
129 virtual int numNodes() const = 0;
130
132 virtual int numGhostNodes() const { return 0; }
133
135 virtual int totalNumNodes() const { return numNodes() + numGhostNodes(); }
136
154 virtual int nodeIndex(int localIndex) const = 0;
155
162 virtual void nodes(int* nodeList, bool ghost) const = 0;
163
174 virtual int propertyIndex(int propertySet) const = 0;
175
179 virtual void setActive(bool active) = 0;
180
189 virtual bool setNodes(const int* nodeList)
190 {
191 Q_UNUSED(nodeList);
192 return false;
193 }
194
209 virtual int addGhostNode(int globalIndex)
210 {
211 Q_UNUSED(globalIndex);
212 return -1;
213 }
214
219 virtual void setGhostNodes(int* ghostNodes, int numNodes) { Q_UNUSED(ghostNodes); Q_UNUSED(numNodes); }
220
229 virtual void removeGhostNode(int localIndex)
230 {
231 Q_UNUSED(localIndex);
232 }
233
244 virtual bool setProperties(const int* propList, int nprop)
245 {
246 Q_UNUSED(propList); Q_UNUSED(nprop);
247 return false;
248 }
249
250 GmCell* adjacentCell(int sideIndex, int* adjSideIndex = NULL) const;
251
252 double length(const GmValueAccessor* coordAccessor, int edgeIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
253 double length(const GmMatrix& X, int edgeIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
254
255 double area(const GmValueAccessor* coordAccessor, int faceIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
256 double area(const GmMatrix& X, int faceIndex = 0, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
257
258 double volume(const GmValueAccessor* coordAccessor, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
259 double volume(const GmMatrix& X, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
260
261 double characteristicLength(const GmValueAccessor* coordAccessor, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
262 double characteristicLength(const GmMatrix& X, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
263
264 double characteristicDimension(const GmValueAccessor* coordAccessor, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
265 double characteristicDimension(const GmMatrix& X, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
266
267 void centroidCartesian(const GmValueAccessor* coordAccessor, GmVector& coord, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
268 void centroidCartesian(const GmMatrix& X, GmVector& coord, GmCellGeometryMode linearMode = GM_CELLGEOM_AUTO) const;
269
274 virtual int isValid(const GmValueAccessor* nodeAccessor, double tol = 1e-5) const;
275
280 virtual double quality(const GmValueAccessor* nodeAccessor, double tol = 1e-5) const;
281
286 virtual bool contains(const GmValueAccessor* nodeAccessor, const GmVector& coord) const
287 {
288 GmMatrix X; fillNodeMatrix(nodeAccessor, X, true);
289 return geometry().contains(X, coord);
290 }
291
292 // There once was a "projected" method that, given a coordinate of a point outside the
293 // cell, should return the coordinate of that point projected on the cell, together with
294 // their distances. Since that method was not used and was never really validated, it was
295 // removed from the cell API. The basic (unvalidated) method implementation core still
296 // remains in the GmGeometryUtils namespace though.
297
298 void fillNodeMatrix (const GmValueAccessor* nodeAccessor, GmMatrix& m, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
299 void fillFaceNodeMatrix(const GmValueAccessor* nodeAccessor, GmMatrix& m, int faceIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES, bool mesh = false) const;
300 void fillEdgeNodeMatrix(const GmValueAccessor* nodeAccessor, GmMatrix& m, int edgeIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES, bool mesh = false) const;
301
302 void fillDeformedNodeMatrix (const GmValueAccessor* nodeAccessor, const GmValueAccessor* uAccessor, GmMatrix& m, GmVector& u, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES) const;
303 void fillDeformedFaceNodeMatrix(const GmValueAccessor* nodeAccessor, const GmValueAccessor* uAccessor, GmMatrix& m, GmVector& u, int faceIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES, bool mesh = false) const;
304 void fillDeformedEdgeNodeMatrix(const GmValueAccessor* nodeAccessor, const GmValueAccessor* uAccessor, GmMatrix& m, GmVector& u, int edgeIndex, bool transposed = false, GmCellFillMode mode = GM_CELL_NODES, bool mesh = false) const;
305
306 static int typeToNumNodes(GmCellType type);
307 static const char* typeToStr(GmCellType type);
308 static int strToType(QString str);
309};
310
311
312#endif
313
A class used to return static metadata information about a cell geometry, along with some methods for...
Definition gmCellGeometry.h:55
Base interface for mesh cells.
Definition gmCell.h:88
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:209
virtual int propertyIndex(int propertySet) const =0
Given a property set number, returns the line of the property set that contains property values for t...
virtual bool active() const =0
Is this cell active ? When looping over the cell list, this function should be probably called to ens...
virtual ~GmCell()
Virtual destructor.
Definition gmCell.h:92
virtual void setActive(bool active)=0
Marks the cell as active or inactive. Inactive cells are not processed by several of the algorithms,...
virtual void setGhostNodes(int *ghostNodes, int numNodes)
Replaces the full set of ghost nodes of the cell. The indices in the list should be values from 0 to ...
Definition gmCell.h:219
virtual void pushProxy(lua_State *L, const GmLogCategory &logger)=0
Pushes a proxy object for the current cell onto the Lua stack.
virtual int numNodes() const =0
Returns the number of nodes of this cell. Equivalent to typeToNumNodes(type()) but usually much more ...
virtual void nodes(int *nodeList, bool ghost) const =0
Fills the vector nodeList with the set of cell nodes, including or not eventual ghost nodes depending...
virtual void removeGhostNode(int localIndex)
Removes a ghost node from the cell definition given its local index.
Definition gmCell.h:229
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:286
virtual bool setNodes(const int *nodeList)
Function allowing editable meshes to set the node list of newly created cells.
Definition gmCell.h:189
virtual int numGhostNodes() const
Returns the number of ghost nodes of this cell, if any.
Definition gmCell.h:132
virtual GmCellMesh * mesh() const =0
Returns the "father" mesh for this cell.
virtual GmCellType type() const =0
Returns the cell type.
virtual int cellId() const =0
Returns a number identifying the cell. It should be possible to use this id as an index to GmCellMesh...
virtual bool setProperties(const int *propList, int nprop)
Function allowing editable meshes to set the property indices of newly created cells.
Definition gmCell.h:244
virtual int nodeIndex(int localIndex) const =0
Returns the global node index used to locate node coordinates for each of the cell nodes.
virtual GmCellGeometry geometry() const
Returns an object that contains detailed cell geometry information.
Definition gmCell.h:126
const char * typeStr() const
Returns a name describing the cell type.
Definition gmCell.h:123
virtual int totalNumNodes() const
Returns the total number of nodes of the cell, including normal nodes & ghost nodes.
Definition gmCell.h:135
Base interface class for CellMesh type plugins.
Definition gmCellMesh.h:40
Integration rule base classe.
Definition gmIntegrationRule.h:89
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Interface class for accessing and setting values from an "indexable" collection of values.
Definition gmValueAccessor.h:60
GmCellGeometryMode
Operation modes for geometry related functions like length(), area(), volume(), etc.
Definition gmCell.h:48
@ GM_CELLGEOM_AUTO
The operation mode is defined by a mesh property defining whether cell geometry is linear or not,...
Definition gmCell.h:49
@ GM_CELLGEOM_LINEAR
The cell geometry is linear, independently of the element type.
Definition gmCell.h:51
@ GM_CELLGEOM_ELEM
The cell geometry is defined by the element type.
Definition gmCell.h:50
GmCellFillMode
Operation modes for the fillNodeMatrix() method.
Definition gmCell.h:39
@ GM_CELL_NODES
The coordinate matrix will be filled with cell geometry nodes only (the default, and includes extra d...
Definition gmCell.h:40
@ GM_CELL_VERTICES
The coordinate matrix will be filled with cell vertex nodes + extra dof nodes only (linear corner nod...
Definition gmCell.h:41
@ GM_CELL_ALL
The coordinate matrix will be filled with cell geometry and ghost nodes.
Definition gmCell.h:43
@ GM_CELL_GHOST
The coordinate matrix will be filled with cell ghost nodes only.
Definition gmCell.h:42
Declaration of the GmCellGeometry base class.
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition gmCellType.h:31
#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
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34