87 "Tetgen mesh : found no boundary cell file " << std::quoted(
"*.face") <<
" or "
88 << std::quoted(
"*.edge") <<
" associated to "
105 std::stringstream hn;
106 hn <<
"Tetgen mesh reader: in file " <<
m_nodesFileName <<
"," << std::endl <<
" ";
117 m_file.seekg (0, std::ios::beg);
118 std::stringstream hc;
119 hc <<
"Tetgen mesh reader: in file " <<
m_fileName <<
"," << std::endl <<
" ";
130 "Provided .ele file does not have elements with the expected number of nodes " <<
m_fileName
139 std::stringstream hb;
140 hb <<
"Tetgen mesh reader: in file " <<
m_bdryFileName <<
"," << std::endl <<
" ";
151 "Provided .face or .edge file does not have elements with the expected number of nodes "
188 CepsUInt nbToRead = indexEnd-indexStart;
192 for (
CepsUInt i=0U; i<indexStart; i++)
195 std::stringstream hh;
197 << std::endl <<
" unable to read ";
238 CepsInt nbToRead = indexEnd-indexStart;
247 nbBoundaryToRead = nbToRead;
255 nbBoundaryToRead = nbToRead-nbCellsToRead;
257 for (
CepsUInt i = 0U; i < indexStart; i++)
263 for (i = 0; i < nbCellsToRead; i++)
265 cellOffset+i,i,nodeOffset,nodeIndices,nodeIndicesPtr,
266 cellAttr,cellAttrPtr,isBoundaryCell,
false
269 for (; i < nbBoundaryToRead+nbCellsToRead; i++)
271 cellOffset+i,i-
m_cellsRead,nodeOffset,nodeIndices,nodeIndicesPtr,
272 cellAttr,cellAttrPtr,isBoundaryCell,
true
291 std::stringstream hh;
292 hh <<
"Tetgen mesh reader: in file " <<
m_fileName <<
"," << std::endl <<
" unable to read ";
304 nodeIndices[nodeIndicesPtr[cellId]+i] =
ceps::readInt(*file,h+
"node IDs of cell #"+c)
308 cellAttr[cellAttrPtr[cellId]+i] =
ceps::readInt(*file,h+
"attributes of cell #"+c);
310 cellAttrPtr [cellId+1] = cellAttrPtr [cellId] + nAttr;
311 nodeIndicesPtr[cellId+1] = nodeIndicesPtr[cellId] + nbPts;
313 isBoundaryCell[cellId] = boundaryFlag;
327 m_file.seekg(0,std::ios::beg);
329 std::getline(
m_file,temp);
#define CEPS_SAYS(message)
Writes a message in the debug log and in the terminal (stdio).
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
#define CEPS_WARNS(message)
Writes a warning in the debug log and in the terminal (stderr).
std::basic_string< CepsChar > CepsString
C++ format string.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
int32_t CepsInt
Need 32 bit integer.
CepsString m_fileName
file to open
std::ifstream m_file
stream
Abstract base class that encapsulates primary functionalities of each mesh reader.
CepsInt m_nodesBegin
line start of nodes
CepsUInt m_nbAttrPerCell
attributes per cell
CepsBool m_initialized
Flag to ensure call of initializeReader()
void checkCanReadNodes(CepsUInt indexStart, CepsUInt indexEnd) const
Aborts if passed indices are wrong.
CepsUInt m_nbNodesPerBdryCell
nb nodes per boundary cell
CepsBool m_quads
Reader for quadratic cells.
CepsUInt m_bdryCellsRead
Keeps track of already read boundary cells.
CepsUInt m_nbNodesPerCell
nb nodes per cell
CepsUInt m_nbBdryCells
number of boundary cells in mesh, appropriate for dimension
CepsUInt m_nbAttrPerBdryCell
attributes per boundary cell
CepsUInt m_cellsRead
Keeps track of already read cells.
CepsUInt m_nbAttrPerNode
attributes per node
virtual CepsBool checkExtension() const
Stop if extension is not ok, extension must be defined in child classes.
CepsInt m_cellsBegin
line start of cells
CepsUInt m_expectedDim
Expected dimension of mesh.
CepsUInt m_nbCellsTotal
number of all cells in file
CepsInt m_bdryCellsBegin
line start of boundary cells
CepsString m_extension
File name extension.
CepsUInt m_nbNodes
number of nodes in mesh
CepsUInt m_nbCells
number of cells in mesh, appropriate for dimension
void checkCanReadCells(CepsUInt indexStart, CepsUInt indexEnd) const
Aborts if passed indices are wrong.
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.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
CepsInt readInt(std::istream &file, const CepsString &errorMessage="")
Reads an integral number from an istream, aborts if conversion fails advances the stream by 1 word.
CepsString changeExtension(const CepsString &str, const CepsString &ext)
Change the extension of a file name (does not check if file exists).
CepsReal readReal(std::istream &file, const CepsString &errorMessage="")
Reads a floating point number from an istream, aborts if conversion fails advances the stream by 1 wo...