72 if (params->
hasKey(keys[dim-1]))
80 "No meshes were provided in input file !"
84 if (params->
hasKey(
"coupledNodesFile"))
87 if (params->
hasKey(
"unknowns per region"))
106 "Geometry::setMeshOfDim dim must be 1<=d<=3, got dim=" << dim
113 m_meshes [dim-1] = ceps::getNew<Mesh>(dim);
114 m_meshes [dim-1]->setGeometry(
this);
143 "Geometry::getMeshOfDim dim must be 1<=d<=3, got dim=" << dim
170 "Geometry::hasMeshOfDim dim must be 1<=d<=3, got dim=" << dim
238 if (S ==
"PTSCOTCHNODE")
242 std::stringstream ss;
243 ss <<
"Geometry Parameters: given partitioning method does not exist in CEPS." << std::endl
244 <<
" Valid keywords for partitioning methods are:" << std::endl;
245 ss <<
" - PTScotchNode" << std::endl;
281 CEPS_SAYS(
"Start reading and partitioning meshes with PtScotch");
282 part = ceps::getNew<PtscotchPartitioner>(
this);
310 CepsUInt* cells = ceps::newArray<CepsUInt>(gridSize);
311 CepsUInt* boundary = ceps::newArray<CepsUInt>(gridSize);
312 CepsUInt* nodes = ceps::newArray<CepsUInt>(gridSize);
313 CepsUInt* haloNodes = ceps::newArray<CepsUInt>(gridSize);
326 #ifdef CEPS_DEBUG_ENABLED
400 nbNodes +=
m_meshes[dim-1]->getLocalNbNodes();
410 nbHaloNodes +=
m_meshes[dim-1]->getLocalNbHaloNodes();
427 nbCells +=
m_meshes[dim-1]->getLocalNbCells();
438 nbBoundary +=
m_meshes[dim-1]->getLocalNbBoundaryCells();
499 os <<
" Geometry" << std::endl;
500 os <<
" ~~~~~~~~" << std::endl;
507 for (
CepsUInt dim = 1; dim <= 3; dim++)
510 os <<
" " << dim <<
"D Mesh" << std::endl;
511 os <<
" -------" << std::endl;
523 std::ostream&
operator<<
524 (std::ostream &os,
const Geometry &g)
538 std::ostream& os)
const
552 for (i = 0; i < gridSize; i++)
553 sumCells += cells[i];
556 CepsReal overlapping = 100 * (sumCells - totalCells) / (
CepsReal) totalCells;
559 <<
"# Data Distribution" << std::endl
561 <<
"# Global data:" << std::endl
562 <<
"#\t- Number of nodes: " << totalNodes << std::endl
563 <<
"#\t- Halo nodes: " << totalHaloNodes <<
" (" << ratHaloNodes <<
"% of nodes)" << std::endl
564 <<
"#\t- Cells: " << totalCells << std::endl
565 <<
"#\t- Boundary cells: " << totalBoundary << std::endl
566 <<
"#\t- Theoretical optimum nodes per process: " << 100.0 / gridSize <<
"%" << std::endl
567 <<
"#\t- Cell overlapping: " << overlapping <<
"%" << std::endl;
570 if (totalHaloNodes == 0)
574 for (i = 0; i < gridSize; i++)
576 os <<
"# Process [" << i <<
"]" << std::endl;
577 os <<
"#\t- Owned Nodes: " << nodes[i] <<
" (" << (nodes[i] / (
CepsReal) totalNodes) * 100 <<
"%)" << std::endl;
578 os <<
"#\t- Halo Nodes: " << haloNodes[i] <<
" (" << (haloNodes[i] / (
CepsReal) totalHaloNodes) * 100 <<
"%)"
580 os <<
"#\t- Cells: " << cells[i] <<
" (" << (cells[i] / (
CepsReal) totalCells) * 100 <<
"%)"
582 os <<
"#\t- Boundary Cells: " << boundary[i] <<
" (" << (boundary[i] / (
CepsReal) totalBoundary) * 100 <<
"%)"
610 CepsUInt nbCells, nbBdryCells, nbNodes, nbHaloNodes;
614 cells [rank] = nbCells;
615 boundary [rank] = nbBdryCells;
616 nodes [rank] = nbNodes;
617 haloNodes[rank] = nbHaloNodes;
679 std::cout <<
"\033[1m\033[34mWARNING. \033[0mGeometry scale: scaling factor " << scaleFactor
680 <<
" too small! Will not scale at all." << std::endl;
741 m_meshes = {
nullptr,
nullptr,
nullptr};
751 std::istringstream iss(spair);
752 CepsString em =
"Impossible to read number of unknowns in region with given attribute\n";
753 em +=
" The entry should be a comma separated list of pairs <attr,number>.\n";
754 em +=
" Got instead:\n ";
775 CepsUInt gnNSCells(0U), gnNSBdCells(0U), gnOwnedNodes(0U);
#define CEPS_ABORT(message)
Stops the execution with a message. If testing is enabled, only throws a runtime_error.
#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_STRING_SEPARATOR
CepsString used as separator.
std::basic_string< CepsChar > CepsString
C++ format string.
CepsGlobalIndex CepsCellGlobalIndex
Indices of cells.
std::map< _Key, _Tp, _Compare, _Alloc > CepsMap
C++ map.
std::vector< _Type, _Alloc > CepsVector
C++ vector.
CepsInt CepsAttribute
Used to define regions.
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
float CepsReal
Need single precision floating point.
CepsGlobalIndex CepsNodeGlobalIndex
Indices of nodes.
std::unordered_multimap< _Key, _Tp, _Hash, _KeyEqual, _Alloc > CepsMultiMap
C++ multimap.
PartitioningMethod
Enum only meant to hold the method typedef.
@ PTScotchNode
GeomNode SCOTCH partitioning using primal graph.
Base class for other (big) CEPS classes. All classes can get a pointer to this base class and also co...
Abstract class for geometrical cell. On top of index and attributes managament, the cell has informat...
Base class for nodes used in meshes.
Class is used to compute a geometry (multiple meshes) partitioning.
virtual CepsUInt computePartition()=0
Calls the partitioning method specified in the Geometry.
Encapsulates all the geometrical data.
void printDataDistribution(CepsUInt *nCells, CepsUInt *nBdCells, CepsUInt *nNodes, CepsUInt *nHaloNodes, std::ostream &os=std::cout) const
Displays the data distribution (percentages of cell and nodes ownership) for each process.
void scale(CepsReal scaleFactor)
Scale the entire geometry.
CepsVector< CepsSet< CepsNodeGlobalIndex > > m_nodesToSend
List of nodes of which to send data to other process (build at partitioning)
const CepsMap< CepsAttribute, CepsUInt > & getPartitionWeights() const
Set the weights to be put on each region before partitioning.
CepsVector< CepsNodeGlobalIndex > m_nodePartitionMap
Map of node indices from read geometry to partitioned geometry.
CepsUInt m_maxNodeConnectivity
Maximum number of neighbors found for current geometry.
CepsBool has1dMesh() const
true if geometry has 1d data
CepsUInt getNbHaloNodesLocal() const
Number of halo nodes local to this process.
GeomNode * getNode(CepsNodeGlobalIndex globalID, CepsBool ownedOnly=false)
Returns a pointer to the node with given global ID. Nullptr if node is not owned or halo.
CepsUInt m_nbHaloNodes
Number of halo nodes (all meshes, all process)
void setPartitionWeightsFromString(const CepsString &s)
Sets the partition weights for given regions. Default is 1 everywhere.
CepsUInt getNbBoundaryCellsLocal() const
Number of boundary cells local to this process (3d, 2d and 1d). N.B as we have implemented a multiple...
void initialize()
Sets default values.
void setCoupledNodesFile(const CepsString &coupledNodesFile)
Reads mesh couplings from this file.
void set2dMesh(const CepsString &meshFileName)
Creates the 2D mesh data.
CepsArray3< CepsBool > m_hasMeshOfDim
If the geometry contains XD data.
CepsUInt getNbBoundaryCells() const
Number of boundary cells of the geometry (global).
const CepsVector< CepsUInt > & getNodeOffsetPerMesh()
Number of nodes per mesh.
Mesh * get3dMesh() const
Pointer on the 3D mesh.
InputParameters * m_parameters
Config used to setup the geometry, if any.
const CepsVector< CepsSet< CepsNodeGlobalIndex > > & getNodesToReceive()
List of nodes of which to get data to other process (build at partitioning)
void setPartitioningMethod(PartitioningMethod method)
Sets the partitioning method.
CepsArray3< Mesh * > m_meshes
pointer to xD mesh instance
const CepsVector< CepsString > & getVolumicFileNames() const
Files with 3D cells.
CepsMultiMap< CepsNodeGlobalIndex, CepsNodeGlobalIndex > m_coupledNodes
Pairs of coupled nodes.
const CepsVector< CepsString > & getCableFileNames() const
Files with 1D cells.
CepsReal m_maxCellDiameter
Largest cell size across meshes.
CepsBool m_hasCoupledNodes
Whether the geometry has connections or not.
CepsUInt getNbHaloNodes() const
Number of halo nodes of the geometry (global)
Geometry()
Default constructor.
CepsUInt m_nbNodes
Number of nodes (all meshes, all process)
const CepsVector< CepsUInt > & getCellOffsetPerMesh()
Number of cells per mesh.
Mesh * get2dMesh() const
Pointer on the 2D mesh.
CepsUInt m_nbCells
Number of non-boundary cells (all meshes, all process)
const CepsVector< CepsNodeGlobalIndex > & getNodePartitionMap()
The node index map from before to after partitioning.
CepsUInt getNbOwnedNodesLocal() const
Number of nodes local to this process, without halo nodes.
const CepsString & getCoupledNodesFileName() const
Coupled nodes file name.
CepsBool has2dMesh() const
true if geometry has 2d data
PartitioningMethod m_partitioningMethod
How the geometry is partitioned.
CepsVector< CepsUInt > m_cellOffsetPerMesh
Offset of each mesh.
void setMeshOfDim(CepsUInt dim, const CepsString &meshFileName)
Creates mesh data of given dimension.
void getLocalDistribution(CepsUInt *nCells, CepsUInt *nBdCells, CepsUInt *nNodes, CepsUInt *nHaloNodes) const
Gets the local data distribution of all the domains.
CepsBool has3dMesh() const
true if geometry has 3d data
Mesh * get1dMesh() const
Pointer on the 1D mesh.
CepsReal computeMaxCellDiameter()
Finds the largest cell diameter.
const CepsVector< CepsString > & getFileNamesForDim(CepsUInt dim) const
Mesh file names.
CepsString m_coupledNodesFileName
Connections file name, if any.
void setupWithParameters(InputParameters *params)
Initializes the instance with all parameters.
CepsVector< CepsCellGlobalIndex > m_cellPartitionMap
Map of cell indices from read geometry to partitioned geometry.
PartitioningMethod getPartitioningMethod() const
Partitioning method (flavours of scotch)
CepsUInt getNbNodesLocal() const
Number of nodes local to this process, with halo nodes.
CepsReal getMaxCellDiameter() const
Get the largest diameter of geom cells across meshes.
const CepsVector< CepsString > & getSurfacicFileNames() const
Files with surfacic cells.
CepsVector< CepsSet< CepsNodeGlobalIndex > > m_nodesToReceive
List of nodes of which to get data to other process (build at partitioning)
CepsUInt computePartition()
Launches the computation of a partitioning. A Geometry may not be manipulated before a partitioning h...
const CepsVector< CepsSet< CepsNodeGlobalIndex > > & getNodesToSend()
List of nodes of which to send data to other process (build at partitioning)
void set3dMesh(const CepsString &meshFileName)
Creates the 3D mesh data.
void updateGeometryInfo()
Update each mesh info.
void setPartitioningMethodFromString(const CepsString &s)
Sets the partioning method from the input string.
Mesh * getMeshOfDim(CepsUInt dim) const
Return the mesh of requested dimension.
CepsUInt getNbNodes() const
Number of nodes of the geometry (global)
CepsUInt m_nbBoundaryCells
Number of boundary cells (all meshes, all process)
CepsVector< CepsUInt > m_nodeOffsetPerMesh
Offset of each mesh.
void print(std::ostream &os=std::cout) const
Displays some info.
CepsUInt getMaxNodeConnectivity() const
Maximum number of adjacent nodes.
CepsUInt getNbCellsLocal() const
Number of cells local to this process (3d, 2d and 1d). N.B as we have implemented a multiple ownershi...
GeomCell * getCell(CepsCellGlobalIndex globalID)
Returns a pointer to the cell with given global ID. Nullptr if cell is not owned.
CepsUInt computeMaxNodeConnectivity()
Finds the maximum number of adjacent nodes.
CepsBool hasMeshOfDim(CepsUInt dim) const
true if geometry has data of requested dimension
CepsMap< CepsAttribute, CepsUInt > m_partitionWeights
nb of unknowns per regions for unbalanced partitions
CepsArray3< CepsVector< CepsString > > m_meshFilenames
All the meshes file names.
const CepsVector< CepsCellGlobalIndex > & getCellPartitionMap()
The node index map from before to after partitioning.
void setPartitionWeights(const CepsMap< CepsAttribute, CepsUInt > &weights)
Set the weights to be put on each region before partitioning.
void getGlobalDistribution(CepsUInt *nCells, CepsUInt *nBDCells, CepsUInt *nNodes, CepsUInt *nHaloNodes) const
Gets the global data distribution of the domains.
void set1dMesh(const CepsString &meshFileName)
Creates the 1D mesh data.
void updateMeshInfo(CepsUInt dim)
Communicate mesh ownership data to all processes.
const CepsMultiMap< CepsNodeGlobalIndex, CepsNodeGlobalIndex > & getCoupledNodes()
Coupled nodes local (owned or in the halo) of this process.
CepsUInt getNbCells() const
Number of non-boundary cells of the geometry (global).
Geometrical information of 1,2 or 3D distributed cells.
CepsUInt getLocalNbCells() const
Number of non-boundary cells stored on this process.
void setNbCells(CepsUInt n)
Set the total number of cells of this mesh.
void setNbNodes(CepsUInt n)
Set the total number of nodes of this mesh.
void scale(CepsReal scaleFactor)
Each node coordinate is scaled by scaleFactor.
CepsUInt getLocalNbNodes() const
Number of nodes stored on this process.
CepsUInt getLocalNbBoundaryCells() const
Number of boundary cells stored on this process.
GeomCell * getCell(CepsCellGlobalIndex geomIndex) const
pointer on requested cell, nullptr if not owned
GeomCell * getBoundaryCell(CepsCellGlobalIndex geomIndex) const
pointer on requested boundary cell, nullptr if not owned
GeomNode * getNodeOrHaloNode(CepsNodeGlobalIndex geomIndex) const
Get node referenced by geom index.
void setNbBoundaryCells(CepsUInt n)
Set the total number of boundary cells of this mesh.
GeomNode * getNode(CepsNodeGlobalIndex globalIndex) const
Get node referenced by global index.
CepsUInt getRank()
Returns current processor rank.
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
void destroyTabular(_Type &)
Destroy[delete] any type.
CepsBool isVerbose()
Check if the verbosity is enabled on the master proc (always false on slave procs).
MPI_Comm getCommunicator()
Get the communicator.
CepsBool approxEquals(CepsReal a, CepsReal b, CepsReal epsilon)
Approximate equality with epsilon tolerance.
CepsBool isValidPtr(_Type *ptr)
Tells if pointer is not null.
std::ofstream & debugLog()
Get the DebugLog used in Ceps.
const _Type & max(const CepsVector< _Type, _Alloc > &vec)
Returns the maximum of the vector, const version.
CepsUInt getGridSize()
Returns the number of process on the computing grid.
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.
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
void beginSequential()
Begins a sequential block.
CepsVector< CepsString > split(const CepsString &s, const CepsString &delimiters=CepsString(" \t"))
Splits a string using mulitple delimiters in a single string.
CepsBool isMaster()
Is calling process the master ?
CepsBool isDebug()
Check if we enable the debug on the master proc (always false on slave procs).
CepsString toUpper(const CepsString &s)
Switches all characters to upper case.
std::ofstream & profilingLog()
Get the ProfilingLog used in Ceps.
CepsBool equals(CepsReal a, CepsReal b, CepsReal error=1.0)
CepsReal equality up to machine precision.
void endSequential()
End a sequential block.
CepsBool isProfiling()
Check if we are currently profiling on the master proc (always false on slave procs).
void destroyObject(_Type &)
Destroy[delete] any type.