NeoN
A framework for CFD software
Loading...
Searching...
No Matches
unstructuredMesh.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include "Kokkos_Sort.hpp"
8
14
15namespace NeoN
16{
17
32{
33public:
34
60 );
61
86 );
87
93 const vectorVector& points() const { return points_; }
94 vectorVector& points() { return points_; }
95
101 const scalarVector& cellVolumes() const { return cellVolumes_; }
102 scalarVector& cellVolumes() { return cellVolumes_; }
103
109 const vectorVector& cellCenters() const { return cellCenters_; }
110 vectorVector& cellCenters() { return cellCenters_; }
111
117 const vectorVector& faceCenters() const { return faceCenters_; }
118 vectorVector& faceCenters() { return faceCenters_; }
119
125 const vectorVector& faceNormals() const { return faceNormals_; }
126 vectorVector& faceNormals() { return faceNormals_; }
127
133 const scalarVector& faceAreas() const { return faceAreas_; }
134 scalarVector& faceAreas() { return faceAreas_; }
135
141 const labelVector& faceOwners() const { return faceOwners_; }
142 labelVector& faceOwners() { return faceOwners_; }
143
149 const labelVector& faceNeighbors() const { return faceNeighbors_; }
150 labelVector& faceNeighbors() { return faceNeighbors_; }
151
157 sizeType nCells() const { return nCells_; }
158
164 sizeType nInternalFaces() const { return nInternalFaces_; }
165
171 sizeType nBoundaryFaces() const { return boundaryMesh_.nBoundaryFaces(); }
172
179 {
181 }
182
188 sizeType nBoundaries() const { return boundaryMesh_.nBoundaries(); }
189
195 sizeType nProcBoundaryFaces() const { return boundaryMesh_.nProcBoundaryFaces(); }
196
202 localIdx globalOffset() const { return globalOffset_; }
203
209 const BoundaryMesh& boundaryMesh() const { return boundaryMesh_; }
210 BoundaryMesh& boundaryMesh() { return boundaryMesh_; }
211
217 Dictionary& stencilDB() const { return stencilDataBase_; }
218
224 const Executor& exec() const { return exec_; }
225
226private:
227
233 const Executor exec_;
234
238 vectorVector points_;
239
243 scalarVector cellVolumes_;
244
248 vectorVector cellCenters_;
249
256 vectorVector faceNormals_;
257
261 vectorVector faceCenters_;
262
266 scalarVector faceAreas_;
267
271 labelVector faceOwners_;
272
276 labelVector faceNeighbors_;
277
281 sizeType nCells_;
282
286 sizeType nInternalFaces_;
287
294 BoundaryMesh boundaryMesh_;
295
296 //
297 localIdx globalOffset_;
298
304 mutable Dictionary stencilDataBase_;
305};
306
316
322UnstructuredMesh create1DUniformMesh(const Executor exec, const localIdx nCells, scalar lx = 1.0);
323
331 const Executor exec, localIdx nx, localIdx ny, scalar lx = 1.0, scalar ly = 1.0
332);
333
341 const Executor exec,
342 localIdx nx,
343 localIdx ny,
344 localIdx nz,
345 scalar lx = 1.0,
346 scalar ly = 1.0,
347 scalar lz = 1.0
348);
349
350
351#ifdef NF_WITH_MPI_SUPPORT
358UnstructuredMesh create1DUniformMeshPart(const Executor exec, const localIdx nCells);
359
373UnstructuredMesh create2DUniformMeshPart(
374 const Executor exec, const localIdx nCells, const localIdx totalRanks, const localIdx rank
375);
376
389UnstructuredMesh create2DUniformMeshPartX(
390 const Executor exec, const localIdx nCells, const localIdx totalRanks, const localIdx rank
391);
392#endif
393
394} // namespace NeoN
Represents boundaries of an unstructured mesh.
A class representing a dictionary that stores key-value pairs.
Represents an unstructured mesh in NeoN.
const labelVector & faceOwners() const
Get the list of labels of face owner cells.
Dictionary & stencilDB() const
Get the stencil data base.
const scalarVector & cellVolumes() const
Get the field of cell volumes in the mesh.
UnstructuredMesh(vectorVector points, scalarVector cellVolumes, vectorVector cellCenters, vectorVector faceNormals, vectorVector faceCenters, scalarVector faceAreas, labelVector faceOwners, labelVector faceNeighbors, BoundaryMesh boundaryMesh)
Constructor for the UnstructuredMesh class.
UnstructuredMesh(Executor exec, vectorVector points, scalarVector cellVolumes, vectorVector cellCenters, vectorVector faceNormals, vectorVector faceCenters, scalarVector faceAreas, labelVector faceOwners, labelVector faceNeighbors, BoundaryMesh boundaryMesh)
Constructor for the UnstructuredMesh class.
const vectorVector & faceNormals() const
Get the field of face normal vectors.
const labelVector & faceNeighbors() const
Get the list of labels of face neighbor cells.
sizeType nProcBoundaryFaces() const
Get the number of processor-boundary faces (inter-rank faces).
const vectorVector & faceCenters() const
Get the field of face centers.
sizeType nBoundaries() const
Get the number of boundaries patches in the mesh.
const scalarVector & faceAreas() const
Get the field of face areas.
const vectorVector & cellCenters() const
Get the field of cell centers in the mesh.
const Executor & exec() const
Get the executor.
sizeType nBoundaryFaces() const
Get the number of boundary faces in the mesh.
localIdx globalOffset() const
the offset local cellIds for the global mesh.
sizeType nCells() const
Get the number of cells in the mesh.
sizeType nTotalFaces() const
Get the total number of faces including boundary and processor faces in the mesh.
BoundaryMesh & boundaryMesh()
const BoundaryMesh & boundaryMesh() const
Get the boundary mesh.
const vectorVector & points() const
Get the field of mesh points.
sizeType nInternalFaces() const
Get the number of internal faces in the mesh.
Integer types used throughout NeoN.
Definition array.hpp:18
UnstructuredMesh create1DUniformMesh(const Executor exec, const localIdx nCells, scalar lx=1.0)
A factory function for a 1D uniform mesh.
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:21
UnstructuredMesh createSingleCellMesh(const Executor exec)
creates a mesh containing only a single cell @warn currently this is only a 2D mesh
float scalar
Definition scalar.hpp:17
std::size_t sizeType
Definition label.hpp:56
NeoN::Vector< Vec3 > vectorVector
UnstructuredMesh create2DUniformMesh(const Executor exec, localIdx nx, localIdx ny, scalar lx=1.0, scalar ly=1.0)
A factory function for a 2D uniform mesh (single-layer hex slab).
UnstructuredMesh create3DUniformMesh(const Executor exec, localIdx nx, localIdx ny, localIdx nz, scalar lx=1.0, scalar ly=1.0, scalar lz=1.0)
A factory function for a uniform 3D hex mesh.
NeoN::Vector< scalar > scalarVector
int32_t localIdx
Definition label.hpp:50
NeoN::Vector< label > labelVector