VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
ActuatorFarmInlines.h
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
33//======================================================================================
34
35#ifndef ACTUATOR_FARM_INLINES
36#define ACTUATOR_FARM_INLINES
37
38#include <basics/DataTypes.h>
40#include "Axis.h"
41
43
44namespace vf::gpu {
45
46
52
53constexpr uint calcPointIndexInBladeArrays(uint bladePoint, uint numberOfPointsPerBlade, uint blade, uint numberOfBlades, uint turbine)
54{
55 // see https://git.rz.tu-bs.de/irmb/VirtualFluids_dev/-/merge_requests/248 for visualization
56 return bladePoint + numberOfPointsPerBlade * (blade + numberOfBlades * turbine);
57}
58
59constexpr uint calcPointIndexInBladeArrays(const TurbinePointIndex &turbineNodeIndex, uint numberOfPointsPerBlade, uint numberOfBlades)
60{
61 return calcPointIndexInBladeArrays(turbineNodeIndex.bladePoint, numberOfPointsPerBlade, turbineNodeIndex.blade, numberOfBlades, turbineNodeIndex.turbine);
62}
63
64constexpr void calcTurbineBladeAndBladePoint(uint node, uint &bladePoint, uint numberOfPointsPerBlade, uint &blade, uint numberOfBlades, uint &turbine)
65{
66 // see https://git.rz.tu-bs.de/irmb/VirtualFluids_dev/-/merge_requests/248 for visualization
67 turbine = node / (numberOfPointsPerBlade * numberOfBlades);
68 const uint x_off = turbine * numberOfPointsPerBlade * numberOfBlades;
69 blade = (node - x_off) / numberOfPointsPerBlade;
70 const uint y_off = numberOfPointsPerBlade * blade + x_off;
71 bladePoint = node - y_off;
72}
73
74constexpr TurbinePointIndex calcTurbineBladeAndBladePoint(uint node, uint numberOfPointsPerBlade, uint numberOfBlades)
75{
76 uint turbine = 0;
77 uint blade = 0;
78 uint bladePoint = 0;
79 calcTurbineBladeAndBladePoint(node, bladePoint, numberOfPointsPerBlade, blade, numberOfBlades, turbine);
80 return { /*.turbine = */ turbine, /*.blade = */ blade, /*.bladePoint = */ bladePoint }; // Designated initializers are a C++ 20 feature
81}
82
89
98{
99 return distX * distX + distY * distY + distZ * distZ;
100}
101constexpr real getRotorBoundingVolumeRadius(real diameter, real smearingWidth, bool useVAWTVolume)
102{
103 using namespace vf::basics::constant;
104 return c1o2 * diameter + c3o2 * smearingWidth;
105}
106
107constexpr bool inSphereVolume(real distX, real distY, real distZ, real diameter, real smearingWidth)
108{
109 const real boundingSphereRadius = getRotorBoundingVolumeRadius(diameter, smearingWidth, false);
111}
112
113template <Axis CylinderAxis, bool UseDonut>
115 real centerX, real centerY, real centerZ,
117 real margin)
118{
119 using namespace vf::basics::constant;
120
123
124 if constexpr (CylinderAxis == x) {
126 axialCenter = centerX;
127 radial1 = gridY;
128 radial2 = gridZ;
129 radialCenter1 = centerY;
130 radialCenter2 = centerZ;
131 } else if constexpr (CylinderAxis == y) {
133 axialCenter = centerY;
134 radial1 = gridX;
135 radial2 = gridZ;
136 radialCenter1 = centerX;
137 radialCenter2 = centerZ;
138 } else { // z
140 axialCenter = centerZ;
141 radial1 = gridX;
142 radial2 = gridY;
143 radialCenter1 = centerX;
144 radialCenter2 = centerY;
145 }
146
147 const real axialMin = axialCenter - cylinderLength * c1o2 - margin;
148 const real axialMax = axialCenter + cylinderLength * c1o2 + margin;
149
151 return false;
152
153 const real d1 = radial1 - radialCenter1;
154 const real d2 = radial2 - radialCenter2;
155 const real squaredRadialDist = d1 * d1 + d2 * d2;
156
158
160 if constexpr (UseDonut)
161 minRadialDist = std::max(cylinderRadius - margin, real(0));
162 else
163 minRadialDist = c0o1;
164
167}
168
170{
171 using namespace vf::basics::constant;
172
173 return std::pow(smearingWidth * std::sqrt(cPi), -3) * std::exp(-distSqrd(distX, distY, distZ) / (smearingWidth * smearingWidth)) ;
174}
175
176
177constexpr bool isHubPoint(uint pointIndex, uint numberOfBladePoints, uint totalPoints)
178{
179 return pointIndex >= numberOfBladePoints && pointIndex < totalPoints;
180}
181
182constexpr uint getHubPointIndex(uint pointIndex, uint numberOfBladePoints)
183{
184 return pointIndex - numberOfBladePoints;
185}
186
187
188
189constexpr bool isTowerPoint(uint pointIndex, uint numberOfBladePoints,
190 uint numberOfHubPoints, uint totalPoints)
191{
192 const uint towerStartIndex = numberOfBladePoints + numberOfHubPoints;
194}
195
196constexpr uint getTowerPointIndex(uint pointIndex, uint numberOfBladePoints,
197 uint numberOfHubPoints)
198{
199 return pointIndex - numberOfBladePoints - numberOfHubPoints;
200}
201
202}
203
204#endif
205
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
#define __host__
#define __device__
@ x
Definition Axis.h:42
@ y
Definition Axis.h:43
__host__ __device__ __inline__ void rotateFromGlobalToBlade(real &bladeCoordX_BF, real &bladeCoordY_BF, real &bladeCoordZ_BF, real bladeCoordX_GF, real bladeCoordY_GF, real bladeCoordZ_GF, real azimuth)
constexpr uint getHubPointIndex(uint pointIndex, uint numberOfBladePoints)
__inline__ __host__ __device__ void invRotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
__host__ __device__ __inline__ real gaussianSmearing(real distX, real distY, real distZ, real smearingWidth)
__host__ __device__ __inline__ bool inCylinderVolume(real gridX, real gridY, real gridZ, real centerX, real centerY, real centerZ, real cylinderLength, real cylinderRadius, real margin)
__inline__ __host__ __device__ void rotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
constexpr real distSqrd(real distX, real distY, real distZ)
constexpr bool isTowerPoint(uint pointIndex, uint numberOfBladePoints, uint numberOfHubPoints, uint totalPoints)
constexpr bool isHubPoint(uint pointIndex, uint numberOfBladePoints, uint totalPoints)
__host__ __device__ __inline__ void rotateFromBladeToGlobal(real bladeCoordX_BF, real bladeCoordY_BF, real bladeCoordZ_BF, real &bladeCoordX_GF, real &bladeCoordY_GF, real &bladeCoordZ_GF, real azimuth)
constexpr uint calcPointIndexInBladeArrays(uint bladePoint, uint numberOfPointsPerBlade, uint blade, uint numberOfBlades, uint turbine)
constexpr uint getTowerPointIndex(uint pointIndex, uint numberOfBladePoints, uint numberOfHubPoints)
constexpr real getRotorBoundingVolumeRadius(real diameter, real smearingWidth, bool useVAWTVolume)
constexpr void calcTurbineBladeAndBladePoint(uint node, uint &bladePoint, uint numberOfPointsPerBlade, uint &blade, uint numberOfBlades, uint &turbine)
constexpr bool inSphereVolume(real distX, real distY, real distZ, real diameter, real smearingWidth)