VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
KernelImp.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//
32#ifndef KERNEL_IMP_H
33#define KERNEL_IMP_H
34
35#include <memory>
36#include <optional>
37
39
41#include "Kernel.h"
43
44namespace vf::gpu {
45
46class Parameter;
47class CudaStreamManager;
48
49class KernelImp : public Kernel
50{
51public:
52 void runOnIndices(const unsigned int* indices, unsigned int sizeIndices, CollisionTemplate collisionTemplate,
53 CudaStreamIndex streamIndex = CudaStreamIndex::Legacy) override;
54
56
57 std::vector<PreProcessorType> getPreProcessorTypes() override;
58
60
61protected:
62 KernelImp(std::shared_ptr<Parameter> para, int level);
64 KernelImp(std::shared_ptr<Parameter> para, int level, real viscosityMaximumRecommended);
67 KernelImp() = default;
68
69 // the limit of the velocity in LB units is the same for all kernels
70 const real velocityMaximumHard = 1 - std::sqrt(vf::basics::constant::c1o3);
72
73 // the limit of the viscosity in LB units depends on the kernel, and may not be defined for some kernels
74 const std::optional<real> viscosityMaximumHard = std::nullopt;
75 const std::optional<real> viscosityMaximumRecommended = std::nullopt;
76
77 std::shared_ptr<Parameter> para;
78 int level;
79 std::vector<PreProcessorType> myPreProcessorTypes;
81
83
84private:
85 void checkViscosity(real viscosityLBOnFinestLevel, uint maxLevel) const;
86 void checkVelocity(real velocityLB) const;
87
88 static std::string realToString(real kernelParameter);
89
90 static std::string composeWarningForMaximumKernelParameterHardLimit(const std::string& kernelParameterName,
92 static std::string composeWarningForMaximumKernelParameterRecommendation(const std::string& kernelParameterName,
94
95 static std::string composeRecommendationForMaximumKernelParameter(const std::string& kernelParameterName,
97 static std::string composeInfoOnHardLimitForMaximumKernelParameter(const std::string& kernelParameterName,
99};
100
101}
102
103#endif
104
std::vector< PreProcessorType > myPreProcessorTypes
Definition KernelImp.h:79
vf::cuda::CudaGrid cudaGrid
Definition KernelImp.h:80
std::vector< PreProcessorType > getPreProcessorTypes() override
Definition KernelImp.cpp:46
const real velocityMaximumRecommended
Definition KernelImp.h:71
std::shared_ptr< Parameter > para
Definition KernelImp.h:77
const real velocityMaximumHard
Definition KernelImp.h:70
const std::optional< real > viscosityMaximumHard
Definition KernelImp.h:74
bool getKernelUsesFluidNodeIndices() const
Definition KernelImp.cpp:51
void runOnIndices(const unsigned int *indices, unsigned int sizeIndices, CollisionTemplate collisionTemplate, CudaStreamIndex streamIndex=CudaStreamIndex::Legacy) override
Definition KernelImp.cpp:41
bool kernelUsesFluidNodeIndices
Definition KernelImp.h:82
void checkKernelParameters(uint maxLevel, real velocityLB, real viscosityLBOnFinestLevel) const override
check if velocityLB and viscosityLB are not too high, as this can lead to inaccurate results or a cra...
const std::optional< real > viscosityMaximumRecommended
Definition KernelImp.h:75
std::shared_ptr< T > SPtr
float real
Definition DataTypes.h:42
unsigned int uint
Definition DataTypes.h:47
CollisionTemplate
An enumeration for selecting a template of the collision kernel (CumulantK17)
Definition Calculation.h:57