DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
DOFFactory.hpp
Go to the documentation of this file.
1#pragma once
2/// @file DOFFactory.hpp
3/// @brief Free-function DOF array builders extracted from FiniteVolume.
4///
5/// These build cell/face/node DOF arrays with ghost communication setup.
6/// FiniteVolume::BuildUDof and BuildUGradD delegate to these.
7
8#include "VRDefines.hpp"
9#include "Geom/Mesh.hpp"
10
11namespace DNDS::CFV
12{
13 /// @brief Build a DOF array pair matching a mesh location (cell/face/node).
14 ///
15 /// Creates father+son arrays, optionally sets up ghost communication
16 /// by borrowing the indexing from the mesh's corresponding adjacency.
17 template <int nVarsFixed = 1>
20 const std::string &name,
21 const MPIInfo &mpi,
23 int nVars,
24 bool buildSon = true,
25 bool buildTrans = true,
27 {
28 u.InitPair(name, mpi);
29 DNDS_assert(varloc);
30 switch (varloc)
31 {
33 u.father->Resize(mesh->NumCell(), nVars, 1);
34 break;
36 u.father->Resize(mesh->NumNode(), nVars, 1);
37 break;
39 u.father->Resize(mesh->NumFace(), nVars, 1);
40 break;
41 default:
42 DNDS_assert(false);
43 }
44 if (buildSon)
45 switch (varloc)
46 {
48 u.son->Resize(mesh->NumCellGhost(), nVars, 1);
49 break;
51 u.son->Resize(mesh->NumNodeGhost(), nVars, 1);
52 break;
54 u.son->Resize(mesh->NumFaceGhost(), nVars, 1);
55 break;
56 default:
57 DNDS_assert(false);
58 }
59
60 if (buildTrans)
61 {
62 DNDS_assert(buildSon);
63 u.TransAttach();
64 switch (varloc)
65 {
67 u.trans.BorrowGGIndexing(mesh->cell2node.trans);
68 break;
70 u.trans.BorrowGGIndexing(mesh->coords.trans);
71 break;
73 u.trans.BorrowGGIndexing(mesh->face2node.trans);
74 break;
75 default:
76 DNDS_assert(false);
77 }
78 u.trans.createMPITypes();
79 u.trans.initPersistentPull();
80 u.trans.initPersistentPush();
81 }
82
83 for (index iCell = 0; iCell < u.Size(); iCell++)
84 u[iCell].setZero();
85 }
86
87 /// @brief Build a gradient DOF array pair matching a mesh location.
88 template <int nVarsFixed, int dim>
91 const std::string &name,
92 const MPIInfo &mpi,
94 int nVars,
95 bool buildSon = true,
96 bool buildTrans = true,
98 {
99 u.InitPair(name, mpi);
100 switch (varloc)
101 {
103 u.father->Resize(mesh->NumCell(), dim, nVars);
104 break;
106 u.father->Resize(mesh->NumNode(), dim, nVars);
107 break;
109 u.father->Resize(mesh->NumFace(), dim, nVars);
110 break;
111 default:
112 DNDS_assert(false);
113 }
114 if (buildSon)
115 switch (varloc)
116 {
118 u.son->Resize(mesh->NumCellGhost(), dim, nVars);
119 break;
121 u.son->Resize(mesh->NumNodeGhost(), dim, nVars);
122 break;
124 u.son->Resize(mesh->NumFaceGhost(), dim, nVars);
125 break;
126 default:
127 DNDS_assert(false);
128 }
129 if (buildTrans)
130 {
131 DNDS_assert(buildSon);
132 u.TransAttach();
133 switch (varloc)
134 {
136 u.trans.BorrowGGIndexing(mesh->cell2node.trans);
137 break;
139 u.trans.BorrowGGIndexing(mesh->coords.trans);
140 break;
142 u.trans.BorrowGGIndexing(mesh->face2node.trans);
143 break;
144 default:
145 DNDS_assert(false);
146 }
147 u.trans.createMPITypes();
148 u.trans.initPersistentPull();
149 u.trans.initPersistentPush();
150 }
151
152 for (index iCell = 0; iCell < u.Size(); iCell++)
153 u[iCell].setZero();
154 }
155}
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
Definition Errors.hpp:108
Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations.
Definition ArrayDOF.hpp:172
void BuildUGradDOnMesh(tUGrad< nVarsFixed, dim > &u, const std::string &name, const MPIInfo &mpi, const ssp< Geom::UnstructuredMesh > &mesh, int nVars, bool buildSon=true, bool buildTrans=true, Geom::MeshLoc varloc=Geom::MeshLoc::Cell)
Build a gradient DOF array pair matching a mesh location.
void BuildUDofOnMesh(tUDof< nVarsFixed > &u, const std::string &name, const MPIInfo &mpi, const ssp< Geom::UnstructuredMesh > &mesh, int nVars, bool buildSon=true, bool buildTrans=true, Geom::MeshLoc varloc=Geom::MeshLoc::Cell)
Build a DOF array pair matching a mesh location (cell/face/node).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Definition Defines.hpp:107
std::shared_ptr< T > ssp
Shortened alias for std::shared_ptr used pervasively in DNDSR.
Definition Defines.hpp:138
void TransAttach()
Bind the transformer to the current father / son pointers.
ssp< TArray > father
Owned-side array (must be resized before ghost setup).
index Size() const
Combined row count (father->Size() + son->Size()).
void InitPair(const std::string &name, Args &&...args)
Allocate both father and son arrays, forwarding all args to TArray constructor.
ssp< TArray > son
Ghost-side array (sized automatically by createMPITypes / BorrowAndPull).
TTrans trans
Ghost-communication engine bound to father and son.
Lightweight bundle of an MPI communicator and the calling rank's coordinates.
Definition MPI.hpp:215