GemaCoreLib
The GeMA Core library
gmElementDof.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_ELEMENT_DOF_H_
25 #define _GEMA_ELEMENT_DOF_H_
26 
27 #include <QList>
28 #include "gmCell.h"
29 
36 typedef quint64 GmElementDofMap;
37 
41 #define GM_MAX_DOF (8*sizeof(GmElementDofMap))
42 
43 
48 {
49 public:
51  virtual int numDof() const = 0;
52 
54  virtual int dof(int columnIndex) const = 0;
55 };
56 
57 
62 {
63 public:
64  GmElementDof(GmCellType type, const QList<int>& dofList = QList<int>());
65  GmElementDof(int numNodes, const QList<int>& dofList = QList<int>());
66 
67  ~GmElementDof();
68 
70  virtual int numDof() const { return _ndof; }
71 
73  int numNodes() const { return _nodeMaps.size(); }
74 
81  int node(int columnIndex) const { return _columnNodeList.at(columnIndex); }
82 
89  virtual int dof(int columnIndex) const { return _columnDofList.at(columnIndex); }
90 
92  GmElementDofMap nodeDofMap(int node) const
93  {
94  assert(node >= 0 && node < numNodes());
95  return _nodeMaps[node];
96  }
97 
98  QList<int> nodeDofList(int node) const;
99 
100  GmElementDofMap elementDofMap() const;
101 
102  void setNodeDof(int node, const QList<int>& dofList);
103  void addNode(const QList<int>& dofList);
104 
105 private:
106  Q_DISABLE_COPY(GmElementDof)
107 
108  void init(int numNodes, const QList<int>& dofList);
109 
110  GmElementDofMap dofMapFromList(const QList<int>& dofList) const;
111 
112  int _ndof;
116 };
117 
133 {
134 public:
137 
139  void clear() { _dofList.clear(); _nodeList.clear(); _globalDofMap.clear(); }
140 
142  void setDofList(const QVector<int>& dofList) { _dofList = dofList; }
143 
145  void addNode(int node) { _nodeList.append(node); }
146 
148  virtual int numDof() const { return _nodeList.size() * _dofList.size(); }
149 
153  int node(int columnIndex) const
154  {
155  assert(columnIndex >= 0 && columnIndex < numDof());
156  return _nodeList[columnIndex / _dofList.size()];
157  }
158 
162  virtual int dof(int columnIndex) const
163  {
164  assert(columnIndex >= 0 && columnIndex < numDof());
165  return _dofList[columnIndex % _dofList.size()];
166  }
167 
173  QVector<int>& globalDofMap() { return _globalDofMap; }
174 
175 private:
176  Q_DISABLE_COPY(GmMatrixDof)
177 
178  QVector<int> _nodeList;
179  QVector<int> _dofList;
180 
181  QVector<int> _globalDofMap;
182 };
183 
184 
185 #endif
186 
QVector< GmElementDofMap > _nodeMaps
Vector storing the dof map for each element node.
Definition: gmElementDof.h:113
void clear()
Clears the information stored in the object.
Definition: gmElementDof.h:139
int _ndof
The total number of dof for this element type.
Definition: gmElementDof.h:112
An interface for a simple class returning the dof number associated to a local matrix column.
Definition: gmElementDof.h:47
virtual int numDof() const
Returns the total number of dofs (the number of matrix columns)
Definition: gmElementDof.h:148
virtual int numDof() const
Returns the total number of dofs for this element.
Definition: gmElementDof.h:70
void addNode(int node)
Adds a new node to the matrix. Each node is associated with the dofs given by setDofList()
Definition: gmElementDof.h:145
QVector< int > & globalDofMap()
Returns the global map used to translate local column indices into global dof numbers (indices on a g...
Definition: gmElementDof.h:173
void setDofList(const QVector< int > &dofList)
Sets the list with dof numbers associated with each node.
Definition: gmElementDof.h:142
quint64 GmElementDofMap
An integer type representing the degrees of freedom associated to an element node....
Definition: gmElementDof.h:36
GmElementDofMap nodeDofMap(int node) const
Returns the dof map for the requested element local node.
Definition: gmElementDof.h:92
A class to represent the degrees of freedom associated with the set of matrix columns,...
Definition: gmElementDof.h:132
#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
QVector< int > _columnNodeList
Vector indexed by 'matrix column' storing the column respective node number. Size equal to numDof().
Definition: gmElementDof.h:114
GmCellType
Mesh Cell types. Don't change type orders or add types without reading comments below.
Definition: gmCellType.h:30
int node(int columnIndex) const
Given a 'matrix column' index, returns the associated node.
Definition: gmElementDof.h:81
virtual int dof(int columnIndex) const
Given a 'matrix column' index, returns the associated dof.
Definition: gmElementDof.h:89
GmMatrixDof()
Default connstructor.
Definition: gmElementDof.h:136
int node(int columnIndex) const
Given a 'matrix column' index, returns the associated node. columnIndex must be a value less than num...
Definition: gmElementDof.h:153
Declaration of the GmCell class.
QVector< int > _columnDofList
Vector indexed by 'matrix column' storing the column respective dof number. Size equal to numDof().
Definition: gmElementDof.h:115
virtual int dof(int columnIndex) const
Given a 'matrix column' index, returns the associated dof. columnIndex must be a value less than numD...
Definition: gmElementDof.h:162
int numNodes() const
Returns the number of nodes in the element (which can contain ghost nodes)
Definition: gmElementDof.h:73
virtual int numDof() const =0
Returns the total number of dfs (matrix columns)
A class to represent the degrees of freedom associated with each node of an element as seen by a phys...
Definition: gmElementDof.h:61