VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
GridScalingKernelManager.cpp
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//=======================================================================================
36
37#include <logger/Logger.h>
38#include "Parameter/Parameter.h"
42#include <stdexcept>
44
45namespace vf::gpu {
46
48 : para(parameter)
49{
50 if(para->getMaxLevel() != 0){
52 throw std::runtime_error("There is more than one level, but no scalingFactory was provided.");
53 }
54 checkScalingFunction(gridScalingFactory->getGridScalingFC(parameter->getUseTurbulentViscosity()), this->para->getParD(0)->fineToCoarse, "scalingFineToCoarse");
55 checkScalingFunction(gridScalingFactory->getGridScalingCF(parameter->getUseTurbulentViscosity()), this->para->getParD(0)->coarseToFine, "scalingCoarseToFine");
56 this->scalingFineToCoarse = gridScalingFactory->getGridScalingFC(parameter->getUseTurbulentViscosity());
57 this->scalingCoarseToFine = gridScalingFactory->getGridScalingCF(parameter->getUseTurbulentViscosity());
58 if (para->getDiffOn())
59 {
60 this->scalingFineToCoarseAD = gridScalingFactory->getGridScalingAdvectionDiffusionFC(parameter->getUseTurbulentDiffusivity());
61 this->scalingCoarseToFineAD = gridScalingFactory->getGridScalingAdvectionDiffusionCF(parameter->getUseTurbulentDiffusivity());
62 }
63 }
64
65 if(this->scalingFineToCoarse == nullptr)
66 VF_LOG_TRACE("Function for scalingFineToCoarse is nullptr");
67 if(this->scalingCoarseToFine == nullptr)
68 VF_LOG_TRACE("Function for scalingCoarseToFine is nullptr");
69
70 if (para->getDiffOn())
71 {
72 if (this->scalingFineToCoarseAD == nullptr)
73 VF_LOG_TRACE("Function for scalingFineToCoarseAD is nullptr");
74 if (this->scalingCoarseToFineAD == nullptr)
75 VF_LOG_TRACE("Function for scalingCoarseToFineAD is nullptr");
76 }
77}
78
79void GridScalingKernelManager::runFineToCoarseKernelLB(const int level, InterpolationCells *fineToCoarse, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex) const
80{
81 cudaStream_t stream = para->getStreamManager()->getStream(streamIndex);
82 this->scalingFineToCoarse(para->getParD(level).get(), para->getParD(level+1).get(), fineToCoarse, neighborFineToCoarse, stream);
83 if (para->getDiffOn())
84 this->scalingFineToCoarseAD(para->getParD(level).get(), para->getParD(level+1).get(), fineToCoarse, neighborFineToCoarse, stream);
85}
86
87void GridScalingKernelManager::runCoarseToFineKernelLB(const int level, InterpolationCells* coarseToFine, ICellNeigh &neighborCoarseToFine, CudaStreamIndex streamIndex) const
88{
89 cudaStream_t stream = para->getStreamManager()->getStream(streamIndex);
90 this->scalingCoarseToFine(para->getParD(level).get(), para->getParD(level+1).get(), coarseToFine, neighborCoarseToFine, stream);
91 if (para->getDiffOn())
92 this->scalingCoarseToFineAD(para->getParD(level).get(), para->getParD(level+1).get(), coarseToFine, neighborCoarseToFine, stream);
93}
94
95}
96
#define VF_LOG_TRACE(...)
Definition Logger.h:48
void runCoarseToFineKernelLB(const int level, InterpolationCells *coarseToFine, ICellNeigh &neighborCoarseToFine, CudaStreamIndex streamIndex) const
calls the device function of the coarse to fine grid interpolation kernel
GridScalingKernelManager(SPtr< Parameter > parameter, GridScalingFactory *gridScalingFactory)
void runFineToCoarseKernelLB(const int level, InterpolationCells *fineToCoarse, ICellNeigh &neighborFineToCoarse, CudaStreamIndex streamIndex) const
calls the device function of the fine to coarse grid interpolation kernelH
std::shared_ptr< T > SPtr
stores location of neighboring cell (necessary for refinement into the wall)
Definition Calculation.h:85