VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
RefinementStrategy.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//=======================================================================================
34#include "RefinementStrategy.h"
35
36#include <logger/Logger.h>
37
40#include "Parameter/Parameter.h"
41
42namespace vf::gpu {
43
44std::function<void(UpdateGrid27 *updateGrid, Parameter *para, int level)>
45 getFunctionForRefinementAndExchange(const bool useStreams, const int numberOfMpiProcesses, const int maxLevel,
46 const bool useReducedCommunicationAfterFtoC) noexcept
47{
48 VF_LOG_INFO("Function used for refinementAndExchange: ");
49 if (maxLevel == 0) {
50 VF_LOG_INFO("only one level - no function needed.");
51 return NoRefinement();
52
53 } else if (numberOfMpiProcesses == 1) {
54 VF_LOG_INFO("only one process - no exchange needed: Refinement_noExchange()");
55 return Refinement_noExchange();
56
57 } else if (numberOfMpiProcesses > 1 && useStreams && useReducedCommunicationAfterFtoC) {
58 VF_LOG_INFO("RefinementAndExchange_streams_exchangeInterface()");
60
61 } else if(numberOfMpiProcesses > 1 && useStreams && !useReducedCommunicationAfterFtoC){
62 VF_LOG_INFO("refinementAndExchange_streams_completeExchange()");
64
65 } else if (numberOfMpiProcesses > 1 && !useStreams && useReducedCommunicationAfterFtoC) {
66 VF_LOG_INFO("RefinementAndExchange_noStreams_exchangeInterface()");
68
69 } else {
70 VF_LOG_INFO("RefinementAndExchange_noStreams_exchangeAllNodes()");
72 }
73}
74
75void NoRefinement::operator()(UpdateGrid27 *updateGrid, Parameter *para, int level){}
76
78{
83 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarseBorder, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::SubDomainBorder);
84
87 updateGrid->prepareExchangeMultiGPUAfterFtoC(level, CudaStreamIndex::SubDomainBorder);
88 if (para->getUseStreams())
89 para->getStreamManager()->triggerStartBulkKernel(CudaStreamIndex::SubDomainBorder);
90
93 para->getStreamManager()->waitOnStartBulkKernelEvent(CudaStreamIndex::Bulk);
94 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarseBulk, para->getParD(level)->neighborFineToCoarseBulk, CudaStreamIndex::SubDomainBorder);
95 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFineBulk, para->getParD(level)->neighborCoarseToFineBulk, CudaStreamIndex::SubDomainBorder);
96
99 updateGrid->exchangeMultiGPUAfterFtoC(level, CudaStreamIndex::SubDomainBorder);
100
101 // 5. interpolation fine to coarse for nodes which are at the border of the gpus/processes
103 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFineBorder, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::SubDomainBorder);
104
106}
107
109{
114 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarseBorder, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::SubDomainBorder);
115
118 updateGrid->prepareExchangeMultiGPU(level, CudaStreamIndex::SubDomainBorder);
119 if (para->getUseStreams())
120 para->getStreamManager()->triggerStartBulkKernel(CudaStreamIndex::SubDomainBorder);
121
124 para->getStreamManager()->waitOnStartBulkKernelEvent(CudaStreamIndex::Bulk);
125 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarseBulk, para->getParD(level)->neighborFineToCoarseBulk, CudaStreamIndex::SubDomainBorder);
126 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFineBulk, para->getParD(level)->neighborCoarseToFineBulk, CudaStreamIndex::SubDomainBorder);
127
130 updateGrid->exchangeMultiGPU(level, CudaStreamIndex::SubDomainBorder);
131
132 // 5. interpolation fine to coarse for nodes which are at the border of the gpus/processes
134 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFineBorder, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::SubDomainBorder);
135
137}
138
140{
145 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarse, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::Legacy);
146
149 updateGrid->exchangeMultiGPU_noStreams_withPrepare(level, true);
150
152 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFine, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::Legacy);
153}
154
156{
161 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarse, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::Legacy);
162
165 updateGrid->exchangeMultiGPU_noStreams_withPrepare(level, false);
166
168 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFine, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::Legacy);
169}
170
172{
177 updateGrid->fineToCoarse(level, &para->getParD(level)->fineToCoarse, para->getParD(level)->neighborFineToCoarse, CudaStreamIndex::Legacy);
179 updateGrid->coarseToFine(level, &para->getParD(level)->coarseToFine, para->getParD(level)->neighborCoarseToFine, CudaStreamIndex::Legacy);
180}
181
182}
183
#define VF_LOG_INFO(...)
Definition Logger.h:50
Version of refinement: for uniform simulations (no grid refinement)
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level)
Class for LBM-parameter management.
Definition Parameter.h:359
std::unique_ptr< CudaStreamManager > & getStreamManager()
std::shared_ptr< LBMSimulationParameter > getParD(int level)
Pointer to instance of LBMSimulationParameter - stored on Device (GPU)
Version of refinement: for single-gpu simulations.
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level)
Version of refinement: for multi-gpu simulations, without communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level)
Version of refinement: for multi-gpu simulations, without communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level)
Version of refinement: for multi-gpu simulations, with communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level)
Version of refinement: for multi-gpu simulations, with communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level)
std::shared_ptr< T > SPtr
std::function< void(UpdateGrid27 *updateGrid, Parameter *para, int level)> getFunctionForRefinementAndExchange(const bool useStreams, const int numberOfMpiProcesses, const int maxLevel, const bool useReducedCommunicationAfterFtoC) noexcept
get a function which performs the interpolation between grid levels and performs the communication be...