11 template <DeviceBackend B,
bool iVarOne = false>
19 auto grad = u_grad[iCell];
21 Eigen::Map<Eigen::Matrix<real, 3, DynamicSize>> gradResult(local_buf, 3, grad.cols());
22 if constexpr (iVarOne)
23 gradResultOne.setZero();
30 for (
rowsize ic2f = 0; ic2f < mesh.cell2face.RowSize(iCell); ic2f++)
32 index iFace = mesh.cell2face(iCell, ic2f);
33 index iCellOther = mesh.CellFaceOther(iCell, iFace);
34 rowsize if2c = mesh.CellIsFaceBack(iCell, iFace) ? 0 : 1;
40 auto uOther = u[iCellOther];
43 if constexpr (B == DeviceBackend::CUDA)
47 if constexpr (iVarOne)
48 for (
int i = 0; i < 3; i++)
49 gradResultOne(i) += norm(i) * (uOther(iVar) - uI(iVar));
51 for (
int iV = 0; iV < grad.cols(); iV++)
56 for (
int i = 0; i < 3; i++)
57 gradResult(i, iV) += norm(i) * (uOther(iV) - uI(iV));
65 if constexpr (iVarOne)
66 gradResultOne += norm * (uOther(iVar) - uI(iVar));
70 gradResult.noalias() += norm * (uOther - uI).transpose();
73 if constexpr (iVarOne)
77 for (
int i = 0; i < 3; i++)
78 grad(i, iVar) = gradResultOne(i);
87 template <DeviceBackend B>
93 template <DeviceBackend B>
115 template <DeviceBackend B,
int nVarsFixed,
bool iVarOne = false>
122 static_assert(nVarsFixed > 0);
123 using namespace Geom;
124 auto grad = u_grad[iCell];
125 tPoint gradResultOne;
126 Eigen::Matrix<real, 3, nVarsFixed> gradResult;
127 if constexpr (iVarOne)
128 gradResultOne.setZero();
130 gradResult.setZero();
131 auto &mesh = fv.
mesh;
134 for (
rowsize ic2f = 0; ic2f < mesh.cell2face.RowSize(iCell); ic2f++)
136 index iFace = mesh.cell2face(iCell, ic2f);
137 index iCellOther = mesh.CellFaceOther(iCell, iFace);
138 rowsize if2c = mesh.CellIsFaceBack(iCell, iFace) ? 0 : 1;
144 auto uOther = u[iCellOther];
147 if constexpr (B == DeviceBackend::CUDA)
149 if constexpr (iVarOne)
150 for (
int i = 0; i < 3; i++)
151 gradResultOne(i) += norm(i) * (uOther(iVar) - uI(iVar));
153 for (
int iV = 0; iV < grad.cols(); iV++)
155 for (
int i = 0; i < 3; i++)
156 gradResult(i, iV) += norm(i) * (uOther(iV) - uI(iV));
164 if constexpr (iVarOne)
165 gradResultOne.noalias() += norm * (uOther(iVar) - uI(iVar));
167 gradResult.noalias() += norm * (uOther - uI).transpose();
170 if constexpr (iVarOne)
174 for (
int i = 0; i < 3; i++)
175 grad(i, iVar) = gradResultOne(i);
184 template <DeviceBackend B,
int nVarsFixed>
188 template <
int nVarsFixed>
191 static constexpr auto B = DeviceBackend::CUDA;
200 template <
int nVarsFixed>
211 template <DeviceBackend B,
int nVarsFixed>
219 auto u_view = u.template deviceView<B>();
220 auto u_grad_view = u_grad.template deviceView<B>();
234 template <DeviceBackend B,
int nVarsFixed,
bool iVarOne = false>
241 static_assert(nVarsFixed > 0);
242 using namespace Geom;
243 tPoint gradResultOne;
244 Eigen::Matrix<real, 3, nVarsFixed> gradResult;
245 if constexpr (iVarOne)
246 gradResultOne.setZero();
248 gradResult.setZero();
249 auto &mesh = fv.
mesh;
252 for (
rowsize ic2f = 0; ic2f < mesh.cell2face.RowSize(iCell); ic2f++)
254 index iFace = mesh.cell2face(iCell, ic2f);
255 index iCellOther = mesh.CellFaceOther(iCell, iFace);
256 rowsize if2c = mesh.CellIsFaceBack(iCell, iFace) ? 0 : 1;
263 if constexpr (iVarOne)
264 for (
int i = 0; i < 3; i++)
265 gradResultOne(i) += norm(i) * (u[iVar][iCellOther](0) - u[iVar][iCell](0));
267 for (
int iV = 0; iV < nVarsFixed; iV++)
269 for (
int i = 0; i < 3; i++)
270 gradResult(i, iV) += norm(i) * (u[iV][iCellOther](0) - u[iV][iCell](0));
275 if constexpr (iVarOne)
279 for (
int i = 0; i < 3; i++)
280 u_grad[iVar][iCell](i, 0) = gradResultOne(i);
285 for (
int iV = 0; iV < nVarsFixed; iV++)
286 for (
int i = 0; i < 3; i++)
287 u_grad[iV][iCell](i) = gradResult(i, iV);
291 template <DeviceBackend B,
int nVarsFixed>
294 template <
int nVarsFixed>
297 static constexpr auto B = DeviceBackend::CUDA;
306 template <
int nVarsFixed>
317 template <DeviceBackend B,
int nVarsFixed>
320 std::array<
tUDof<1>, nVarsFixed> &u,
327 std::array<tUDof<1>::t_deviceView<B>, nVarsFixed> u_view;
328 for (
int i = 0; i < nVarsFixed; i++)
329 u_view[i] = u[i].
template deviceView<B>();
330 std::array<tUGrad<1, 3>::t_deviceView<B>, nVarsFixed> u_grad_view;
331 for (
int i = 0; i < nVarsFixed; i++)
332 u_grad_view[i] = u_grad[i].
template deviceView<B>();
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_DEVICE_CALLABLE
Device memory abstraction layer with backend-specific storage and factory creation.
Assertion / error-handling macros and supporting helper functions.
#define DNDS_HD_assert(cond)
Host-only expansion of DNDS_HD_assert (equivalent to DNDS_assert).
JSON-to-Eigen conversion utilities and nlohmann_json helper macros.
Mutable device view of an ArrayDof father/son pair.
Primary solver state container: an ArrayEigenMatrix pair with MPI-collective vector-space operations.
t_deviceView< B > deviceView()
Build a mutable device view (wraps the base-class implementation).
Geom::UnstructuredMeshDeviceView< B > mesh
DNDS_DEVICE_CALLABLE real GetFaceArea(index iFace)
DNDS_DEVICE_CALLABLE real GetCellVol(index iCell)
DNDS_DEVICE_CALLABLE Geom::tPoint GetFaceNormFromCell(index iFace, index iCell, rowsize if2c, int iG)
t_deviceView< B > deviceView()
DNDS_DEVICE_CALLABLE void finiteVolumeCellOpTest_SOA_ver0(FiniteVolume::t_deviceView< B > &fv, std::array< tUDof< 1 >::t_deviceView< B >, nVarsFixed > &u, std::array< tUGrad< 1, 3 >::t_deviceView< B >, nVarsFixed > &u_grad, index iCell, int iVar=UnInitRowsize)
void finiteVolumeCellOpTest_Fixed_main(FiniteVolume &fv, tUDof< nVarsFixed > &u, tUGrad< nVarsFixed, 3 > &u_grad, int nIter, const t_jsonconfig &settings)
DNDS_DEVICE_CALLABLE void finiteVolumeCellOpTest_Fixed(FiniteVolume::t_deviceView< B > &fv, typename tUDof< nVarsFixed >::template t_deviceView< B > &u, typename tUGrad< nVarsFixed, 3 >::template t_deviceView< B > &u_grad, index iCell, int iVar=UnInitRowsize)
DNDS_DEVICE_CALLABLE void finiteVolumeCellOpTest(FiniteVolume::t_deviceView< B > &fv, tUDof< DynamicSize >::t_deviceView< B > &u, tUGrad< DynamicSize, 3 >::t_deviceView< B > &u_grad, index iCell, real *local_buf, int iVar=UnInitRowsize)
void finiteVolumeCellOpTest_main(FiniteVolume &fv, tUDof< DynamicSize > &u, tUGrad< DynamicSize, 3 > &u_grad, int nIter, const t_jsonconfig &settings)
void finiteVolumeCellOpTest_run(FiniteVolume::t_deviceView< B > &fv, tUDof< DynamicSize >::t_deviceView< B > &u, tUGrad< DynamicSize, 3 >::t_deviceView< B > &u_grad, int nIter, const t_jsonconfig &settings)
void finiteVolumeCellOpTest_run< B >(FiniteVolume::t_deviceView< B > &fv, tUDof< DynamicSize >::t_deviceView< B > &u, tUGrad< DynamicSize, 3 >::t_deviceView< B > &u_grad, int nIter, const t_jsonconfig &settings)
void finiteVolumeCellOpTest_SOA_ver0_main(FiniteVolume &fv, std::array< tUDof< 1 >, nVarsFixed > &u, std::array< tUGrad< 1, 3 >, nVarsFixed > &u_grad, int nIter, const t_jsonconfig &settings)
DeviceBackend
Enumerates the backends a DeviceStorage / Array can live on.
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
nlohmann::ordered_json t_jsonconfig
Project-wide JSON type alias: nlohmann/json with ordered keys.
DNDS_CONSTANT const rowsize UnInitRowsize
Sentinel "not initialised" rowsize value (= INT32_MIN).
void run(FiniteVolume::t_deviceView< B > &fv, typename tUDof< nVarsFixed >::template t_deviceView< B > &u, typename tUGrad< nVarsFixed, 3 >::template t_deviceView< B > &u_grad, int nIter, const t_jsonconfig &settings)
void run(FiniteVolume::t_deviceView< B > &fv, std::array< tUDof< 1 >::t_deviceView< B >, nVarsFixed > &u, std::array< tUGrad< 1, 3 >::t_deviceView< B >, nVarsFixed > &u_grad, int nIter, const t_jsonconfig &settings)