VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
OutflowNonReflecting.cuh
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//
29//! \addtogroup gpu_BoundaryConditions BoundaryConditions
30//! \ingroup gpu_core core
31//! \{
32//! \author Martin Schoenherr, Anna Wellmann, Henry Korb
33//======================================================================================
34#ifndef OUTFLOW_NON_REFLECTING_H_
35#define OUTFLOW_NON_REFLECTING_H_
36
37#include "Calculation/Calculation.h"
38#include "Utilities/KernelUtilities.h"
39#include "basics/constants/NumericConstants.h"
40#include "cuda_helper/CudaIndexCalculation.h"
41#include "lbm/MacroscopicQuantities.h"
42#include "lbm/constants/D3Q27.h"
43
44namespace vf::gpu {
45
46template <size_t dir>
47constexpr void computeOutflowDistribution(const Distributions27& populationReferences,
48 const ListIndices& listIndices, const real* populations,
49 const real* populationsNeighbor, const real cs, const real densityCorrection)
50{
51 using namespace vf::basics::constant;
52 const real weight = vf::lbm::dir::getWeight<dir>();
53 const real population = populationsNeighbor[dir] * cs + (c1o1 - cs) * populations[dir] - weight * densityCorrection;
54 writeInSameDirection<dir>(population, listIndices, populationReferences);
55}
56
57template <bool applyPressureCorrection>
58__global__ void OutflowNonReflecting_Device(real* rhoBC, real* distributions, const int* indicesBCnode,
59 const int* indicesNeighbor, const int numberOfBCnodes, const uint* neighborX,
60 const uint* neighborY, const uint* neighborZ,
61 const unsigned long long numberOfLBnodes, const bool isEvenTimestep,
62 const size_t direction, const real densityCorrectionFactor)
63{
64 using namespace vf::basics::constant;
65 using namespace vf::lbm::dir;
66 const uint nodeIndex = vf::cuda::get1DIndexFrom2DBlock();
67 if (nodeIndex >= numberOfBCnodes)
68 return;
69
70 const ListIndices listIndices(indicesBCnode[nodeIndex], neighborX, neighborY, neighborZ);
71 const ListIndices neighborIndices(indicesNeighbor[nodeIndex], neighborX, neighborY, neighborZ);
72
73 Distributions27 populationReferences;
74 getPointersToDistributions(populationReferences, distributions, numberOfLBnodes, isEvenTimestep);
75 real populations[NUMBER_Of_DIRECTIONS], populationsNeighbor[NUMBER_Of_DIRECTIONS];
76
77 getPreCollisionDistribution(populationsNeighbor, populationReferences, neighborIndices);
78 getPreCollisionDistribution(populations, populationReferences, listIndices);
79
80 const real densityCorrection =
81 applyPressureCorrection ? densityCorrectionFactor * vf::lbm::getDensity(populations) : c0o1;
82 const real cs = std::sqrt(c1o3);
83
84 getPointersToDistributions(populationReferences, distributions, numberOfLBnodes, !isEvenTimestep);
85
86 switch (direction) {
87 case dM00:
88 computeOutflowDistribution<dP00>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
89 computeOutflowDistribution<dPM0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
90 computeOutflowDistribution<dPP0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
91 computeOutflowDistribution<dP0M>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
92 computeOutflowDistribution<dP0P>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
93 computeOutflowDistribution<dPMP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
94 computeOutflowDistribution<dPPP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
95 computeOutflowDistribution<dPMM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
96 computeOutflowDistribution<dPPM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
97 break;
98
99 case dP00:
100 computeOutflowDistribution<dM00>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
101 computeOutflowDistribution<dMM0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
102 computeOutflowDistribution<dMP0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
103 computeOutflowDistribution<dM0M>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
104 computeOutflowDistribution<dM0P>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
105 computeOutflowDistribution<dMMP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
106 computeOutflowDistribution<dMPP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
107 computeOutflowDistribution<dMMM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
108 computeOutflowDistribution<dMPM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
109 break;
110
111 case d0M0:
112 computeOutflowDistribution<d0P0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
113 computeOutflowDistribution<dPP0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
114 computeOutflowDistribution<dMP0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
115 computeOutflowDistribution<d0PP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
116 computeOutflowDistribution<d0PM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
117 computeOutflowDistribution<dPPP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
118 computeOutflowDistribution<dMPP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
119 computeOutflowDistribution<dPPM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
120 computeOutflowDistribution<dMPM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
121 break;
122
123 case d0P0:
124 computeOutflowDistribution<d0M0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
125 computeOutflowDistribution<dPM0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
126 computeOutflowDistribution<dMM0>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
127 computeOutflowDistribution<d0MP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
128 computeOutflowDistribution<d0MM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
129 computeOutflowDistribution<dPMP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
130 computeOutflowDistribution<dMMP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
131 computeOutflowDistribution<dPMM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
132 computeOutflowDistribution<dMMM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
133 break;
134
135 case d00M:
136 computeOutflowDistribution<d00P>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
137 computeOutflowDistribution<dP0P>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
138 computeOutflowDistribution<dM0P>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
139 computeOutflowDistribution<d0PP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
140 computeOutflowDistribution<d0MP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
141 computeOutflowDistribution<dPPP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
142 computeOutflowDistribution<dMPP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
143 computeOutflowDistribution<dPMP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
144 computeOutflowDistribution<dMMP>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
145 break;
146
147 case d00P:
148 computeOutflowDistribution<d00M>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
149 computeOutflowDistribution<dP0M>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
150 computeOutflowDistribution<dM0M>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
151 computeOutflowDistribution<d0PM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
152 computeOutflowDistribution<d0MM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
153 computeOutflowDistribution<dPPM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
154 computeOutflowDistribution<dMPM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
155 computeOutflowDistribution<dPMM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
156 computeOutflowDistribution<dMMM>(populationReferences, listIndices, populations, populationsNeighbor, cs, densityCorrection);
157 break;
158 default:
159 break;
160 }
161}
162
163}
164
165//! \}
166#endif