CEPS  24.01
Cardiac ElectroPhysiology Simulator
GeometryReader.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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
32 #pragma once
33 
34 #include "common/CepsCommon.hpp"
41 
43 namespace MeshReaderType
44 {
46  enum Type
47  {
48  VOLUMIC = 0,
49  SURFACIC = 1,
50  CABLE = 2
51  };
52 } // namespace MeshReaderType
53 
54 // --------------------------------------------------------
55 // The next class can be later completed with meshes that have quads
56 // Add corresponding vectors of volumicQuadMeshes, surfacicMeshes, etc...
57 // volumicTriMeshes, ...
58 // and rewrite computeCellMemory with an option for quads
59 // Normally, the mesh readers are ready for quads.
60 // --------------------------------------------------------
61 
83 {
84 public:
100  const CepsVector<CepsString> &volumicMeshes,
101  const CepsVector<CepsString> &surfacicMeshes,
102  const CepsVector<CepsString> &cableMeshes,
103  const CepsString &coupledNodesFile = ""
104  );
105 
107  ~GeometryReader ();
108 
109  // Cell/node count
110 
112  void
113  getCellOffsetsPerMeshType (CepsUInt cellOffsets[4]);
114 
116  void
118 
120  void
121  getNodeOffsetsPerMeshType (CepsUInt offsets[4]);
122 
124  void
126 
128  CepsUInt
129  getNbNodes ();
130 
132  CepsUInt
133  getNbCells ();
134 
136  CepsUInt
137  getNbBdryCells ();
138 
150  CepsUInt
151  readNodes (
152  CepsUInt indexStart,
153  CepsUInt nbNodesToRead,
154  CepsVector<CepsReal> &coords,
156  CepsVector<CepsUInt> &attrOffset,
157  CepsUInt &attrSize
158  );
159 
172  CepsUInt
173  readCells (
174  CepsUInt indexStart,
175  CepsUInt nbCellsToRead,
176  CepsVector<CepsNodeGlobalIndex> &nodeIndices,
177  CepsVector<CepsUInt> &nodeIndicesOffset,
179  CepsVector<CepsUInt> &attrOffset,
180  CepsVector<CepsChar> &isBoundary,
181  CepsUInt &eindSize,
182  CepsUInt &attrSize
183  );
184 
187  getCoupledNodes ();
188 
189 private:
195  MeshReader *
196  getMeshReaderFor (const CepsString &meshName, CepsInt index, CepsUInt dim);
197 
204  void
206 
208  void
209  readCoupledNodes (const CepsString &fileName);
210 
213  CepsUInt
214  computeNumberOfNodeIndices (CepsUInt nbCells[3], CepsUInt nbBoundary[3]);
215 
216 protected:
218 
219  // Mesh readers
223 
224  // Coupling meshes
227 
228  // Mesh data
234 
235  // All meshes data
240 };
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
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
int32_t CepsInt
Need 32 bit integer.
Definition: CepsTypes.hpp:106
std::unordered_multimap< _Key, _Tp, _Hash, _KeyEqual, _Alloc > CepsMultiMap
C++ multimap.
Definition: CepsTypes.hpp:205
Regroups all geometrical data readers and prepare for partitionning.
CepsUInt m_totalNbBdryCells
Total # of boundary cells across all meshes.
CepsUInt * m_meshNbBdryCells
Number of boundary cells in each mesh.
void getNodeOffsetPerMesh(CepsVector< CepsUInt > &offsets)
Fills vector with cell offset for each mesh.
CepsUInt * m_meshNbCells
Number of cells in each mesh.
CepsUInt getNbNodes()
All meshes number of nodes.
CepsBool m_hasCoupledNodes
Flag to activate coupled nodes.
void initializeDataStructures()
Reads each mesh in order.
CepsUInt getNbBdryCells()
All meshes number of boundary cells.
CepsUInt readNodes(CepsUInt indexStart, CepsUInt nbNodesToRead, CepsVector< CepsReal > &coords, CepsVector< CepsAttribute > &attr, CepsVector< CepsUInt > &attrOffset, CepsUInt &attrSize)
Reads nbNodesToRead nodes, using global indices.
CepsUInt * m_nodeOffsets
GeomNode offsets for each mesh.
CepsUInt getNbCells()
All meshes number of cells.
CepsUInt * m_readerType
Type of mesh being read.
CepsUInt * m_cellOffsets
Cell offsets for each mesh (bdry included)
CepsUInt m_totalNbNodes
Total # of nodes across all meshes.
CepsVector< CepsString > m_meshFileNames
File names of each mesh.
~GeometryReader()
Destructor.
void getCellOffsetsPerMeshType(CepsUInt cellOffsets[4])
Fills array with cell offsets for each mesh type.
CepsUInt m_nbMeshes
Number of meshes to read.
void getNodeOffsetsPerMeshType(CepsUInt offsets[4])
Fills array with node offsets for each mesh type.
const CepsMultiMap< CepsNodeGlobalIndex, CepsNodeGlobalIndex > & getCoupledNodes()
Returns the hashtable of coupled nodes.
GeometryReader(const CepsVector< CepsString > &volumicMeshes, const CepsVector< CepsString > &surfacicMeshes, const CepsVector< CepsString > &cableMeshes, const CepsString &coupledNodesFile="")
Constructor. Actually runs the reading routines.
void getCellOffsetPerMesh(CepsVector< CepsUInt > &offsets)
Fills vector with cell offset for each mesh.
MeshReader ** m_readers
Array (dimension x type) holding the readers on all meshes.
void readCoupledNodes(const CepsString &fileName)
Get coupled nodes list using CoupledNodesReader.
CepsMultiMap< CepsNodeGlobalIndex, CepsNodeGlobalIndex > m_coupledNodes
Edges linking meshes.
MeshReader * getMeshReaderFor(const CepsString &meshName, CepsInt index, CepsUInt dim)
Initializes a mesh reader depending on the mesh file extension.
CepsUInt m_totalNbCells
Total # of cells across all meshes.
CepsUInt * m_meshNbNodes
Number of nodes in each mesh.
CepsUInt readCells(CepsUInt indexStart, CepsUInt nbCellsToRead, CepsVector< CepsNodeGlobalIndex > &nodeIndices, CepsVector< CepsUInt > &nodeIndicesOffset, CepsVector< CepsAttribute > &attr, CepsVector< CepsUInt > &attrOffset, CepsVector< CepsChar > &isBoundary, CepsUInt &eindSize, CepsUInt &attrSize)
Reads nbCellsToRead cells, using global indices.
CepsUInt computeNumberOfNodeIndices(CepsUInt nbCells[3], CepsUInt nbBoundary[3])
Returns the number of nodes given numbers of cells and boundary cells.
Abstract base class that encapsulates primary functionalities of each mesh reader.
Definition: MeshReader.hpp:42
Enum for better reading of code.
Type
Enum for better reading of code.