Skip to content
Snippets Groups Projects
Commit ed6ee96e authored by Anna Wellmann's avatar Anna Wellmann
Browse files

Add CudaKernelManager from OpenSource

parent fa02603f
No related branches found
No related tags found
1 merge request!113Use kernel managers to call the kernels (LBM, AdvectionDiffusion, BoundaryConditions)
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// This file is part of VirtualFluids. VirtualFluids is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CudaKernelManager.cpp
//! \ingroup GPU
//! \author Martin Schoenherr
//=======================================================================================
#include <cuda_runtime.h>
#include <helper_cuda.h>
#include "CudaKernelManager.h"
#include "GPU_Interface.h"
#include <Parameter/Parameter.h>
void CudaKernelManager::runLBMKernel(SPtr<Parameter> para)
{
if (para->getIsADcalculationOn()) {
CumulantK17LBMDeviceKernelAD(
para->getParD()->numberofthreads,
para->getParD()->omega,
para->getParD()->typeOfGridNode,
para->getParD()->neighborX,
para->getParD()->neighborY,
para->getParD()->neighborZ,
para->getParD()->distributions.f[0],
para->getParD()->distributionsAD.f[0],
para->getParD()->numberOfNodes,
para->getParD()->forcing,
para->getParD()->isEvenTimestep);
} else {
CumulantK17LBMDeviceKernel(
para->getParD()->numberofthreads,
para->getParD()->omega,
para->getParD()->typeOfGridNode,
para->getParD()->neighborX,
para->getParD()->neighborY,
para->getParD()->neighborZ,
para->getParD()->distributions.f[0],
para->getParD()->numberOfNodes,
para->getParD()->forcing,
para->getParD()->isEvenTimestep);
}
}
void CudaKernelManager::runVelocityBCKernel(SPtr<Parameter> para)
{
if (para->getParD()->numberOfVeloBCnodes > 0)
{
QVelDevicePlainBB27(
para->getParD()->numberofthreads,
para->getParD()->veloBC.Vx,
para->getParD()->veloBC.Vy,
para->getParD()->veloBC.Vz,
para->getParD()->distributions.f[0],
para->getParD()->veloBC.k,
para->getParD()->veloBC.q27[0],
para->getParD()->numberOfVeloBCnodes,
para->getParD()->veloBC.kArray,
para->getParD()->neighborX,
para->getParD()->neighborY,
para->getParD()->neighborZ,
para->getParD()->numberOfNodes,
para->getParD()->isEvenTimestep);
}
}
void CudaKernelManager::runGeoBCKernel(SPtr<Parameter> para)
{
if (para->getParD()->numberOfGeoBCnodes > 0)
{
// ...
}
}
void runSlipBCKernel(SPtr<Parameter> para){
if (para->getParD()->numberOfSlipBCnodes > 0)
{
// ...
}
}
void runNoSlipBCKernel(SPtr<Parameter> para){
if (para->getParD()->numberOfNoSlipBCnodes > 0)
{
// ...
}
}
void runPressureBCKernel(SPtr<Parameter> para){
if (para->getParD()->numberOfPressureBCnodes > 0)
{
// ...
}
}
void CudaKernelManager::calculateMacroscopicValues(SPtr<Parameter> para)
{
if (para->getIsADcalculationOn()) {
CalcMacADCompSP27(
para->getParD()->velocityX,
para->getParD()->velocityY,
para->getParD()->velocityZ,
para->getParD()->rho,
para->getParD()->pressure,
para->getParD()->typeOfGridNode,
para->getParD()->neighborX,
para->getParD()->neighborY,
para->getParD()->neighborZ,
para->getParD()->numberOfNodes,
para->getParD()->numberofthreads,
para->getParD()->distributions.f[0],
para->getParD()->distributionsAD.f[0],
para->getParD()->forcing,
para->getParD()->isEvenTimestep);
} else {
CalcMacCompSP27(
para->getParD()->velocityX,
para->getParD()->velocityY,
para->getParD()->velocityZ,
para->getParD()->rho,
para->getParD()->pressure,
para->getParD()->typeOfGridNode,
para->getParD()->neighborX,
para->getParD()->neighborY,
para->getParD()->neighborZ,
para->getParD()->numberOfNodes,
para->getParD()->numberofthreads,
para->getParD()->distributions.f[0],
para->getParD()->isEvenTimestep);
}
}
SPtr<CudaKernelManager> CudaKernelManager::make(SPtr<Parameter> parameter)
{
return SPtr<CudaKernelManager>(new CudaKernelManager(parameter));
}
CudaKernelManager::CudaKernelManager(SPtr<Parameter> parameter)
{
this->parameter = parameter;
}
CudaKernelManager::CudaKernelManager(const CudaKernelManager&)
{
}
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// This file is part of VirtualFluids. VirtualFluids is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with VirtualFluids (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file CudaKernelManager.h
//! \ingroup GPU
//! \author Martin Schoenherr
//=======================================================================================
#ifndef CudaKernelManager_H
#define CudaKernelManager_H
#include <memory>
#include "PointerDefinitions.h"
#include "VirtualFluids_GPU_export.h"
//! \brief Class forwarding for Parameter
class Parameter;
//! \class CudaKernelManager
//! \brief manage the cuda kernel calls
class VIRTUALFLUIDS_GPU_EXPORT CudaKernelManager
{
public:
//! \brief makes an object of CudaKernelManager
//! \param para shared pointer to instance of class Parameter
static SPtr<CudaKernelManager> make(std::shared_ptr<Parameter> parameter);
//! \brief calls the device function of the lattice Boltzmann kernel
void runLBMKernel(SPtr<Parameter> para);
//! \brief calls the device function of the velocity boundary condition
void runVelocityBCKernel(SPtr<Parameter> para);
//! \brief calls the device function of the geometry boundary condition
void runGeoBCKernel(SPtr<Parameter> para);
//! \brief calls the device function of the slip boundary condition
void runSlipBCKernel(SPtr<Parameter> para);
//! \brief calls the device function of the no-slip boundary condition
void runNoSlipBCKernel(SPtr<Parameter> para);
//! \brief calls the device function of the pressure boundary condition
void runPressureBCKernel(SPtr<Parameter> para);
//! \brief calls the device function that calculates the macroscopic values
void calculateMacroscopicValues(SPtr<Parameter> para);
private:
//! Class constructor
//! \param parameter shared pointer to instance of class Parameter
CudaKernelManager(SPtr<Parameter> parameter);
//! Class copy constructor
//! \param CudaKernelManager is a reference to CudaKernelManager object
CudaKernelManager(const CudaKernelManager&);
//! \property para is a shared pointer to an object of Parameter
SPtr<Parameter> parameter;
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment