Skip to content
Snippets Groups Projects
Commit 8c55a511 authored by Martin Schönherr's avatar Martin Schönherr :speech_balloon:
Browse files

refactor all navier stokes inits

parent 2c4e5b09
No related branches found
No related tags found
1 merge request!295Clean up init GPU
Showing
with 336 additions and 91 deletions
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#include "LBM/LB.h" #include "LBM/LB.h"
#include "lbm/constants/D3Q27.h" #include "lbm/constants/D3Q27.h"
#include <basics/constants/NumericConstants.h> #include <basics/constants/NumericConstants.h>
...@@ -8,7 +38,8 @@ using namespace vf::lbm::dir; ...@@ -8,7 +38,8 @@ using namespace vf::lbm::dir;
#include <stdio.h> #include <stdio.h>
__global__ void LB_Init_Comp_SP_27(unsigned int* neighborX, __global__ void InitNavierStokesCompressible_Device(
unsigned int* neighborX,
unsigned int* neighborY, unsigned int* neighborY,
unsigned int* neighborZ, unsigned int* neighborZ,
unsigned int* geoD, unsigned int* geoD,
...@@ -179,7 +210,7 @@ __global__ void LB_Init_Comp_SP_27(unsigned int* neighborX, ...@@ -179,7 +210,7 @@ __global__ void LB_Init_Comp_SP_27(unsigned int* neighborX,
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
__global__ void LB_Init_Comp_Neq_SP_27( unsigned int* neighborX, __global__ void InitNavierStokesCompressibleNonEquilibrium_Device( unsigned int* neighborX,
unsigned int* neighborY, unsigned int* neighborY,
unsigned int* neighborZ, unsigned int* neighborZ,
unsigned int* neighborWSB, unsigned int* neighborWSB,
......
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#ifndef InitNavierStokesCompressible_Device_H
#define InitNavierStokesCompressible_Device_H
#include <DataTypes.h>
#include <curand.h>
__global__ void InitNavierStokesCompressible_Device(unsigned int* neighborX,
unsigned int* neighborY,
unsigned int* neighborZ,
unsigned int* geoD,
real* rho,
real* ux,
real* uy,
real* uz,
unsigned int size_Mat,
real* DD,
bool EvenOrOdd);
__global__ void InitNavierStokesCompressibleNonEquilibrium_Device(unsigned int* neighborX,
unsigned int* neighborY,
unsigned int* neighborZ,
unsigned int* neighborWSB,
unsigned int* geoD,
real* rho,
real* ux,
real* uy,
real* uz,
unsigned int size_Mat,
real* DD,
real omega,
bool EvenOrOdd);
#endif
\ No newline at end of file
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#include "InitNavierStokesIncompressible.h"
#include "InitNavierStokesIncompressible_Device.cuh"
#include "Parameter/Parameter.h"
#include <cuda_helper/CudaGrid.h>
std::shared_ptr<PreProcessorStrategy> InitNavierStokesIncompressible::getNewInstance(std::shared_ptr<Parameter> para)
{
return std::shared_ptr<PreProcessorStrategy>(new InitNavierStokesIncompressible(para));
}
void InitNavierStokesIncompressible::init(int level)
{
vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->numberOfNodes);
InitNavierStokesIncompressible_Device<<<grid.grid, grid.threads>>>(
para->getParD(level)->neighborX,
para->getParD(level)->neighborY,
para->getParD(level)->neighborZ,
para->getParD(level)->typeOfGridNode,
para->getParD(level)->rho,
para->getParD(level)->velocityX,
para->getParD(level)->velocityY,
para->getParD(level)->velocityZ,
para->getParD(level)->numberOfNodes,
para->getParD(level)->distributions.f[0],
para->getParD(level)->isEvenTimestep);
getLastCudaError("LB_Init_SP_27 execution failed");
}
bool InitNavierStokesIncompressible::checkParameter()
{
return false;
}
InitNavierStokesIncompressible::InitNavierStokesIncompressible(std::shared_ptr<Parameter> para)
{
this->para = para;
}
InitNavierStokesIncompressible::InitNavierStokesIncompressible()
{
}
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#ifndef INIT_SP27_H
#define INIT_SP27_H
#include "PreProcessor/PreProcessorStrategy/PreProcessorStrategy.h"
#include <memory>
class Parameter;
class InitNavierStokesIncompressible : public PreProcessorStrategy
{
public:
static std::shared_ptr<PreProcessorStrategy> getNewInstance(std::shared_ptr< Parameter> para);
void init(int level);
bool checkParameter();
private:
InitNavierStokesIncompressible();
InitNavierStokesIncompressible(std::shared_ptr< Parameter> para);
std::shared_ptr< Parameter> para;
};
#endif
\ No newline at end of file
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#include "LBM/LB.h" #include "LBM/LB.h"
#include "lbm/constants/D3Q27.h" #include "lbm/constants/D3Q27.h"
#include <basics/constants/NumericConstants.h> #include <basics/constants/NumericConstants.h>
...@@ -6,7 +36,7 @@ using namespace vf::basics::constant; ...@@ -6,7 +36,7 @@ using namespace vf::basics::constant;
using namespace vf::lbm::dir; using namespace vf::lbm::dir;
#include "math.h" #include "math.h"
__global__ void LB_Init_SP_27(unsigned int* neighborX, __global__ void InitNavierStokesIncompressible_Device(unsigned int* neighborX,
unsigned int* neighborY, unsigned int* neighborY,
unsigned int* neighborZ, unsigned int* neighborZ,
unsigned int* geoD, unsigned int* geoD,
......
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#ifndef InitNavierStokesIncompressible_Device_H
#define InitNavierStokesIncompressible_Device_H
#include <DataTypes.h>
#include <curand.h>
__global__ void InitNavierStokesIncompressible_Device(
unsigned int* neighborX,
unsigned int* neighborY,
unsigned int* neighborZ,
unsigned int* geoD,
real* rho,
real* ux,
real* uy,
real* uz,
unsigned int size_Mat,
real* DD,
bool EvenOrOdd);
#endif
\ No newline at end of file
#include "InitSP27.h"
#include "InitSP27_Device.cuh"
#include "Parameter/Parameter.h"
#include <cuda_helper/CudaGrid.h>
std::shared_ptr<PreProcessorStrategy> InitSP27::getNewInstance(std::shared_ptr<Parameter> para)
{
return std::shared_ptr<PreProcessorStrategy>(new InitSP27(para));
}
void InitSP27::init(int level)
{
vf::cuda::CudaGrid grid = vf::cuda::CudaGrid(para->getParD(level)->numberofthreads, para->getParD(level)->numberOfNodes);
LB_Init_SP_27 <<< grid.grid, grid.threads >>>(
para->getParD(level)->neighborX,
para->getParD(level)->neighborY,
para->getParD(level)->neighborZ,
para->getParD(level)->typeOfGridNode,
para->getParD(level)->rho,
para->getParD(level)->velocityX,
para->getParD(level)->velocityY,
para->getParD(level)->velocityZ,
para->getParD(level)->numberOfNodes,
para->getParD(level)->distributions.f[0],
para->getParD(level)->isEvenTimestep);
getLastCudaError("LB_Init_SP_27 execution failed");
}
bool InitSP27::checkParameter()
{
return false;
}
InitSP27::InitSP27(std::shared_ptr<Parameter> para)
{
this->para = para;
}
InitSP27::InitSP27()
{
}
#ifndef INIT_SP27_H
#define INIT_SP27_H
#include "PreProcessor/PreProcessorStrategy/PreProcessorStrategy.h"
#include <memory>
class Parameter;
class InitSP27 : public PreProcessorStrategy
{
public:
static std::shared_ptr<PreProcessorStrategy> getNewInstance(std::shared_ptr< Parameter> para);
void init(int level);
bool checkParameter();
private:
InitSP27();
InitSP27(std::shared_ptr< Parameter> para);
std::shared_ptr< Parameter> para;
};
#endif
\ No newline at end of file
#ifndef LB_INIT_SP27_H
#define LB_INIT_SP27_H
#include <DataTypes.h>
#include <curand.h>
__global__ void LB_Init_SP_27(unsigned int* neighborX,
unsigned int* neighborY,
unsigned int* neighborZ,
unsigned int* geoD,
real* rho,
real* ux,
real* uy,
real* uz,
unsigned int size_Mat,
real* DD,
bool EvenOrOdd);
#endif
\ No newline at end of file
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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/>.
//
//! \author Martin Schoenherr
//=======================================================================================
#ifndef PRE_PROCESSOR_TYPE_H #ifndef PRE_PROCESSOR_TYPE_H
#define PRE_PROCESSOR_TYPE_H #define PRE_PROCESSOR_TYPE_H
enum PreProcessorType enum PreProcessorType
{ {
InitSP27, InitNavierStokesIncompressible,
InitCompSP27, InitNavierStokesCompressible,
InitF3, InitK18K20NavierStokesCompressible,
InitIncompAD7, InitIncompAD7,
InitIncompAD27, InitIncompAD27,
InitCompAD7, InitCompAD7,
......
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