VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GeometryUtils.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 _GEOMETRYUTILS_H
36#define _GEOMETRYUTILS_H
37
38#include "UbMath.h"
39#include <algorithm>
40
41#include <cuda_runtime.h>
42
43#include <basics/DataTypes.h>
45
46namespace vf::gpu {
47
49 uint& k_MPP, uint& k_PPP, const uint* neighborX, const uint* neighborY,
50 const uint* neighborZ)
51{
52 k_PMM = neighborX[k_MMM];
53 k_MPM = neighborY[k_MMM];
54 k_MMP = neighborZ[k_MMM];
55 k_PPM = neighborY[k_PMM];
56 k_PMP = neighborZ[k_PMM];
57 k_MPP = neighborZ[k_MPM];
58 k_PPP = neighborX[k_MPP];
59}
60
61constexpr uint findNearestCellBSW(const uint index, const real* coordsX, const real* coordsY, const real* coordsZ,
62 const real posX, const real posY, const real posZ, const uint* neighborsX,
63 const uint* neighborsY, const uint* neighborsZ, const uint* neighborsWSB)
64{
65 uint new_index = index;
66 constexpr uint comparisor = 1;
67
69
73
77
81
82 return neighborsWSB[new_index];
83}
84
85constexpr real trilinearInterpolation(real dXM, real dYM, real dZM, uint kMMM, uint kPMM, uint kMPM, uint kMMP, uint kPPM,
86 uint kPMP, uint kMPP, uint kPPP, const real* quantity)
87{
88 return ub_math::lerp3(quantity[kMMM], quantity[kPMM], quantity[kMPM], quantity[kPPM], quantity[kMMP], quantity[kPMP], quantity[kMPP], quantity[kPPP], dXM, dYM, dZM);
89}
90
96
102
110
118
124
126 real originY)
127{
128 real tmpX, tmpY;
129 invTranslate2D(posX, posY, newPosX, newPosY, originX, originY);
131 translate2D(tmpX, tmpY, newPosX, newPosY, originX, originY);
132}
138
140 real originY)
141{
142 real tmpX, tmpY;
143 invTranslate2D(posX, posY, newPosX, newPosY, originX, originY);
145 translate2D(tmpX, tmpY, newPosX, newPosY, originX, originY);
146}
147
154
156 real& newPosZ, real originX, real originY, real originZ)
157{
158 real tmpX, tmpY, tmpZ;
159 invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
161 translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
162}
163
170
172 real& newPosY, real& newPosZ, real originX, real originY, real originZ)
173{
174 real tmpX, tmpY, tmpZ;
175 invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
177 translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
178}
179
186
188 real& newPosZ, real originX, real originY, real originZ)
189{
190 real tmpX, tmpY, tmpZ;
191 invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
193 translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
194}
195
202
204 real& newPosY, real& newPosZ, real originX, real originY, real originZ)
205{
206 real tmpX, tmpY, tmpZ;
207 invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
209 translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
210}
211
218
220 real& newPosZ, real originX, real originY, real originZ)
221{
222 real tmpX, tmpY, tmpZ;
223 invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
225 translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
226}
227
234
236 real& newPosY, real& newPosZ, real originX, real originY, real originZ)
237{
238 real tmpX, tmpY, tmpZ;
239 invTranslate3D(posX, posY, posZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
241 translate3D(tmpX, tmpY, tmpZ, newPosX, newPosY, newPosZ, originX, originY, originZ);
242}
243
244}
245
246#endif
247
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
#define __host__
#define __device__
constexpr T lerp3(const T &a, const T &b, const T &c, const T &d, const T &e, const T &f, const T &g, const T &h, const U &t, const U &u, const U &v)
Definition UbMath.h:424
constexpr void getNeighborIndicesOfBSW(uint k_MMM, uint &k_PMM, uint &k_MPM, uint &k_MMP, uint &k_PPM, uint &k_PMP, uint &k_MPP, uint &k_PPP, const uint *neighborX, const uint *neighborY, const uint *neighborZ)
__inline__ __host__ __device__ void rotate2D(real angle, real posX, real posY, real &newPosX, real &newPosY)
constexpr void invTranslate2D(real posX, real posY, real &newPosX, real &newPosY, real translationX, real translationY)
constexpr uint findNearestCellBSW(const uint index, const real *coordsX, const real *coordsY, const real *coordsZ, const real posX, const real posY, const real posZ, const uint *neighborsX, const uint *neighborsY, const uint *neighborsZ, const uint *neighborsWSB)
constexpr real trilinearInterpolation(real dXM, real dYM, real dZM, uint kMMM, uint kPMM, uint kMPM, uint kMMP, uint kPPM, uint kPMP, uint kMPP, uint kPPP, const real *quantity)
__inline__ __host__ __device__ void invRotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
constexpr void translate3D(real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real translationX, real translationY, real translationZ)
__inline__ __host__ __device__ void rotateAboutX3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
constexpr void invTranslate3D(real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ, real translationX, real translationY, real translationZ)
constexpr void translate2D(real posX, real posY, real &newPosX, real &newPosY, real translationX, real translationY)
__inline__ __host__ __device__ void invRotateAboutZ3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
__inline__ __host__ __device__ void rotateAboutY3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
__inline__ __host__ __device__ void invRotate2D(real angle, real posX, real posY, real &newPosX, real &newPosY)
__inline__ __host__ __device__ void rotateAboutZ3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)
__inline__ __host__ __device__ void invRotateAboutY3D(real angle, real posX, real posY, real posZ, real &newPosX, real &newPosY, real &newPosZ)