VM2D 1.14
Vortex methods for 2D flows simulation
Loading...
Searching...
No Matches
cudaTreeInfo.h
Go to the documentation of this file.
1/*--------------------------------*- VM2D -*-----------------*---------------*\
2| ## ## ## ## #### ##### | | Version 1.14 |
3| ## ## ### ### ## ## ## ## | VM2D: Vortex Method | 2026/03/06 |
4| ## ## ## # ## ## ## ## | for 2D Flow Simulation *----------------*
5| #### ## ## ## ## ## | Open Source Code |
6| ## ## ## ###### ##### | https://www.github.com/vortexmethods/VM2D |
7| |
8| Copyright (C) 2017-2026 I. Marchevsky, K. Sokol, E. Ryatina, A. Kolganova |
9*-----------------------------------------------------------------------------*
10| File name: cudaTreeInfo.h |
11| Info: Source code of VM2D |
12| |
13| This file is part of VM2D. |
14| VM2D is free software: you can redistribute it and/or modify it |
15| under the terms of the GNU General Public License as published by |
16| the Free Software Foundation, either version 3 of the License, or |
17| (at your option) any later version. |
18| |
19| VM2D is distributed in the hope that it will be useful, but WITHOUT |
20| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
21| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
22| for more details. |
23| |
24| You should have received a copy of the GNU General Public License |
25| along with VM2D. If not, see <http://www.gnu.org/licenses/>. |
26\*---------------------------------------------------------------------------*/
27
39#ifndef CUDATREEINFO_H
40#define CUDATREEINFO_H
41
42#ifdef USE_CUDA
43
44#include <cuda_runtime.h>
45#include <device_launch_parameters.h>
46
47#include "Vortex2D.h"
48#include "Gpudefs.h"
49
50namespace BHcu
51{
63 struct infoForMatVecMul
64 {
65 std::vector<int> nClosePanels;
66 std::vector<int> nFarCells;
67
68 std::vector<int> closePrefixSum;
69 std::vector<int> farPrefixSum;
70
71 Point2D* i00D;
72 Point2D* i01D;
73 Point2D* i10D;
74 Point2D* i11D;
75
76 int* nClosePanelsD;
77 int* nFarCellsD;
78
79 int* closeCellsIdxD;
80 int* farCellsIdxD;
81
82 int* closePrefixSumD;
83 int* farPrefixSumD;
84
85 infoForMatVecMul()
86 {
87 i00D = i01D = i10D = i11D = nullptr;//
88 //nClosePanelsD = nullptr;
89 //nFarCellsD = nullptr;
90 closeCellsIdxD = nullptr;//
91 farCellsIdxD = nullptr; //
92 //closePrefixSumD = nullptr;
93 //farPrefixSumD = nullptr;
94 }
95
96 void ReleaseGpuMemory();
97 };
98
99
112 class CudaTreeInfo
113 {
114
115 public:
116 int nObject;
117 int nNode;
118
119 bool duplicateObj;
120 double* objectD;
121
122 tree_T treeType;
123 object_T objectType;
124
125 scheme_T schemeType;
126
127 int sizeOfElement;
128
129 int* massD; //массы (единица для точечного вихря, число вихрей для ячейки)
130
131 Point2D* maxrD, * minrD; //габаритный прямоугольник
132 Point2D* momsD; //мультипольные моменты всех ячеек; хранятся в виде <mom_0x, mom_0y=0, mom_1x, mom_1y, ..., mom_px, mom_py>, <для второй ячейки> ...
133 Point2D* ED; //к-ты локальных разложений
134
135 //For Morton tree
136 int* mortonCodesKeyUnsortD;
137 int* mortonCodesKeyD;
138
139 int* mortonCodesIdxUnsortD; //0 1 2 3 ... nbodies-1
140 int* mortonCodesIdxD;
141
142 int* levelUnsortD;
143 int* levelSortD;
144
145 int* indexUnsortD; //0 1 2 3 ... nbodies-2
146 int* indexSortD;
147 int* indexSortTD;
148
149 Point2D* centerD; //Положения внутренних узлов в дерева Карраса
150 Point4D* lowerupperD; //Левый нижний и правый верхний углы ячейки
151 Point4D* gabForLeavesD; //Левый нижний и правый верхний углы листа
152
153 int* parentD; //Номер ячейки-родителя
154 long long* childD; //Потомки внутренних ячеек (в одной ячейке храним сразу два целых числа)
155 long long* rangeD; //Диапазон частиц во внутренней ячейке (в одной ячейке храним сразу два целых числа)
156
157 void* sortObjectsBufferD;
158 int sortObjectsBufferSizeInBytes;
159
160 void* sortInternalCellsBufferD;
161 int sortInternalCellsBufferSizeInBytes;
162
163 const int nBlock;
164 int reservedMemorySizeItems;
165
166 infoForMatVecMul matVecMulInfo;
167
168 CudaTreeInfo(int nBlock_, tree_T treeType_, object_T objectType_, scheme_T schemeType_, bool duplicateObj_);
169 ~CudaTreeInfo();
170
171 void Update(int nObject_, double* objectD_);
172 void UpdatePanelGeometry(int nObject_, double4* gabForLeavesD_);
173
174 void UpdatePanelFreeVortexIntensity(const double* dev_ptr_freeVortexSheet, const double* dev_ptr_freeVortexSheetLin);//функция нулит attached vortex sheet
175 void UpdatePanelAttachedVortexIntensity(const double* dev_ptr_attachedVortexSheet, const double* dev_ptr_attachedVortexSheetLin);//функция нулит free vortex sheet
176 void UpdatePanelAttachedSourceIntensity(const double* dev_ptr_attachedSourceSheet, const double* dev_ptr_attachedSourceSheetLin);
177 void UpdatePanelFreeAndAttachedVortexIntensity(const double* dev_ptr_freeVortexSheet, const double* dev_ptr_freeVortexSheetLin, const double* dev_ptr_attachedVortexSheet, const double* dev_ptr_attachedVortexSheetLin);
178
179 float MemoryAllocateForGMRES(bool firstStep, double itheta2);
180 void MemoryFreeForGMRES();
181
182 void MemoryAllocate(int nCudaObject);
183
184 bool IsInitialized() const;
185
186 float Build();
187 float UpwardTraversal(int order);
188
189 template <int NUMBER_OF_THREADS>
190 float DownwardTraversalVorticesToPoints(CudaTreeInfo& cntrTree, Point2D* velD, double* epsastD, double theta, int order, bool calcRadius);
191
192 float DownwardTraversalVorticesToPanels(CudaTreeInfo& cntrTree, double* rhsD, double* rhsLinD, double theta, int order);
193 float DownwardTraversalPanelsToPoints(CudaTreeInfo& cntrTree, Point2D* velD, double theta, int order);
194 float DownwardTraversalGMRES(double* resD, double* resLinD, double itheta2, int order, int iter, bool memAlloc);
195
196 float I1I2CalculationWrapper(double minRd, double* __restrict I1D, Point2D* __restrict I2D, double* __restrict epsastD);
197 float I0I3CalculationWrapper(double minRd, float* __restrict I0D, Point2Df* __restrict I3D, double* __restrict epsastD, const double* __restrict meanEpsD, int nPan, double* __restrict panD, double* __restrict visstrD);
198 void RadixSortMortonCodes(int beginBit = 0, int endBit = 2 * codeLength);
199 void RadixSortInternalCells(int beginBit = 0, int endBit = 2 * codeLength);
200 };
201
202}
203
204#endif
205
206#endif
Описание констант и параметров для взаимодействия с графическим ускорителем
object_T
Definition Gpudefs.h:153
#define codeLength
Definition Gpudefs.h:101
tree_T
Definition Gpudefs.h:146
scheme_T
Definition Gpudefs.h:158
Заголовочный файл с описанием класса Vortex2D.