DNDSR 0.1.0.dev1+gcd065ad
Distributed Numeric Data Structure for CFV
Loading...
Searching...
No Matches
FiniteVolume_DeviceView.hpp
Go to the documentation of this file.
1#pragma once
3#include "VRDefines.hpp"
5
6namespace DNDS::CFV
7{
8 template <DeviceBackend B>
10 {
11 public:
13
15
16 static_assert(std::is_trivially_copyable_v<FiniteVolumeSettings>);
17 static_assert(std::is_trivially_copyable_v<Geom::UnstructuredMeshDeviceView<B>>);
18
20 {
21 return mesh.dim;
22 }
23
24 protected:
44
45 static_assert(std::is_trivially_copyable_v<tScalarPair::t_deviceView<B>>);
46 static_assert(std::is_trivially_copyable_v<tRecAtrPair::t_deviceView<B>>);
47 static_assert(std::is_trivially_copyable_v<tCoeffPair::t_deviceView<B>>);
48 static_assert(std::is_trivially_copyable_v<t3VecsPair::t_deviceView<B>>);
49 static_assert(std::is_trivially_copyable_v<t3VecPair::t_deviceView<B>>);
50 static_assert(std::is_trivially_copyable_v<t3MatPair::t_deviceView<B>>);
51
52 public:
54
55 template <class TMain>
82
84 DNDS_DEVICE_CALLABLE real GetFaceArea(index iFace) { return faceArea[iFace][0]; }
86 {
87 return cellSmoothScale(iCell, 0);
88 }
90
93
95 {
96 auto e = mesh.GetFaceElement(iFace);
97 return Geom::Elem::Quadrature{e, faceAtr(iFace, 0).intOrder};
98 }
99
101 {
102 auto e = mesh.GetFaceElement(iFace);
103 return Geom::Elem::Quadrature{e, 1};
104 }
105
106 DNDS_DEVICE_CALLABLE real GetFaceParamArea(index iFace) const { return std::get<1>(this->GetFaceQuadO1(iFace).GetQuadraturePointInfo(0)); }
107
109 {
110 auto e = mesh.GetCellElement(iCell);
111 return Geom::Elem::Quadrature{e, cellAtr(iCell, 0).intOrder};
112 }
113
115 {
116 auto e = mesh.GetCellElement(iCell);
117 return Geom::Elem::Quadrature{e, 1};
118 }
119
120 DNDS_DEVICE_CALLABLE real GetCellParamVol(index iCell) const { return std::get<1>(this->GetCellQuadO1(iCell).GetQuadraturePointInfo(0)); }
121
123
125 {
126 return mesh.CellIsFaceBack(iCell, iFace);
127 }
128
130 {
131 return mesh.CellFaceOther(iCell, iFace);
132 }
133
135 {
136 if (iG >= 0)
137 return faceUnitNorm(iFace, iG);
138 else
139 return faceMeanNorm[iFace];
140 }
141
143 {
144 if (!mesh.isPeriodic)
145 return GetFaceNorm(iFace, iG);
146 auto faceID = mesh.faceElemInfo[iFace]->zone;
147 if (!Geom::FaceIDIsPeriodic(faceID))
148 return GetFaceNorm(iFace, iG);
149 if (if2c < 0)
150 if2c = CellIsFaceBack(iCell, iFace) ? 0 : 1;
151 if (if2c == 1 && Geom::FaceIDIsPeriodicMain(faceID))
152 return mesh.periodicInfo.TransVector(GetFaceNorm(iFace, iG), faceID);
153 if (if2c == 1 && Geom::FaceIDIsPeriodicDonor(faceID))
154 return mesh.periodicInfo.TransVectorBack(GetFaceNorm(iFace, iG), faceID);
155 return GetFaceNorm(iFace, iG);
156 }
157
159 {
160 if (iG >= 0)
161 return faceIntPPhysics(iFace, iG);
162 else
163 return faceCent[iFace];
164 }
165
167 {
168 if (!mesh.isPeriodic)
169 return GetFaceQuadraturePPhys(iFace, iG);
170 auto faceID = mesh.faceElemInfo[iFace]->zone;
171 if (!Geom::FaceIDIsPeriodic(faceID))
172 return GetFaceQuadraturePPhys(iFace, iG);
173 if (if2c < 0)
174 if2c = CellIsFaceBack(iCell, iFace) ? 0 : 1;
175 if (if2c == 1 && Geom ::FaceIDIsPeriodicMain(faceID)) // I am donor
176 {
177 // std::cout << iFace <<" " << iCell << " " <<if2c << std::endl;
178 // std::cout << GetFaceQuadraturePPhys(iFace, iG).transpose() << std::endl;
179 // std::cout << mesh->periodicInfo.TransCoord(GetFaceQuadraturePPhys(iFace, iG), faceID).transpose() << std::endl;
180 // std::abort();
181 return mesh.periodicInfo.TransCoord(GetFaceQuadraturePPhys(iFace, iG), faceID);
182 }
183 if (if2c == 1 && Geom::FaceIDIsPeriodicDonor(faceID)) // I am main
184 return mesh.periodicInfo.TransCoordBack(GetFaceQuadraturePPhys(iFace, iG), faceID);
185 return GetFaceQuadraturePPhys(iFace, iG);
186 }
187
189 {
190 if (!mesh.isPeriodic)
191 return pnt;
192 auto faceID = mesh.faceElemInfo[iFace]->zone;
193 if (!Geom::FaceIDIsPeriodic(faceID))
194 return pnt;
195 if (if2c < 0)
196 if2c = CellIsFaceBack(iCell, iFace) ? 0 : 1;
197 if (if2c == 1 && Geom ::FaceIDIsPeriodicMain(faceID)) // I am donor
198 {
199 // std::cout << iFace <<" " << iCell << " " <<if2c << std::endl;
200 // std::cout << pnt.transpose() << std::endl;
201 // std::cout << mesh->periodicInfo.TransCoord(pnt, faceID).transpose() << std::endl;
202 // std::abort();
203 return mesh.periodicInfo.TransCoord(pnt, faceID);
204 }
205 if (if2c == 1 && Geom::FaceIDIsPeriodicDonor(faceID)) // I am main
206 return mesh.periodicInfo.TransCoordBack(pnt, faceID);
207 return pnt;
208 }
209
211 index iCell, index iCellOther,
212 index iFace)
213 {
214 if (!mesh.isPeriodic)
215 return GetCellBary(iCellOther);
216
217 auto faceID = mesh.faceElemInfo[iFace]->zone;
218 if (!Geom::FaceIDIsPeriodic(faceID))
219 return GetCellBary(iCellOther);
220 rowsize if2c = CellIsFaceBack(iCell, iFace) ? 0 : 1;
221 if ((if2c == 1 && Geom::FaceIDIsPeriodicMain(faceID)) ||
222 (if2c == 0 && Geom::FaceIDIsPeriodicDonor(faceID))) // I am donor
223 return mesh.periodicInfo.TransCoord(GetCellBary(iCellOther), faceID);
224 if ((if2c == 1 && Geom::FaceIDIsPeriodicDonor(faceID)) ||
225 (if2c == 0 && Geom::FaceIDIsPeriodicMain(faceID))) // I am main
226 return mesh.periodicInfo.TransCoordBack(GetCellBary(iCellOther), faceID);
227 return GetCellBary(iCellOther);
228 }
229
231 index iCell, index iCellOther,
232 index iFace, const Geom::tPoint &pnt)
233 {
234 if (!mesh.isPeriodic)
235 return pnt;
236
237 auto faceID = mesh.faceElemInfo[iFace]->zone;
238 if (!Geom::FaceIDIsPeriodic(faceID))
239 return pnt;
240 rowsize if2c = CellIsFaceBack(iCell, iFace) ? 0 : 1;
241 if ((if2c == 1 && Geom::FaceIDIsPeriodicMain(faceID)) ||
242 (if2c == 0 && Geom::FaceIDIsPeriodicDonor(faceID))) // I am donor
243 return mesh.periodicInfo.TransCoord(pnt, faceID);
244 if ((if2c == 1 && Geom::FaceIDIsPeriodicDonor(faceID)) ||
245 (if2c == 0 && Geom::FaceIDIsPeriodicMain(faceID))) // I am main
246 return mesh.periodicInfo.TransCoordBack(pnt, faceID);
247 return pnt;
248 }
249
251 index iCell, index iCellOther,
252 index iFace)
253 { // structure copy of GetOtherCellBaryFromCell
254 if (!mesh.isPeriodic)
255 return cellInertia[iCellOther];
256
257 auto faceID = mesh.faceElemInfo[iFace]->zone;
258 if (!Geom::FaceIDIsPeriodic(faceID))
259 return cellInertia[iCellOther];
260 rowsize if2c = CellIsFaceBack(iCell, iFace) ? 0 : 1;
261 if ((if2c == 1 && Geom::FaceIDIsPeriodicMain(faceID)) ||
262 (if2c == 0 && Geom::FaceIDIsPeriodicDonor(faceID))) // I am donor
263 return mesh.periodicInfo.template TransMat<3>(cellInertia[iCellOther], faceID);
264 if ((if2c == 1 && Geom::FaceIDIsPeriodicDonor(faceID)) ||
265 (if2c == 0 && Geom::FaceIDIsPeriodicMain(faceID))) // I am main
266 return mesh.periodicInfo.template TransMatBack<3>(cellInertia[iCellOther], faceID);
267 return cellInertia[iCellOther];
268 }
269
271 {
272 if (iG >= 0)
273 return cellIntPPhysics(iCell, iG);
274 else
275 return cellCent[iCell];
276 }
277
279 {
280 auto hb = cellMajorHBox[iCell];
281 real ret = std::max(hb[0], hb[1]);
282 if (this->getDim() == 3)
283 ret = std::max(ret, hb[2]);
284 return ret * 2;
285 }
286 };
287}
#define DNDS_DEVICE_CALLABLE
Definition Defines.hpp:76
#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE_NO_EMPTY_CTOR(T, T_Self)
Definition Defines.hpp:91
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
Definition Errors.hpp:108
#define DNDS_COPY_MEMBER(obj, member)
#define DNDS_COPY_MEMBER_VIEW(obj, member)
DNDS_DEVICE_CALLABLE Geom::tPoint GetCellBary(index iCell)
DNDS_DEVICE_CALLABLE Geom::Elem::Quadrature GetFaceQuad(index iFace) const
t3VecsPair::t_deviceView< B > faceIntPPhysics
t3MatPair::t_deviceView< B > cellInertia
DNDS_DEVICE_CALLABLE real GetFaceParamArea(index iFace) const
FiniteVolumeDeviceView(TMain &fv, index placeholder)
DNDS_DEVICE_CALLABLE Geom::tPoint GetOtherCellBaryFromCell(index iCell, index iCellOther, index iFace)
DNDS_DEVICE_CALLABLE real GetCellJacobiDet(index iCell, rowsize iG) const
DNDS_DEVICE_CALLABLE Geom::tPoint GetOtherCellPointFromCell(index iCell, index iCellOther, index iFace, const Geom::tPoint &pnt)
DNDS_DEVICE_CALLABLE Geom::Elem::Quadrature GetFaceQuadO1(index iFace) const
t3MatPair::t_deviceView< B > cellMajorCoord
DNDS_DEVICE_CALLABLE Geom::tPoint GetFacePointFromCell(index iFace, index iCell, rowsize if2c, const Geom::tPoint &pnt)
Geom::UnstructuredMeshDeviceView< B > mesh
DNDS_DEVICE_CALLABLE Geom::tPoint GetFaceQuadraturePPhys(index iFace, int iG)
DNDS_DEVICE_CALLABLE Geom::tPoint GetFaceQuadraturePPhysFromCell(index iFace, index iCell, rowsize if2c, int iG)
t3VecPair::t_deviceView< B > cellAlignedHBox
tCoeffPair::t_deviceView< B > cellIntJacobiDet
DNDS_DEVICE_CALLABLE Geom::tPoint GetFaceNorm(index iFace, int iG) const
DNDS_DEVICE_CALLABLE real GetGlobalVol() const
DNDS_DEVICE_CALLABLE Geom::Elem::Quadrature GetCellQuadO1(index iCell) const
DNDS_DEVICE_CALLABLE real GetFaceArea(index iFace)
t3VecPair::t_deviceView< B > cellMajorHBox
DNDS_DEVICE_CALLABLE real GetCellVol(index iCell)
tScalarPair::t_deviceView< B > faceArea
DNDS_DEVICE_CALLABLE real GetCellMaxLenScale(index iCell)
DNDS_DEVICE_CALLABLE bool CellIsFaceBack(index iCell, index iFace) const
DNDS_DEVICE_CALLABLE real GetCellSmoothScaleRatio(index iCell) const
t3VecPair::t_deviceView< B > faceMeanNorm
DNDS_DEVICE_CALLABLE Geom::tGPoint GetOtherCellInertiaFromCell(index iCell, index iCellOther, index iFace)
tRecAtrPair::t_deviceView< B > faceAtr
tScalarPair::t_deviceView< B > volumeLocal
DNDS_DEVICE_CALLABLE index CellFaceOther(index iCell, index iFace) const
DNDS_DEVICE_CALLABLE Geom::tPoint GetFaceNormFromCell(index iFace, index iCell, rowsize if2c, int iG)
DNDS_DEVICE_CALLABLE real GetCellParamVol(index iCell) const
t3VecsPair::t_deviceView< B > cellIntPPhysics
DNDS_DEVICE_CALLABLE Geom::tPoint GetCellQuadraturePPhys(index iCell, int iG)
DNDS_DEVICE_CALLABLE Geom::Elem::Quadrature GetCellQuad(index iCell) const
tRecAtrPair::t_deviceView< B > cellAtr
DNDS_DEVICE_CALLABLE real GetFaceJacobiDet(index iFace, rowsize iG) const
t3VecsPair::t_deviceView< B > faceUnitNorm
tCoeffPair::t_deviceView< B > faceIntJacobiDet
tScalarPair::t_deviceView< B > cellSmoothScale
Eigen::Vector3d tPoint
Definition Geometric.hpp:9
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodic(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicDonor(t_index id)
DNDS_DEVICE_CALLABLE bool FaceIDIsPeriodicMain(t_index id)
Eigen::Matrix3d tGPoint
Definition Geometric.hpp:11
DNDS_CONSTANT const index UnInitIndex
Sentinel "not initialised" index value (= INT64_MIN).
Definition Defines.hpp:176
int32_t rowsize
Row-width / per-row element-count type (signed 32-bit).
Definition Defines.hpp:109
int64_t index
Global row / DOF index type (signed 64-bit; handles multi-billion-cell meshes).
Definition Defines.hpp:107
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Definition Defines.hpp:105
Mutable device view onto an ArrayPair (for CUDA kernels).
ArrayPairDeviceView< B, DNDS::ParArray< RecAtr, 1 > > t_deviceView
Device-view template alias: t_deviceView<DeviceBackend::CUDA> gives the mutable CUDA view type for th...
A means to translate nlohmann json into c++ primitive data types and back; and stores then during com...