CEPS  24.01
Cardiac ElectroPhysiology Simulator
MeshReader.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 
33 #include "common/CepsCommon.hpp"
34 
41 class MeshReader : public FileReader
42 {
43 
44  public:
45 
47  MeshReader() = delete;
48 
50  MeshReader(const CepsString &mesh, const CepsUInt &dim, CepsBool quads = false);
51 
53  ~MeshReader() override;
54 
56  CepsUInt
57  getNbCellsRead() const;
58 
60  CepsUInt
61  getNbBdryCellsRead() const;
62 
64  CepsUInt
65  getNbNodes() const;
66 
68  CepsUInt
69  getNbCells() const;
70 
72  CepsUInt
73  getNbBdryCells() const;
74 
76  virtual CepsInt
77  getNbAttributesPerNode() const;
78 
80  virtual CepsInt
81  getNbAttributesPerCell() const;
82 
84  virtual CepsInt
86 
88  virtual void
89  initialize() = 0;
90 
98  virtual void
100  CepsUInt indexStart,
101  CepsUInt indexEnd,
102  CepsUInt nodeOffset,
103  CepsVector<CepsReal>& coords,
105  CepsVector<CepsUInt>& attrPtr
106  ) = 0;
107 
118  virtual void
120  CepsUInt indexStart,
121  CepsUInt indexEnd,
122  CepsUInt nodeOffset,
123  CepsUInt cellOffset,
124  CepsVector<CepsNodeGlobalIndex>& nodeIndices,
125  CepsVector<CepsUInt>& nodeIndicesPtr,
126  CepsVector<CepsAttribute>& cellAttr,
127  CepsVector<CepsUInt>& cellAttrPtr,
128  CepsVector<CepsChar>& isBoundaryCell
129  ) = 0;
130 
131 
132  protected:
133 
144  virtual void
146  CepsUInt cellId,
147  CepsUInt fileCellId,
148  CepsUInt nodeOffset,
149  CepsVector<CepsNodeGlobalIndex>& nodeIndices,
150  CepsVector<CepsUInt>& nodeIndicesPtr,
151  CepsVector<CepsAttribute>& cellAttr,
152  CepsVector<CepsUInt>& cellAttrPtr,
153  CepsVector<CepsChar>& isBoundaryCell,
154  CepsBool boundaryFlag
155  ) = 0;
156 
158  virtual CepsBool
159  checkExtension() const;
160 
162  void
163  checkCanReadNodes(CepsUInt indexStart, CepsUInt indexEnd) const;
164 
166  void
167  checkCanReadCells(CepsUInt indexStart, CepsUInt indexEnd) const;
168 
169 
170  protected:
171 
173 
177 
182 
185 
189 
192 
196 };
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
Base class that regroups common reader functionalities.
Definition: FileReader.hpp:43
Abstract base class that encapsulates primary functionalities of each mesh reader.
Definition: MeshReader.hpp:42
CepsInt m_nodesBegin
line start of nodes
Definition: MeshReader.hpp:183
CepsUInt m_nbAttrPerCell
attributes per cell
Definition: MeshReader.hpp:194
CepsUInt getNbCellsRead() const
Number of cells that have been read until now.
Definition: MeshReader.cpp:75
virtual void readNodes(CepsUInt indexStart, CepsUInt indexEnd, CepsUInt nodeOffset, CepsVector< CepsReal > &coords, CepsVector< CepsAttribute > &attr, CepsVector< CepsUInt > &attrPtr)=0
Reads several nodes in mesh file.
virtual CepsInt getNbAttributesPerCell() const
Number of attributes per cell.
Definition: MeshReader.cpp:111
CepsUInt getNbNodes() const
Number of nodes of current mesh.
Definition: MeshReader.cpp:87
CepsBool m_initialized
Flag to ensure call of initializeReader()
Definition: MeshReader.hpp:176
void checkCanReadNodes(CepsUInt indexStart, CepsUInt indexEnd) const
Aborts if passed indices are wrong.
Definition: MeshReader.cpp:137
MeshReader()=delete
Deleted default constructor.
CepsUInt m_nbNodesPerBdryCell
nb nodes per boundary cell
Definition: MeshReader.hpp:181
virtual void readCells(CepsUInt indexStart, CepsUInt indexEnd, CepsUInt nodeOffset, CepsUInt cellOffset, CepsVector< CepsNodeGlobalIndex > &nodeIndices, CepsVector< CepsUInt > &nodeIndicesPtr, CepsVector< CepsAttribute > &cellAttr, CepsVector< CepsUInt > &cellAttrPtr, CepsVector< CepsChar > &isBoundaryCell)=0
Reads several cells in mesh file.
CepsBool m_quads
Reader for quadratic cells.
Definition: MeshReader.hpp:175
CepsUInt m_bdryCellsRead
Keeps track of already read boundary cells.
Definition: MeshReader.hpp:180
~MeshReader() override
Destructor.
Definition: MeshReader.cpp:71
CepsUInt m_nbNodesPerCell
nb nodes per cell
Definition: MeshReader.hpp:179
CepsUInt getNbBdryCells() const
Number of boundary cell of current mesh.
Definition: MeshReader.cpp:99
virtual CepsInt getNbAttributesPerBdryCell() const
Number of attributes per boundary cell.
Definition: MeshReader.cpp:117
CepsUInt m_nbBdryCells
number of boundary cells in mesh, appropriate for dimension
Definition: MeshReader.hpp:191
CepsUInt getNbCells() const
Number of cell of current mesh.
Definition: MeshReader.cpp:93
CepsUInt m_nbAttrPerBdryCell
attributes per boundary cell
Definition: MeshReader.hpp:195
CepsUInt m_cellsRead
Keeps track of already read cells.
Definition: MeshReader.hpp:178
CepsUInt m_nbAttrPerNode
attributes per node
Definition: MeshReader.hpp:193
virtual CepsInt getNbAttributesPerNode() const
Number of attributes per node.
Definition: MeshReader.cpp:105
virtual CepsBool checkExtension() const
Stop if extension is not ok, extension must be defined in child classes.
Definition: MeshReader.cpp:123
CepsInt m_cellsBegin
line start of cells
Definition: MeshReader.hpp:186
CepsUInt m_expectedDim
Expected dimension of mesh.
Definition: MeshReader.hpp:174
CepsUInt m_nbCellsTotal
number of all cells in file
Definition: MeshReader.hpp:188
CepsInt m_bdryCellsBegin
line start of boundary cells
Definition: MeshReader.hpp:190
CepsString m_extension
File name extension.
Definition: MeshReader.hpp:172
CepsUInt m_nbNodes
number of nodes in mesh
Definition: MeshReader.hpp:184
CepsUInt getNbBdryCellsRead() const
Number of boundary cells that have been read.
Definition: MeshReader.cpp:81
CepsUInt m_nbCells
number of cells in mesh, appropriate for dimension
Definition: MeshReader.hpp:187
virtual void initialize()=0
The routine MUST set the number of nodes and cells.
virtual void getNextCell(CepsUInt cellId, CepsUInt fileCellId, CepsUInt nodeOffset, CepsVector< CepsNodeGlobalIndex > &nodeIndices, CepsVector< CepsUInt > &nodeIndicesPtr, CepsVector< CepsAttribute > &cellAttr, CepsVector< CepsUInt > &cellAttrPtr, CepsVector< CepsChar > &isBoundaryCell, CepsBool boundaryFlag)=0
Reads a single cell in mesh file.
void checkCanReadCells(CepsUInt indexStart, CepsUInt indexEnd) const
Aborts if passed indices are wrong.
Definition: MeshReader.cpp:151