VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
CollisisionStrategy.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 "CollisionStrategy.h"
36#include "Parameter/Parameter.h"
37#include <logger/Logger.h>
38
39namespace vf::gpu {
40
41std::function<void(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)>
43 const bool kernelNeedsFluidNodeIndicesToRun)
44{
45 VF_LOG_INFO("Function used for collisionAndExchange: ");
46
47 if (useStreams && numberOfMpiProcesses > 1 && kernelNeedsFluidNodeIndicesToRun) {
48 VF_LOG_INFO("CollisionAndExchange_streams()");
50
51 } else if (useStreams && !kernelNeedsFluidNodeIndicesToRun) {
52 VF_LOG_INFO("Cuda Streams can only be used with kernels which run using fluidNodesIndices.");
53
54 } else if (useStreams && numberOfMpiProcesses <= 1) {
55 VF_LOG_INFO("Cuda Streams can only be used with multiple MPI processes.");
56
57 } else if (!useStreams && kernelNeedsFluidNodeIndicesToRun) {
58 VF_LOG_INFO("CollisionAndExchange_noStreams_indexKernel()");
60
61 } else if (!useStreams && !kernelNeedsFluidNodeIndicesToRun) {
62 VF_LOG_INFO("CollisionAndExchange_noStreams_oldKernel()");
64 }
65
66 throw std::runtime_error("Invalid Configuration for collision and exchange");
67}
68
70 unsigned int t)
71{
76 for( CollisionTemplate tag: para->getParH(level)->allocatedBulkFluidNodeTags )
77 {
78 updateGrid->collisionUsingIndices( level, t,
79 para->getParD(level)->taggedFluidNodeIndices[tag],
80 para->getParD(level)->numberOfTaggedFluidNodes[tag],
81 tag,
83 }
84
86 updateGrid->exchangeMultiGPU_noStreams_withPrepare(level, false);
87}
88
90 unsigned int t)
91{
96 updateGrid->collisionAllNodes(level, t);
97
99 updateGrid->exchangeMultiGPU_noStreams_withPrepare(level, false);
100}
101
102void CollisionAndExchange_streams::operator()(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)
103{
108 updateGrid->collisionUsingIndices( level, t,
109 para->getParD(level)->taggedFluidNodeIndices[CollisionTemplate::SubDomainBorder],
110 para->getParD(level)->numberOfTaggedFluidNodes[CollisionTemplate::SubDomainBorder],
113
116 updateGrid->prepareExchangeMultiGPU(level, CudaStreamIndex::SubDomainBorder);
117 if (para->getUseStreams())
118 para->getStreamManager()->triggerStartBulkKernel(CudaStreamIndex::SubDomainBorder);
119
122
123 para->getStreamManager()->waitOnStartBulkKernelEvent(CudaStreamIndex::Bulk);
124
125 for( CollisionTemplate tag: para->getParH(level)->allocatedBulkFluidNodeTags )
126 {
127 updateGrid->collisionUsingIndices( level, t,
128 para->getParD(level)->taggedFluidNodeIndices[tag],
129 para->getParD(level)->numberOfTaggedFluidNodes[tag],
130 tag,
132 }
134 updateGrid->exchangeMultiGPU(level, CudaStreamIndex::SubDomainBorder);
135
139}
140
141}
142
#define VF_LOG_INFO(...)
Definition Logger.h:50
Version of collision: for multi-gpu simulations, without communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)
Version of collision: for multi-gpu simulations, without communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)
Version of collision: for multi-gpu simulations, with communication hiding ("streams"),...
void operator()(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)
Class for LBM-parameter management.
Definition Parameter.h:359
std::shared_ptr< LBMSimulationParameter > getParH(int level) const
Pointer to instance of LBMSimulationParameter - stored on Host System.
std::unique_ptr< CudaStreamManager > & getStreamManager()
std::shared_ptr< LBMSimulationParameter > getParD(int level)
Pointer to instance of LBMSimulationParameter - stored on Device (GPU)
std::shared_ptr< T > SPtr
std::function< void(UpdateGrid27 *updateGrid, Parameter *para, int level, unsigned int t)> getFunctionForCollisionAndExchange(const bool useStreams, const int numberOfMpiProcesses, const bool kernelNeedsFluidNodeIndicesToRun)
get a function which performs the collision operator and performs the communication between gpus/ pro...
CollisionTemplate
An enumeration for selecting a template of the collision kernel (CumulantK17)
Definition Calculation.h:57