41 m_totalNbBdryCells (0u)
44 CepsUInt nVolumic = volumicMeshes.size ();
45 CepsUInt nSurfacic = surfacicMeshes.size ();
46 CepsUInt nCable = cableMeshes.size ();
62 for (
CepsUInt i = 0U; i < nVolumic; i++, index++)
67 for (
CepsUInt i = 0U; i < nSurfacic; i++, index++)
72 for (
CepsUInt i = 0U; i < nCable; i++, index++)
114 memset (cellOffsets, 0, 4*
sizeof(
CepsUInt));
120 cellOffsets[j] += nbCells;
132 offsets[i+1] = offsets[i]
141 memset(offsets, 0, 4*
sizeof(
CepsUInt));
146 offsets[j] += nbNodes;
190 if (nbNodesToRead < 1)
212 "GeometryReader: starting node index is larger than number of nodes in all meshes"
215 meshesToRead.push_back(iMesh);
217 meshesNbAttr.push_back(
m_readers[iMesh]->getNbAttributesPerNode());
221 CepsUInt indexEnd = indexStart + nbNodesToRead;
235 CEPS_ABORT(
"Number of nodes to read is too large!");
243 meshesToRead.push_back(iMesh+1);
244 meshesStart .push_back(0);
245 meshesNbAttr.push_back(
m_readers[iMesh+1]->getNbAttributesPerNode());
256 coords.resize(3 * nbNodesToRead);
260 for (
CepsUInt i=0U; i<meshesToRead.size(); i++)
261 memorySize += meshesNbAttr[i]*(meshesEnd[i]-meshesStart[i]);
264 attr.resize(memorySize, 0);
266 attrPtr.resize(nbNodesToRead+1, 0);
273 CepsUInt nbNodesRead(0u), start(0u), end(0u), toRead(0u);
275 for (
CepsUInt i=0U; i<meshesToRead.size(); i++)
277 toRead = meshesToRead[i];
278 start = meshesStart [i];
281 nbNodesRead += end-start;
283 attrSize = memorySize;
302 if (nbCellsToRead < 1)
310 CepsUInt indexEnd = indexStart + nbCellsToRead;
316 CepsUInt nbBdryCells[3] = {0, 0, 0};
326 "GeometryReader: starting cell index is larger than # of cells in all meshes"
330 meshesToRead.push_back (iMesh);
331 meshesStart.push_back (
offset);
352 remainingBdry = totalRemainingCells;
358 if (temp < totalRemainingCells)
361 remainingCells = temp;
362 remainingBdry = totalRemainingCells - temp;
367 remainingCells = totalRemainingCells;
377 meshesEnd.push_back(
offset + totalRemainingCells);
387 "Number of nodes to read is too large!"
398 meshesToRead.push_back(iMesh+1);
399 meshesStart .push_back(0);
418 nodeIndices .resize(niSize);
419 nodeIndicesPtr.resize(nbCellsToRead+1);
420 isBoundary .resize(nbCellsToRead);
423 if (cellAttrSize > 0)
424 attr.resize(cellAttrSize,0);
425 attrPtr.resize(nbCellsToRead+1,0);
430 CepsUInt toRead(0u),start(0u),end(0u);
432 for (
CepsUInt i=0U; i<meshesToRead.size(); i++)
434 toRead = meshesToRead[i];
435 start = meshesStart [i];
439 nodeIndices,nodeIndicesPtr,attr,attrPtr,isBoundary
441 nbCellsRead += end-start;
444 nNodeIndices = nodeIndices.size();
445 nAttr = cellAttrSize;
466 fileName.append (
".mesh");
468 fileName.append (
".ele");
470 fileName.append (
".msh");
472 fileName.append (
".pvtu");
474 fileName.append (
".vtk");
477 fileName = dir +
"/" + fileName;
481 return ceps::getNew<MeditMeshReader>(fileName, dim);
483 else if (ext ==
"ele")
484 return ceps::getNew<TetgenMeshReader>(fileName, dim);
485 else if (ext ==
"msh")
486 return ceps::getNew<GmshMeshReader>(fileName, dim);
487 else if (ext ==
"vtk" or ext ==
"pvtu")
488 return ceps::getNew<VtkMeshReader>(fileName, dim);
490 CEPS_ABORT (
"Unsupported mesh format for file: " << fileName);
515 using couple_t = std::pair<CepsNodeGlobalIndex, CepsNodeGlobalIndex>;
522 for (couple_t c : nc.getNodeCouples ())
525 m_coupledNodes.insert (couple_t (c.first + offsetA, c.second + offsetB));
526 m_coupledNodes.insert (couple_t (c.second + offsetB, c.first + offsetA));
534 GeomCell *c3 = ceps::getNew<GeomSimplex<3u>>();
535 GeomCell *c2 = ceps::getNew<GeomSimplex<2u>>();
536 GeomCell *c1 = ceps::getNew<GeomSimplex<1u>>();
537 GeomCell *c0 = ceps::getNew<GeomSimplex<0u>>();
540 (nbCells[1] + nbBoundary[0]) * c2->getNumberOfNodes () +
541 (nbCells[2] + nbBoundary[1]) * c1->getNumberOfNodes () +
542 nbBoundary[2] * c0->getNumberOfNodes ();
#define CEPS_ABORT(message)
Stops the execution with a message. If testing is enabled, only throws a runtime_error.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
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.
std::unordered_multimap< _Key, _Tp, _Hash, _KeyEqual, _Alloc > CepsMultiMap
C++ multimap.
A derived class of FileReader that is used when reading coupled Nodes files.
CepsVector< NodeCoupling > getCoupledNodesBetween(const CepsVector< CepsString > &meshes)
Returns all given couples between current meshes,.
Abstract class for geometrical cell. On top of index and attributes managament, the cell has informat...
virtual CepsUInt getNumberOfNodes() const =0
Volume for 3D, area for 2D, length for 1D, 0 for points.
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.
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.
CepsUInt getNbNodes() const
Number of nodes of current mesh.
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.
CepsUInt getNbBdryCells() const
Number of boundary cell of current mesh.
virtual CepsInt getNbAttributesPerBdryCell() const
Number of attributes per boundary cell.
CepsUInt getNbCells() const
Number of cell of current mesh.
virtual void initialize()=0
The routine MUST set the number of nodes and cells.
Meta-cell for connections between meshes.
CepsString getDir(const CepsString &str)
Get a substring of s, from beginning of s to the last '/' character. Example: "/home/someone/file....
void destroyTabular(_Type &)
Destroy[delete] any type.
CepsString getFilename(const CepsString &str)
Returns a substring corresponding to the string after the last '/' character. Example: "/home/someone...
CepsInt argVector(const CepsVector< _Type, _Alloc > &vec, const _Type &value)
Get position of element in vector, -1 if not found.
CepsString getExtension(const CepsString &str)
Returns the extension of a file, if any.
void destroyObject(_Type &)
Destroy[delete] any type.
CepsBool fileExists(const CepsString &fileName, const CepsString &directory)