DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
utils.py
Go to the documentation of this file.
1from DNDSR import DNDS, Geom
2import os, sys
3import mpi4py.MPI as MPI
4import numpy as np
5
6
7def get_mesh_2D(meshFile: str, mpi: DNDS.MPIInfo):
8
9 mesh = Geom.UnstructuredMesh(mpi, 2)
10 meshReader = Geom.UnstructuredMeshSerialRW(mesh, 0)
11 assert os.path.isfile(meshFile)
12 name2ID = meshReader.ReadFromCGNSSerial(meshFile)
13 # print(name2ID.n2id_map)
14 meshReader.Deduplicate1to1Periodic(1e-9)
15 meshReader.BuildCell2Cell()
16 meshReader.MeshPartitionCell2Cell({"metisUfactor": 5})
17 meshReader.PartitionReorderToMeshCell2Cell()
18
19 mesh.RecoverNode2CellAndNode2Bnd()
20 mesh.RecoverCell2CellAndBnd2Cell()
21 mesh.BuildGhostPrimary()
22 mesh.AdjGlobal2LocalPrimary()
23 mesh.InterpolateFace()
24 mesh.AssertOnFaces()
25
26 return mesh, meshReader, name2ID
27
28
29def get_mpi4py_comm_from_MPIInfo(mpi: DNDS.MPIInfo):
30 return MPI.Comm.fromhandle(mpi.comm()) # handling raw MPI_Comm handle (pointer)
31
32t_travelling_cell_pack = tuple[Geom.Elem.ElemType, int, int, list[int], np.ndarray]
33
35 cellType: Geom.Elem.ElemType,
36 cellZone: int,
37 iCell: int,
38 cell2nodeRow: list[int],
39 coords: np.ndarray,
40):
41 return (cellType, cellZone, iCell, cell2nodeRow, coords)
pack_travelling_cell(Geom.Elem.ElemType cellType, int cellZone, int iCell, list[int] cell2nodeRow, np.ndarray coords)
Definition utils.py:40
get_mesh_2D(str meshFile, DNDS.MPIInfo mpi)
Definition utils.py:7
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Definition MPI.hpp:215