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#include <cuda.h>
47
48#include "Vortex2D.h"
49#include "Gpudefs.h"
50
51namespace BHcu
52{
64 struct infoForMatVecMul
65 {
66 std::vector<int> nClosePanels;
67 std::vector<int> nFarCells;
68
69 std::vector<int> closePrefixSum;
70 std::vector<int> farPrefixSum;
71
72 Point2D* i00D;
73 Point2D* i01D;
74 Point2D* i10D;
75 Point2D* i11D;
76
77 int* nClosePanelsD;
78 int* nFarCellsD;
79
80 int* closeCellsIdxD;
81 int* farCellsIdxD;
82
83 int* closePrefixSumD;
84 int* farPrefixSumD;
85 };
86
87
100 class CudaTreeInfo
101 {
102
103 public:
104 int nObject;
105 int nNode;
106
107 bool duplicateObj;
108 double* objectD;
109
110 tree_T treeType;
111 object_T objectType;
112
113 scheme_T schemeType;
114
115 int sizeOfElement;
116 int offsetOfPointInElement;
117
118 int* massD; //массы (единица для точечного вихря, число вихрей для ячейки)
119
120 Point2D* maxrD, * minrD; //габаритный прямоугольник
121 Point2D* momsD; //мультипольные моменты всех ячеек; хранятся в виде <mom_0x, mom_0y=0, mom_1x, mom_1y, ..., mom_px, mom_py>, <для второй ячейки> ...
122 Point2D* ED; //к-ты локальных разложений
123
124 //For Morton tree
125 int* mortonCodesKeyUnsortD;
126 int* mortonCodesKeyD;
127
128 int* mortonCodesIdxUnsortD; //0 1 2 3 ... nbodies-1
129 int* mortonCodesIdxD;
130
131 int* levelUnsortD;
132 int* levelSortD;
133
134 int* indexUnsortD; //0 1 2 3 ... nbodies-2
135 int* indexSortD;
136 int* indexSortTD;
137
138 Point2D* centerD; //Положения внутренних узлов в дерева Карраса
139 Point4D* lowerupperD; //Левый нижний и правый верхний углы ячейки
140 Point4D* gabForLeavesD; //Левый нижний и правый верхний углы листа
141
142 int* parentD; //Номер ячейки-родителя
143 long long* childD; //Потомки внутренних ячеек (в одной ячейке храним сразу два целых числа)
144 long long* rangeD; //Диапазон частиц во внутренней ячейке (в одной ячейке храним сразу два целых числа)
145
146 void* sortObjectsBufferD;
147 int sortObjectsBufferSizeInBytes;
148
149 void* sortInternalCellsBufferD;
150 int sortInternalCellsBufferSizeInBytes;
151
152 const int nBlock;
153 int reservedMemorySizeItems;
154
155 infoForMatVecMul matVecMulInfo;
156
157 CudaTreeInfo(int nBlock_, tree_T treeType_, object_T objectType_, scheme_T schemeType_, bool duplicateObj_);
158 ~CudaTreeInfo();
159
160 void Update(int nObject_, double* objectD_, double eps);
161 void UpdatePanelGeometry(int nObject_, double4* gabForLeavesD_);
162
163 void UpdatePanelFreeVortexIntensity(const double* dev_ptr_freeVortexSheet, const double* dev_ptr_freeVortexSheetLin);//функция нулит attached vortex sheet
164 void UpdatePanelAttachedVortexIntensity(const double* dev_ptr_attachedVortexSheet, const double* dev_ptr_attachedVortexSheetLin);//функция нулит free vortex sheet
165 void UpdatePanelAttachedSourceIntensity(const double* dev_ptr_attachedSourceSheet, const double* dev_ptr_attachedSourceSheetLin);
166 void UpdatePanelFreeAndAttachedVortexIntensity(const double* dev_ptr_freeVortexSheet, const double* dev_ptr_freeVortexSheetLin, const double* dev_ptr_attachedVortexSheet, const double* dev_ptr_attachedVortexSheetLin);
167
168 void MemoryAllocateForGMRES();
169 void MemoryFreeForGMRES();
170
171 void MemoryAllocate(int nCudaObject);
172
173 bool IsInitialized() const;
174
175 float Build();
176 float UpwardTraversal(int order);
177
178 float DownwardTraversalVorticesToPoints(CudaTreeInfo& cntrTree, Point2D* velD, double* epsastD, double eps2, double theta, int order, bool calcRadius);
179 float DownwardTraversalVorticesToPanels(CudaTreeInfo& cntrTree, double* rhsD, double* rhsLinD, double theta, int order);
180 float DownwardTraversalPanelsToPoints(CudaTreeInfo& cntrTree, Point2D* velD, double eps2, double theta, int order);
181 float DownwardTraversalGMRES(double* resD, double* resLinD, double theta, int order, int iter);
182
183 float I1I2CalculationWrapper(double minRd, double* __restrict I1D, Point2D* __restrict I2D, double* __restrict epsastD);
184 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);
185 void RadixSortMortonCodes(int beginBit = 0, int endBit = 2 * codeLength);
186 void RadixSortInternalCells(int beginBit = 0, int endBit = 2 * codeLength);
187 };
188
189}
190
191#endif
192
193#endif
Описание констант и параметров для взаимодействия с графическим ускорителем
object_T
Definition Gpudefs.h:146
#define codeLength
Definition Gpudefs.h:97
tree_T
Definition Gpudefs.h:139
scheme_T
Definition Gpudefs.h:151
Заголовочный файл с описанием класса Vortex2D.