CEPS  24.01
Cardiac ElectroPhysiology Simulator
TetgenMeshReader.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 
34 
43 {
44 
45  public:
46 
48  TetgenMeshReader(const CepsString &fileName, const CepsUInt &dim, CepsBool quads = false);
49 
51  ~TetgenMeshReader() override;
52 
54  CepsBool
55  open() override;
56 
58  void
59  resetStreams();
60 
62  void
63  initialize() override;
64 
66  CepsBool
67  hasBoundaryMarker() const;
68 
70  void
71  readNodes(
72  CepsUInt indexStart,
73  CepsUInt indexEnd,
74  CepsUInt nodeOffset,
75  CepsVector<CepsReal>& coords,
77  CepsVector<CepsUInt>& attrPtr
78  ) override;
79 
81  void
82  readCells(
83  CepsUInt indexStart,
84  CepsUInt indexEnd,
85  CepsUInt nodeOffset,
86  CepsUInt cellOffset,
88  CepsVector<CepsUInt>& nodeIndicesPtr,
89  CepsVector<CepsAttribute>& cellAttr,
90  CepsVector<CepsUInt>& cellAttrPtr,
91  CepsVector<CepsChar>& isBoundaryCell
92  ) override;
93 
94 
95  private:
96 
98  void
100  CepsUInt cellId,
101  CepsUInt fileCellId,
102  CepsUInt nodeOffset,
103  CepsVector<CepsNodeGlobalIndex>& nodeIndices,
104  CepsVector<CepsUInt>& nodeIndicesPtr,
105  CepsVector<CepsAttribute>& cellAttr,
106  CepsVector<CepsUInt>& cellAttrPtr,
107  CepsVector<CepsChar>& isBoundaryCell,
108  CepsBool boundaryFlag
109  ) override;
110 
111 
112  private:
113 
114  std::ifstream m_nodesFile;
115  std::ifstream m_bdryFile;
119 
122 };
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
Abstract base class that encapsulates primary functionalities of each mesh reader.
Definition: MeshReader.hpp:42
Parser for tetgen .ele .node ... files.
TetgenMeshReader(const CepsString &fileName, const CepsUInt &dim, CepsBool quads=false)
Constructor. The .ele file name must be provided.
CepsString m_bdryFileName
File with boundary cells.
CepsUInt m_indexOffset
Cells and nodes indices may start from 0 or 1...
CepsBool open() override
Redefinition of base class open method as more than 1 file must be opened.
CepsString m_nodesFileName
File with nodes.
std::ifstream m_nodesFile
File with nodes.
CepsBool hasBoundaryMarker() const
True if current mesh has boundary markers.
void initialize() override
Get number of nodes and cells from files. Prior to any reading.
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) override
Reads several cells in mesh file.
std::ifstream m_bdryFile
File with boundary cells.
~TetgenMeshReader() override
Destructor.
CepsInt m_bdryMarker
Should be 1 or 0.
void resetStreams()
Place the streams at the correct lines.
CepsUInt m_bdryIndexOffset
Index offset for boundary cells.
void readNodes(CepsUInt indexStart, CepsUInt indexEnd, CepsUInt nodeOffset, CepsVector< CepsReal > &coords, CepsVector< CepsAttribute > &attr, CepsVector< CepsUInt > &attrPtr) override
Reads several nodes in mesh file.
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) override
Reads a single cell in mesh file.