diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp index f37a5430048dbc1fabdfee9a91fa0c9f315e61e5..a32bbd70e396dae3dc5699690e4b5d90c621a6dc 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.cpp @@ -61,6 +61,10 @@ Parameter::Parameter() this->setVelocityLB((real)0.01); + this->setSc((real)1.0); + + this->setG_r((real)0.0); + this->setViscosityRatio((real)1.0); this->setVelocityRatio((real)1.0); @@ -72,6 +76,10 @@ Parameter::Parameter() this->setPathAndFilename(this->getOutputPath() + "/" + this->getOutputPrefix()); this->setlimitOfNodesForVTK((uint)30000000); + + ////////////////////////////////////////////////////////////////////////// + // Advection Diffusion + this->setIsADcalculationOn(false); } Parameter::~Parameter() { @@ -94,12 +102,16 @@ void Parameter::initParameter() parametersOnHost->numberofthreads = 64; parametersOnHost->omega = (real)1.0/((real)3.0*this->viscosityLB+(real)0.5); parametersOnHost->isEvenTimestep = true; + // set diffusivity + parametersOnHost->diffusivity = (real)0.01; //device parametersOnDevice = new ParameterStruct; parametersOnDevice->numberofthreads = parametersOnHost->numberofthreads; parametersOnDevice->omega = parametersOnHost->omega; parametersOnDevice->isEvenTimestep = parametersOnHost->isEvenTimestep; + // set diffusivity + parametersOnDevice->diffusivity = parametersOnHost->diffusivity; } @@ -138,6 +150,14 @@ void Parameter::setPathAndFilename(std::string pathAndFilename) { this->pathAndFilename = pathAndFilename; } +void Parameter::setIsADcalculationOn(bool calcAD) +{ + this->calcAD = calcAD; +} +void Parameter::setIsBodyForceOn(bool calcBF) +{ + this->calcBF = calcBF; +} void Parameter::setPrintFiles(bool printfiles) { this->printFiles = printfiles; @@ -170,6 +190,18 @@ void Parameter::setRe(real Re) { this->Re = Re; } +void Parameter::setSc(real Sc) +{ + this->Sc = Sc; +} +void Parameter::setNx(real Nx) +{ + this->Nx = Nx; +} +void Parameter::setG_r(real g_r) +{ + this->g_r = g_r; +} void Parameter::setMemsizeGPU(double addMemory, bool reset) { if (reset == true) @@ -204,6 +236,14 @@ bool Parameter::getIsTimestepEven() { return this->parametersOnHost->isEvenTimestep; } +bool Parameter::getIsADcalculationOn() +{ + return this->calcAD; +} +bool Parameter::getIsBodyForceOn() +{ + return this->calcBF; +} int Parameter::getD3Qxx() { return this->D3Qxx; @@ -268,6 +308,18 @@ real Parameter::getRe() { return this->Re; } +real Parameter::getSc() +{ + return this->Sc; +} +real Parameter::getNx() +{ + return this->Nx; +} +real Parameter::getG_r() +{ + return this->g_r; +} double Parameter::getMemsizeGPU() { return this->memsizeGPU; @@ -276,3 +328,29 @@ double Parameter::getMemsizeGPU() +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// initial condition fluid +void Parameter::setInitialCondition(std::function<void(real, real, real, real&, real&, real&, real&)> initialCondition) +{ + this->initialCondition = initialCondition; +} + +std::function<void(real, real, real, real&, real&, real&, real&)>& Parameter::getInitialCondition() +{ + return this->initialCondition; +} + +// initial condition concentration +void Parameter::setInitialConditionAD(std::function<void(real, real, real, real&, real)> initialConditionAD) +{ + this->initialConditionAD = initialConditionAD; +} + +std::function<void(real, real, real, real&, real)>& Parameter::getInitialConditionAD() +{ + return this->initialConditionAD; +} +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index 4fc4ecb89b64b9809f2c48c8a15f9e471a657b9d..b74624c7398cbbdae016e9f91830392e45a1119b 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -33,6 +33,7 @@ #ifndef PARAMETER_H #define PARAMETER_H +#include <functional> #include "LBM/LB.h" #include "PointerDefinitions.h" #include "VirtualFluids_GPU_export.h" @@ -72,7 +73,12 @@ struct ParameterStruct{ uint numberOfNodes; //! \brief stores the size of the memory consumption for real/int values of the above arrays uint mem_size_real, mem_size_int; - ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the slip boundary condition data + QforBoundaryConditions slipBC; + //! \brief number of lattice nodes for the slip boundary condition + uint numberOfSlipBCnodes; + ////////////////////////////////////////////////////////////////////////// //! \brief stores the velocity boundary condition data QforBoundaryConditions inflowBC; //! \brief number of lattice nodes for the velocity boundary condition @@ -80,6 +86,18 @@ struct ParameterStruct{ ////////////////////////////////////////////////////////////////////////// //! \brief sets the forcing uniform on every fluid node in all three space dimensions real *forcing; + + ////////////////////////////////////////////////////////////////////////// + // Advection Diffusion + ////////////////////////////////////////////////////////////////////////// + //! \brief stores the diffusivity + real diffusivity; + //! \brief stores the value for omega (for the diffusivity) + real omegaD; + //! \brief stores a field of concentration values + real *concentration; + //! \brief store all distribution functions for the D3Q27 Advection Diffusion field + Distributions27 distributionsAD; }; //! \class Parameter implements the singleton design pattern. @@ -128,7 +146,13 @@ public: //! \brief sets the complete string for the vtk-files with results //! \param string "fname" represents the combination of path and prefix void setPathAndFilename(std::string pathAndFilename); - //! \brief sets the status, if the vtk files should be printed + //! \brief sets the status, if Advection Diffusion should be calculated + //! \param if calcAD is true, the Advection Diffusion will be calculated + void setIsADcalculationOn(bool calcAD); + //! \brief sets the status, if Advection Diffusion should be calculated + //! \param if calcAD is true, the Advection Diffusion will be calculated + void setIsBodyForceOn(bool calcBF); + //! \brief sets the status, if the vtk files should be printed //! \param if printfiles is true, the vtk files will be printed void setPrintFiles(bool printfiles); //! \brief sets the viscosity in LB units @@ -152,7 +176,16 @@ public: //! \brief sets the Reynolds number (Re) for the simulation //! \param Reynolds number (Re) void setRe(real Re); - //! \brief sets the necessary memory on the device(s)/GPU(s) + //! \brief sets the Schmidt number (Sc) for the simulation + //! \param sets the Schmidt number (Sc) + void setSc(real Sc); + //! \brief sets the number of nodes used to discretize characteristic length scale L + //! \param number of nodes (Nx) used to discretize characteristic length scale L + void setNx(real Nx); + //! \brief sets reduced acceleration due to gravity in buoyancy driven flow (LBM units) + //! \param reduced acceleration due to gravity in buoyancy driven flow (LBM units) + void setG_r(real g_r); + //! \brief sets the necessary memory on the device(s)/GPU(s) //! \param addMemory is the amount of additional memory //! \param reset decides if the value for overall GPU memory should be set to zero void setMemsizeGPU(double addMemory, bool reset); @@ -164,7 +197,11 @@ public: uint getlimitOfNodesForVTK(); //! \brief return if the timestep is even or odd bool getIsTimestepEven(); - //! \brief return if the simulation should write VTK files + //! \brief return true if Advection Diffusion calculation is switched on + bool getIsADcalculationOn(); + //! \brief return true if Advection Diffusion calculation is switched on + bool getIsBodyForceOn(); + //! \brief return if the simulation should write VTK files bool getPrintFiles(); //! \brief return the number of neighbors of a lattice node (stencil) int getD3Qxx(); @@ -196,10 +233,24 @@ public: real getPressureRatio(); //! \brief return the Reynolds number real getRe(); - //! \brief return the used device memory + //! \brief return the Schmidt number + real getSc(); + //! \brief return number of nodes used to discretize characteristic length scale L + real getNx(); + //! \brief return reduced acceleration due to gravity in buoyancy driven flow (LBM units) + real getG_r(); + //! \brief return the used device memory double getMemsizeGPU(); - ////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////// + // initial condition fluid + void setInitialCondition(std::function<void(real, real, real, real &, real &, real &, real &)> initialCondition); + std::function<void(real, real, real, real &, real &, real &, real &)> &getInitialCondition(); + // initial condition concentration + void setInitialConditionAD(std::function<void(real, real, real, real &, real)> initialConditionAD); + std::function<void(real, real, real, real &, real)> &getInitialConditionAD(); + + ////////////////////////////////////////////////////////////////////////// //! Class destructor ~Parameter(); protected: @@ -218,19 +269,35 @@ private: uint timestepStartOut; //! \brief Reynolds number real Re; - //! \brief viscosity and velocity in LB units + //! \brief Schmidt number + real Sc; + //! \brief number of nodes used to discretize characteristic length scale L + real Nx; + //! \brief reduced acceleration due to gravity in buoyancy driven flow (LBM units) + real g_r; + //! \brief viscosity and velocity in LB units real viscosityLB, velocityLB; //! \brief ratio SI units / LB units for viscosity, velocity, density and pressure real viscosityRatio, velocityRatio; real densityRatio, pressRatio; //! \brief used device memory double memsizeGPU; - //! \brief write output files on/off + //! \brief Advection Diffusion calculation on/off + bool calcAD; + //! \brief Include body forces on/off + bool calcBF; + //! \brief write output files on/off bool printFiles; //! \brief strings to store output path, prefix and combination of both std::string pathAndFilename, outputPath, outputPrefix; - //! \brief pointer to LB-parameter struct on host system + //////////////////////////////////////////////////////////////////////////// + //! \brief initial condition fluid + std::function<void(real, real, real, real &, real &, real &, real &)> initialCondition; + //! \brief initial condition concentration + std::function<void(real, real, real, real &, real)> initialConditionAD; + + //! \brief pointer to LB-parameter struct on host system ParameterStruct* parametersOnHost; //! \brief pointer to LB-parameter struct on device/GPU ParameterStruct* parametersOnDevice;