CEPS  24.01
Cardiac ElectroPhysiology Simulator
Mesh.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 #pragma once
32 
35 
36 // Forward declaration of geometry template class
37 class Geometry;
38 
56 class Mesh
57 {
58 
59  public:
60 
62  explicit Mesh(CepsUInt dim);
63 
65  ~Mesh();
66 
68  CepsUInt
69  getDimension() const;
70 
72  void
73  addCell(GeomCell *cell);
74 
76  void
77  addBoundaryCell(GeomCell *boundaryCell);
78 
80  void
81  addNode(GeomNode *node);
82 
84  void
85  addHaloNode(GeomNode *node);
86 
88  void
89  refreshCells();
90 
96  void
98 
104  void
106 
111  void
112  setNbNodes(CepsUInt n);
113 
117  GeomNode*
118  getNode(CepsNodeGlobalIndex globalIndex) const;
119 
124  GeomNode*
125  getHaloNode(CepsNodeGlobalIndex geomIndex) const;
126 
130  GeomNode*
131  getNodeOrHaloNode(CepsNodeGlobalIndex geomIndex) const;
132 
136  CepsInt
137  getLocalIndexOfCell(CepsCellGlobalIndex geomIndex) const;
138 
142  CepsInt
144 
146  GeomCell*
147  getCell(CepsCellGlobalIndex geomIndex) const;
148 
150  GeomCell*
151  getBoundaryCell(CepsCellGlobalIndex geomIndex) const;
152 
154  const CepsVector<GeomCell*>&
155  getCells();
156 
158  const CepsVector<GeomCell*>&
160 
162  const CepsVector<GeomNode*>&
163  getOwnedNodes();
164 
166  const CepsVector<GeomNode*>&
167  getHaloNodes();
168 
170  CepsUInt
171  getNbCells() const;
172 
174  CepsUInt
175  getNbBoundaryCells() const;
176 
178  CepsUInt
179  getNbNodes() const;
180 
182  CepsUInt
183  getLocalNbCells() const;
184 
186  CepsUInt
187  getLocalNbBoundaryCells() const;
188 
190  CepsUInt
191  getLocalNbNodes() const;
192 
194  CepsUInt
195  getLocalNbHaloNodes() const;
196 
198  CepsUInt
200 
202  CepsReal
203  getMaxCellDiameter() const;
204 
206  void
207  setGeometry(Geometry* geom);
208 
210  Geometry*
211  getGeometry() const;
212 
214  void
215  scale(CepsReal scaleFactor);
216 
218  friend std::ostream&
219  operator<<(std::ostream& os, const Mesh& m);
220 
221 
222  protected:
223 
225  CepsUInt
227 
229  CepsHash
230  getNodeHash(GeomNode* n);
231 
233  CepsHash
234  getCellHash(GeomCell* c);
235 
236 
237  protected:
238 
239  // ----------------------------------------**
240  // GLOBAL DATA
241  // ----------------------------------------**
242 
244 
251 
252  // ----------------------------------------**
253  // PARTIAL DATA
254  // ----------------------------------------**
255 
256  // Data structures
261 
263 };
264 
266 std::ostream&
267 operator<<(std::ostream& os, const Mesh& m);
CepsGlobalIndex CepsCellGlobalIndex
Indices of cells.
Definition: CepsTypes.hpp:222
CepsSize CepsHash
Hashes for distributed data.
Definition: CepsTypes.hpp:220
std::vector< _Type, _Alloc > CepsVector
C++ vector.
Definition: CepsTypes.hpp:155
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
CepsGlobalIndex CepsNodeGlobalIndex
Indices of nodes.
Definition: CepsTypes.hpp:224
int32_t CepsInt
Need 32 bit integer.
Definition: CepsTypes.hpp:106
std::ostream & operator<<(std::ostream &os, const Mesh &m)
Displays some info on the mesh.
Definition: Mesh.cpp:334
Abstract class for geometrical cell. On top of index and attributes managament, the cell has informat...
Definition: GeomCell.hpp:48
Base class for nodes used in meshes.
Definition: GeomNode.hpp:53
Encapsulates all the geometrical data.
Definition: Geometry.hpp:50
Geometrical information of 1,2 or 3D distributed cells.
Definition: Mesh.hpp:57
CepsReal m_maxCellDiameter
Largest cell size.
Definition: Mesh.hpp:250
void addBoundaryCell(GeomCell *boundaryCell)
Add a boundary cell to the mesh.
Definition: Mesh.cpp:87
CepsInt getLocalIndexOfBoundaryCell(CepsCellGlobalIndex geomIndex) const
Geom global to local mapping for boundary cells.
Definition: Mesh.cpp:186
const CepsVector< GeomNode * > & getOwnedNodes()
CepsVector of local nodes stored on this process.
Definition: Mesh.cpp:216
CepsUInt getNbBoundaryCells() const
Total number of boundary cells of the mesh.
Definition: Mesh.cpp:234
CepsUInt getMaxNodeConnectivity()
Local maximum node connectivity (nb of adjacent nodes)
Definition: Mesh.cpp:270
CepsUInt m_nbNodes
whole mesh nodes count
Definition: Mesh.hpp:248
CepsUInt computeMaxNodeConnectivity()
Locally computes the maximum node connectivity (nb of adjacent nodes)
Definition: Mesh.cpp:319
LocalGlobalMapping< GeomNode * > m_haloNodes
Nodes in halo.
Definition: Mesh.hpp:260
CepsUInt getLocalNbCells() const
Number of non-boundary cells stored on this process.
Definition: Mesh.cpp:246
void addHaloNode(GeomNode *node)
Add a halo node to the mesh.
Definition: Mesh.cpp:120
void refreshCells()
Forces re-evaluation of each cell structure (boundary elmts included).
Definition: Mesh.cpp:135
CepsHash getNodeHash(GeomNode *n)
gets an identifier for the node (here its global index)
Definition: Mesh.cpp:307
CepsUInt getNbNodes() const
Total number of nodes of the mesh.
Definition: Mesh.cpp:240
CepsBool m_connectivityComputed
computation flag
Definition: Mesh.hpp:249
CepsUInt getDimension() const
Geometrical dimension.
Definition: Mesh.cpp:59
void setNbCells(CepsUInt n)
Set the total number of cells of this mesh.
Definition: Mesh.cpp:145
void setNbNodes(CepsUInt n)
Set the total number of nodes of this mesh.
Definition: Mesh.cpp:156
GeomNode * getHaloNode(CepsNodeGlobalIndex geomIndex) const
Get node referenced by geom index.
Definition: Mesh.cpp:168
Geometry * getGeometry() const
Geometry this mesh is tied too.
Definition: Mesh.cpp:290
LocalGlobalMapping< GeomCell * > m_bCells
Boundary cells (dim-1)
Definition: Mesh.hpp:258
void scale(CepsReal scaleFactor)
Each node coordinate is scaled by scaleFactor.
Definition: Mesh.cpp:296
const CepsVector< GeomCell * > & getCells()
CepsVector of cells stored on this process.
Definition: Mesh.cpp:204
const CepsVector< GeomNode * > & getHaloNodes()
CepsVector of halo nodes stored on this process.
Definition: Mesh.cpp:222
~Mesh()
Destructor.
Definition: Mesh.cpp:45
Mesh(CepsUInt dim)
Default constructor.
Definition: Mesh.cpp:33
CepsUInt m_maxNodeConnectivity
maximum nb adjacent nodes.
Definition: Mesh.hpp:262
CepsUInt getNbCells() const
Total number of non-boundary cells of the mesh.
Definition: Mesh.cpp:228
void addNode(GeomNode *node)
Add a node to the mesh.
Definition: Mesh.cpp:106
void addCell(GeomCell *cell)
Add an cell to the mesh.
Definition: Mesh.cpp:65
CepsHash getCellHash(GeomCell *c)
gets an identifier for the node, (here its global index)
Definition: Mesh.cpp:313
CepsReal getMaxCellDiameter() const
Maximum size of cells.
Definition: Mesh.cpp:278
CepsUInt getLocalNbNodes() const
Number of nodes stored on this process.
Definition: Mesh.cpp:258
Geometry * m_geom
Link to geometry.
Definition: Mesh.hpp:245
CepsUInt getLocalNbBoundaryCells() const
Number of boundary cells stored on this process.
Definition: Mesh.cpp:252
void setGeometry(Geometry *geom)
Link geometry.
Definition: Mesh.cpp:284
GeomCell * getCell(CepsCellGlobalIndex geomIndex) const
pointer on requested cell, nullptr if not owned
Definition: Mesh.cpp:192
LocalGlobalMapping< GeomNode * > m_ownedNodes
Nodes of that proc.
Definition: Mesh.hpp:259
GeomCell * getBoundaryCell(CepsCellGlobalIndex geomIndex) const
pointer on requested boundary cell, nullptr if not owned
Definition: Mesh.cpp:198
CepsUInt getLocalNbHaloNodes() const
Number of halo nodes stored on this process.
Definition: Mesh.cpp:264
GeomNode * getNodeOrHaloNode(CepsNodeGlobalIndex geomIndex) const
Get node referenced by geom index.
Definition: Mesh.cpp:174
CepsUInt m_dim
Dimension of the cells.
Definition: Mesh.hpp:243
void setNbBoundaryCells(CepsUInt n)
Set the total number of boundary cells of this mesh.
Definition: Mesh.cpp:151
CepsUInt m_nbCells
whole mesh cells count
Definition: Mesh.hpp:246
CepsUInt m_nbBoundaryCells
whole mesh boundary cells count
Definition: Mesh.hpp:247
GeomNode * getNode(CepsNodeGlobalIndex globalIndex) const
Get node referenced by global index.
Definition: Mesh.cpp:162
const CepsVector< GeomCell * > & getBoundaryCells()
CepsVector of boundary cells stored on this process.
Definition: Mesh.cpp:210
friend std::ostream & operator<<(std::ostream &os, const Mesh &m)
Displays some info on the mesh.
Definition: Mesh.cpp:334
LocalGlobalMapping< GeomCell * > m_cells
Cells of main dimension.
Definition: Mesh.hpp:257
CepsInt getLocalIndexOfCell(CepsCellGlobalIndex geomIndex) const
Geom global to local mapping for cells.
Definition: Mesh.cpp:180