diff --git a/apps/gpu/Cases_1_3_5_7/CMakeLists.txt b/apps/gpu/Cases_1_3_5_7/CMakeLists.txt deleted file mode 100644 index 6062e81f889869e8eed4e32f3efed8eb29dad1fb..0000000000000000000000000000000000000000 --- a/apps/gpu/Cases_1_3_5_7/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(Cases_1_3_5_7 LANGUAGES CUDA CXX) - -vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU GksMeshAdapter GksGpu FILES Cases_1_3_5_7.cpp) diff --git a/apps/gpu/Cases_2_4_6_8/CMakeLists.txt b/apps/gpu/Cases_2_4_6_8/CMakeLists.txt deleted file mode 100644 index f05abae095b523bd5e572c3c35750ffc7cf3a073..0000000000000000000000000000000000000000 --- a/apps/gpu/Cases_2_4_6_8/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(Cases_2_4_6_8 LANGUAGES CUDA CXX) - -vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU GksMeshAdapter GksGpu FILES Cases_2_4_6_8.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case1/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case1/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..20f96e15e520378ccbf7542ae005ef6f947ac878 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case1/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case1 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case1.cpp) diff --git a/apps/gpu/Cases_2_4_6_8/Cases_2_4_6_8.cpp b/apps/gpu/DiluteGravityCurrents_Case1/DiluteGravityCurrents_Case1.cpp similarity index 91% rename from apps/gpu/Cases_2_4_6_8/Cases_2_4_6_8.cpp rename to apps/gpu/DiluteGravityCurrents_Case1/DiluteGravityCurrents_Case1.cpp index 5d1d5d3f0511eaee7cd19a68f108288ff022f0de..1dcfb02ccd9e355fbbe2faad51bf3fce15e980bd 100644 --- a/apps/gpu/Cases_2_4_6_8/Cases_2_4_6_8.cpp +++ b/apps/gpu/DiluteGravityCurrents_Case1/DiluteGravityCurrents_Case1.cpp @@ -26,7 +26,7 @@ // 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 Cases_2_4_6_8.cpp +//! \file DiluteGravityCurrents_Case1.cpp //! \ingroup Applications //! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye //======================================================================================= @@ -74,16 +74,16 @@ int main(int argc, char *argv[]) ////////////////////////////////////////////////////////////////////////// // Simulation parameters ////////////////////////////////////////////////////////////////////////// - std::string path("Insert Path to Results Directory Here"); - std::string simulationName("Insert Simulation Name Here"); + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case1"); - const real Re = 1000; // Set Reynolds number for given case + const real Re = 895; // Set Reynolds number for given case const real Sc = 1; // Set Schmidt number const real L = 1; // Set height of channel (H) - const uint nx = 100; // Set the number of nodes discrtizing channel depth + const uint nx = 100; // Set the number of nodes discretizing channel depth const real Gate = L; // Set distance to gate (x0) - // this testcase is implemented for LBM-GPU only + // this testcase is implemented for LBM(GPU) only LbmOrGks lbmOrGks = LBM; ////////////////////////////////////////////////////////////////////////// @@ -109,9 +109,9 @@ int main(int argc, char *argv[]) real dx = L / real(nx); - gridBuilder->addCoarseGrid(0 * L, 0 * L, 0 * L, 15 * L, 1 * L, 1 * L, dx); + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); - gridBuilder->setPeriodicBoundaryCondition(false, false, false); + gridBuilder->setPeriodicBoundaryCondition(true, true, false); gridBuilder->buildGrids(lbmOrGks, false); @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) if (lbmOrGks == LBM) { SPtr<Parameter> para = Parameter::make(); - real DeltaT = 0.5 * (real)nx / para->getVelocityLB(); + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); const uint timeStepOut = (int)DeltaT; const uint timeStepEnd = (int)DeltaT * 12; @@ -179,7 +179,14 @@ int main(int argc, char *argv[]) // set concentration if (para->getIsADcalculationOn()) { - para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration, real dist) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + real dist = 0; + real rand_min = -0.005, rand_max = 0.005; + real random = ((real)rand()) / (real)RAND_MAX; + real diff = rand_max - rand_min; + real r = random * diff; + dist = rand_min + r; + if (sqrt(coordX * coordX) < Gate + dist) { concentration = (real)1.0; } else { @@ -192,10 +199,6 @@ int main(int argc, char *argv[]) // set boundary conditions ////////////////////////////////////////////////////////////////////////// - gridBuilder->setNoSlipBoundaryCondition(SideType::PX); - gridBuilder->setNoSlipBoundaryCondition(SideType::MX); - gridBuilder->setNoSlipBoundaryCondition(SideType::PY); - gridBuilder->setNoSlipBoundaryCondition(SideType::MY); gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); diff --git a/apps/gpu/DiluteGravityCurrents_Case2/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case2/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..403aac7d3a8184c3e83432f4c67e1e7659174f3b --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case2/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case2 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case2.cpp) diff --git a/apps/gpu/Cases_1_3_5_7/Cases_1_3_5_7.cpp b/apps/gpu/DiluteGravityCurrents_Case2/DiluteGravityCurrents_Case2.cpp similarity index 96% rename from apps/gpu/Cases_1_3_5_7/Cases_1_3_5_7.cpp rename to apps/gpu/DiluteGravityCurrents_Case2/DiluteGravityCurrents_Case2.cpp index 1f9a7c31d942314ea8a833c4f8850a551c47018f..5e8efdd85dc0788540e216d6f44206453b5c492b 100644 --- a/apps/gpu/Cases_1_3_5_7/Cases_1_3_5_7.cpp +++ b/apps/gpu/DiluteGravityCurrents_Case2/DiluteGravityCurrents_Case2.cpp @@ -26,7 +26,7 @@ // 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 Cases_1_3_5_7.cpp +//! \file DiluteGravityCurrents_Case2.cpp //! \ingroup Applications //! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye //======================================================================================= @@ -74,13 +74,13 @@ int main(int argc, char *argv[]) ////////////////////////////////////////////////////////////////////////// // Simulation parameters ////////////////////////////////////////////////////////////////////////// - std::string path("Insert Path to Results Directory Here"); - std::string simulationName("Insert Simulation Name Here"); + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case2"); - const real Re = 8950; // Set Reynolds number for given case + const real Re = 1000; // Set Reynolds number for given case const real Sc = 1; // Set Schmidt number const real L = 1; // Set height of channel (H) - const uint nx = 100; // Set the number of nodes discrtizing channel depth + const uint nx = 100; // Set the number of nodes discretizing channel depth const real Gate = L; // Set distance to gate (x0) // this testcase is implemented for LBM(GPU) only @@ -179,8 +179,8 @@ int main(int argc, char *argv[]) // set concentration if (para->getIsADcalculationOn()) { - para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration, real dist) { - if (sqrt(coordX * coordX) < Gate + dist) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + if (sqrt(coordX * coordX) < Gate) { concentration = (real)1.0; } else { concentration = (real)0.0; diff --git a/apps/gpu/DiluteGravityCurrents_Case3/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case3/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..807edc7c144dfcae44ab8a6e8ed277f19672d098 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case3/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case3 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case3.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case3/DiluteGravityCurrents_Case3.cpp b/apps/gpu/DiluteGravityCurrents_Case3/DiluteGravityCurrents_Case3.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b6add0b37443e814883c5e81d105da38e19d3212 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case3/DiluteGravityCurrents_Case3.cpp @@ -0,0 +1,235 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 DiluteGravityCurrents_Case3.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye +//======================================================================================= +#define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> +#include <math.h> +#include <memory> +#include <sstream> +#include <stdexcept> +#include <string> + +#include "PointerDefinitions.h" + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" +#include "Core/VectorTypes.h" + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/GridFactory.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + srand(time(nullptr)); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case3"); + + const real Re = 3450; // Set Reynolds number for given case + const real Sc = 1; // Set Schmidt number + const real L = 1; // Set height of channel (H) + const uint nx = 100; // Set the number of nodes discretizing channel depth + const real Gate = L; // Set distance to gate (x0) + + // this testcase is implemented for LBM(GPU) only + LbmOrGks lbmOrGks = LBM; + + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// + + auto gridFactory = GridFactory::make(); + gridFactory->setGridStrategy(Device::CPU); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// + + real dx = L / real(nx); + + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); + + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// + + if (lbmOrGks == LBM) { + SPtr<Parameter> para = Parameter::make(); + + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); + + const uint timeStepOut = (int)DeltaT; + const uint timeStepEnd = (int)DeltaT * 12; + std::cout << "DeltaT=" << timeStepOut << "\n"; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// + const real velocityLB = para->getVelocityLB(); // Using default velocity in Parameter constructor (LB units) + const real dt = velocityLB / nx; + const real velocity = velocityLB * dx / dt; + + const real viscosityLB = nx * velocityLB / Re; // LB units + + const real g_r = (velocityLB * velocityLB) / nx; // LB units + + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// + + para->setOutputPath(path); + para->setOutputPrefix(simulationName); + + para->setPathAndFilename(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); + + para->setVelocityRatio(velocity / velocityLB); + + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); + + para->setIsADcalculationOn(true); + para->setIsBodyForceOn(true); + + para->setSc((real)Sc); + para->setNx((real)nx); + para->setG_r((real)g_r); + ////////////////////////////////////////////////////////////////////////// + // set initial conditions + ////////////////////////////////////////////////////////////////////////// + para->setInitialCondition( + [&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; + vy = (real)0.0; + vz = (real)0.0; + }); + + // set concentration + if (para->getIsADcalculationOn()) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + real dist = 0; + real rand_min = -0.005, rand_max = 0.005; + real random = ((real)rand()) / (real)RAND_MAX; + real diff = rand_max - rand_min; + real r = random * diff; + dist = rand_min + r; + + if (sqrt(coordX * coordX) < Gate + dist) { + concentration = (real)1.0; + } else { + concentration = (real)0.0; + } + }); + } + + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// + + gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// + + Simulation sim; + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); + } + + } catch (const std::bad_alloc &e) { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception &e) { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + } + + return 0; +} diff --git a/apps/gpu/DiluteGravityCurrents_Case4/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case4/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..ffd04d68ea0ca6ecac67b76e3fc30851b7fee486 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case4/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case4 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case4.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case4/DiluteGravityCurrents_Case4.cpp b/apps/gpu/DiluteGravityCurrents_Case4/DiluteGravityCurrents_Case4.cpp new file mode 100644 index 0000000000000000000000000000000000000000..940a08d55a2de93f1762e526ca79a355d9f45c0c --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case4/DiluteGravityCurrents_Case4.cpp @@ -0,0 +1,228 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 DiluteGravityCurrents_Case4.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye +//======================================================================================= +#define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> +#include <math.h> +#include <memory> +#include <sstream> +#include <stdexcept> +#include <string> + +#include "PointerDefinitions.h" + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" +#include "Core/VectorTypes.h" + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/GridFactory.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + srand(time(nullptr)); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case4"); + + const real Re = 5000; // Set Reynolds number for given case + const real Sc = 1; // Set Schmidt number + const real L = 1; // Set height of channel (H) + const uint nx = 100; // Set the number of nodes discretizing channel depth + const real Gate = L; // Set distance to gate (x0) + + // this testcase is implemented for LBM(GPU) only + LbmOrGks lbmOrGks = LBM; + + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// + + auto gridFactory = GridFactory::make(); + gridFactory->setGridStrategy(Device::CPU); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// + + real dx = L / real(nx); + + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); + + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// + + if (lbmOrGks == LBM) { + SPtr<Parameter> para = Parameter::make(); + + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); + + const uint timeStepOut = (int)DeltaT; + const uint timeStepEnd = (int)DeltaT * 12; + std::cout << "DeltaT=" << timeStepOut << "\n"; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// + const real velocityLB = para->getVelocityLB(); // Using default velocity in Parameter constructor (LB units) + const real dt = velocityLB / nx; + const real velocity = velocityLB * dx / dt; + + const real viscosityLB = nx * velocityLB / Re; // LB units + + const real g_r = (velocityLB * velocityLB) / nx; // LB units + + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// + + para->setOutputPath(path); + para->setOutputPrefix(simulationName); + + para->setPathAndFilename(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); + + para->setVelocityRatio(velocity / velocityLB); + + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); + + para->setIsADcalculationOn(true); + para->setIsBodyForceOn(true); + + para->setSc((real)Sc); + para->setNx((real)nx); + para->setG_r((real)g_r); + ////////////////////////////////////////////////////////////////////////// + // set initial conditions + ////////////////////////////////////////////////////////////////////////// + para->setInitialCondition( + [&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; + vy = (real)0.0; + vz = (real)0.0; + }); + + // set concentration + if (para->getIsADcalculationOn()) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + if (sqrt(coordX * coordX) < Gate) { + concentration = (real)1.0; + } else { + concentration = (real)0.0; + } + }); + } + + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// + + gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// + + Simulation sim; + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); + } + + } catch (const std::bad_alloc &e) { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception &e) { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + } + + return 0; +} diff --git a/apps/gpu/DiluteGravityCurrents_Case5/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case5/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..090d9da555dc3c8d30632c217692293cb99d305f --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case5/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case5 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case5.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case5/DiluteGravityCurrents_Case5.cpp b/apps/gpu/DiluteGravityCurrents_Case5/DiluteGravityCurrents_Case5.cpp new file mode 100644 index 0000000000000000000000000000000000000000..91d6f6015a2a2c7e2f7d9b4b153bc4c4bc7ef460 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case5/DiluteGravityCurrents_Case5.cpp @@ -0,0 +1,235 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 DiluteGravityCurrents_Case5.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye +//======================================================================================= +#define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> +#include <math.h> +#include <memory> +#include <sstream> +#include <stdexcept> +#include <string> + +#include "PointerDefinitions.h" + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" +#include "Core/VectorTypes.h" + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/GridFactory.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + srand(time(nullptr)); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case5"); + + const real Re = 8950; // Set Reynolds number for given case + const real Sc = 1; // Set Schmidt number + const real L = 1; // Set height of channel (H) + const uint nx = 100; // Set the number of nodes discretizing channel depth + const real Gate = L; // Set distance to gate (x0) + + // this testcase is implemented for LBM(GPU) only + LbmOrGks lbmOrGks = LBM; + + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// + + auto gridFactory = GridFactory::make(); + gridFactory->setGridStrategy(Device::CPU); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// + + real dx = L / real(nx); + + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); + + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// + + if (lbmOrGks == LBM) { + SPtr<Parameter> para = Parameter::make(); + + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); + + const uint timeStepOut = (int)DeltaT; + const uint timeStepEnd = (int)DeltaT * 12; + std::cout << "DeltaT=" << timeStepOut << "\n"; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// + const real velocityLB = para->getVelocityLB(); // Using default velocity in Parameter constructor (LB units) + const real dt = velocityLB / nx; + const real velocity = velocityLB * dx / dt; + + const real viscosityLB = nx * velocityLB / Re; // LB units + + const real g_r = (velocityLB * velocityLB) / nx; // LB units + + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// + + para->setOutputPath(path); + para->setOutputPrefix(simulationName); + + para->setPathAndFilename(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); + + para->setVelocityRatio(velocity / velocityLB); + + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); + + para->setIsADcalculationOn(true); + para->setIsBodyForceOn(true); + + para->setSc((real)Sc); + para->setNx((real)nx); + para->setG_r((real)g_r); + ////////////////////////////////////////////////////////////////////////// + // set initial conditions + ////////////////////////////////////////////////////////////////////////// + para->setInitialCondition( + [&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; + vy = (real)0.0; + vz = (real)0.0; + }); + + // set concentration + if (para->getIsADcalculationOn()) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + real dist = 0; + real rand_min = -0.005, rand_max = 0.005; + real random = ((real)rand()) / (real)RAND_MAX; + real diff = rand_max - rand_min; + real r = random * diff; + dist = rand_min + r; + + if (sqrt(coordX * coordX) < Gate + dist) { + concentration = (real)1.0; + } else { + concentration = (real)0.0; + } + }); + } + + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// + + gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// + + Simulation sim; + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); + } + + } catch (const std::bad_alloc &e) { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception &e) { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + } + + return 0; +} diff --git a/apps/gpu/DiluteGravityCurrents_Case6/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case6/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..d0a16f7912c985c5bca930c0da08a7800b0114a0 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case6/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case6 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case6.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case6/DiluteGravityCurrents_Case6.cpp b/apps/gpu/DiluteGravityCurrents_Case6/DiluteGravityCurrents_Case6.cpp new file mode 100644 index 0000000000000000000000000000000000000000..52b57916d139510678d73d16aa3355a33461ca2f --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case6/DiluteGravityCurrents_Case6.cpp @@ -0,0 +1,228 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 DiluteGravityCurrents_Case6.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye +//======================================================================================= +#define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> +#include <math.h> +#include <memory> +#include <sstream> +#include <stdexcept> +#include <string> + +#include "PointerDefinitions.h" + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" +#include "Core/VectorTypes.h" + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/GridFactory.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + srand(time(nullptr)); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case6"); + + const real Re = 10000;// Set Reynolds number for given case + const real Sc = 1; // Set Schmidt number + const real L = 1; // Set height of channel (H) + const uint nx = 100; // Set the number of nodes discretizing channel depth + const real Gate = L; // Set distance to gate (x0) + + // this testcase is implemented for LBM(GPU) only + LbmOrGks lbmOrGks = LBM; + + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// + + auto gridFactory = GridFactory::make(); + gridFactory->setGridStrategy(Device::CPU); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// + + real dx = L / real(nx); + + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); + + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// + + if (lbmOrGks == LBM) { + SPtr<Parameter> para = Parameter::make(); + + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); + + const uint timeStepOut = (int)DeltaT; + const uint timeStepEnd = (int)DeltaT * 12; + std::cout << "DeltaT=" << timeStepOut << "\n"; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// + const real velocityLB = para->getVelocityLB(); // Using default velocity in Parameter constructor (LB units) + const real dt = velocityLB / nx; + const real velocity = velocityLB * dx / dt; + + const real viscosityLB = nx * velocityLB / Re; // LB units + + const real g_r = (velocityLB * velocityLB) / nx; // LB units + + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// + + para->setOutputPath(path); + para->setOutputPrefix(simulationName); + + para->setPathAndFilename(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); + + para->setVelocityRatio(velocity / velocityLB); + + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); + + para->setIsADcalculationOn(true); + para->setIsBodyForceOn(true); + + para->setSc((real)Sc); + para->setNx((real)nx); + para->setG_r((real)g_r); + ////////////////////////////////////////////////////////////////////////// + // set initial conditions + ////////////////////////////////////////////////////////////////////////// + para->setInitialCondition( + [&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; + vy = (real)0.0; + vz = (real)0.0; + }); + + // set concentration + if (para->getIsADcalculationOn()) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + if (sqrt(coordX * coordX) < Gate) { + concentration = (real)1.0; + } else { + concentration = (real)0.0; + } + }); + } + + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// + + gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// + + Simulation sim; + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); + } + + } catch (const std::bad_alloc &e) { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception &e) { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + } + + return 0; +} diff --git a/apps/gpu/DiluteGravityCurrents_Case7/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case7/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..caa81b84bd48c093bea3708db8aad39cd24856cb --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case7/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case7 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case7.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case7/DiluteGravityCurrents_Case7.cpp b/apps/gpu/DiluteGravityCurrents_Case7/DiluteGravityCurrents_Case7.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c1266235a6b9e9e99a42cbccdb4cc7b90500c786 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case7/DiluteGravityCurrents_Case7.cpp @@ -0,0 +1,235 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 DiluteGravityCurrents_Case7.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye +//======================================================================================= +#define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> +#include <math.h> +#include <memory> +#include <sstream> +#include <stdexcept> +#include <string> + +#include "PointerDefinitions.h" + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" +#include "Core/VectorTypes.h" + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/GridFactory.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + srand(time(nullptr)); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case7"); + + const real Re = 15000;// Set Reynolds number for given case + const real Sc = 1; // Set Schmidt number + const real L = 1; // Set height of channel (H) + const uint nx = 140; // Set the number of nodes discretizing channel depth + const real Gate = L; // Set distance to gate (x0) + + // this testcase is implemented for LBM(GPU) only + LbmOrGks lbmOrGks = LBM; + + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// + + auto gridFactory = GridFactory::make(); + gridFactory->setGridStrategy(Device::CPU); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// + + real dx = L / real(nx); + + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); + + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// + + if (lbmOrGks == LBM) { + SPtr<Parameter> para = Parameter::make(); + + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); + + const uint timeStepOut = (int)DeltaT; + const uint timeStepEnd = (int)DeltaT * 12; + std::cout << "DeltaT=" << timeStepOut << "\n"; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// + const real velocityLB = para->getVelocityLB(); // Using default velocity in Parameter constructor (LB units) + const real dt = velocityLB / nx; + const real velocity = velocityLB * dx / dt; + + const real viscosityLB = nx * velocityLB / Re; // LB units + + const real g_r = (velocityLB * velocityLB) / nx; // LB units + + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// + + para->setOutputPath(path); + para->setOutputPrefix(simulationName); + + para->setPathAndFilename(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); + + para->setVelocityRatio(velocity / velocityLB); + + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); + + para->setIsADcalculationOn(true); + para->setIsBodyForceOn(true); + + para->setSc((real)Sc); + para->setNx((real)nx); + para->setG_r((real)g_r); + ////////////////////////////////////////////////////////////////////////// + // set initial conditions + ////////////////////////////////////////////////////////////////////////// + para->setInitialCondition( + [&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; + vy = (real)0.0; + vz = (real)0.0; + }); + + // set concentration + if (para->getIsADcalculationOn()) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + real dist = 0; + real rand_min = -0.005, rand_max = 0.005; + real random = ((real)rand()) / (real)RAND_MAX; + real diff = rand_max - rand_min; + real r = random * diff; + dist = rand_min + r; + + if (sqrt(coordX * coordX) < Gate + dist) { + concentration = (real)1.0; + } else { + concentration = (real)0.0; + } + }); + } + + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// + + gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// + + Simulation sim; + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); + } + + } catch (const std::bad_alloc &e) { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception &e) { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + } + + return 0; +} diff --git a/apps/gpu/DiluteGravityCurrents_Case8/CMakeLists.txt b/apps/gpu/DiluteGravityCurrents_Case8/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..dfed3832cc017211b273bc90844d7e0968b5ca32 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case8/CMakeLists.txt @@ -0,0 +1,3 @@ +project(DiluteGravityCurrents_Case8 LANGUAGES CUDA CXX) + +vf_add_library(BUILDTYPE binary PRIVATE_LINK basics GridGenerator VirtualFluids_GPU FILES DiluteGravityCurrents_Case8.cpp) diff --git a/apps/gpu/DiluteGravityCurrents_Case8/DiluteGravityCurrents_Case8.cpp b/apps/gpu/DiluteGravityCurrents_Case8/DiluteGravityCurrents_Case8.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6fe8abaa19941eb6974876a025c290166ddabda0 --- /dev/null +++ b/apps/gpu/DiluteGravityCurrents_Case8/DiluteGravityCurrents_Case8.cpp @@ -0,0 +1,228 @@ +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 DiluteGravityCurrents_Case8.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz, Damilola Adekanye +//======================================================================================= +#define _USE_MATH_DEFINES +#include <exception> +#include <fstream> +#include <iostream> +#include <math.h> +#include <memory> +#include <sstream> +#include <stdexcept> +#include <string> + +#include "PointerDefinitions.h" + +////////////////////////////////////////////////////////////////////////// + +#include "Core/DataTypes.h" +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" +#include "Core/VectorTypes.h" + +////////////////////////////////////////////////////////////////////////// + +#include "GridGenerator/grid/BoundaryConditions/Side.h" +#include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" +#include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" +#include "GridGenerator/grid/GridFactory.h" + +////////////////////////////////////////////////////////////////////////// + +#include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" +#include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" + +////////////////////////////////////////////////////////////////////////// + +int main(int argc, char *argv[]) +{ + srand(time(nullptr)); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("/output/"); + std::string simulationName("DiluteGravityCurrents_Case8"); + + const real Re = 30000;// Set Reynolds number for given case + const real Sc = 1; // Set Schmidt number + const real L = 1; // Set height of channel (H) + const uint nx = 140; // Set the number of nodes discretizing channel depth + const real Gate = L; // Set distance to gate (x0) + + // this testcase is implemented for LBM(GPU) only + LbmOrGks lbmOrGks = LBM; + + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// + + logging::Logger::addStream(&std::cout); + logging::Logger::setDebugLevel(logging::Logger::Level::INFO_LOW); + logging::Logger::timeStamp(logging::Logger::ENABLE); + logging::Logger::enablePrintedRankNumbers(logging::Logger::ENABLE); + + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// + + auto gridFactory = GridFactory::make(); + gridFactory->setGridStrategy(Device::CPU); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); + + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// + + real dx = L / real(nx); + + gridBuilder->addCoarseGrid(-12.5 * L, 0 * L, 0 * L, 12.5 * L, 1.5 * L, 1 * L, dx); + + gridBuilder->setPeriodicBoundaryCondition(true, true, false); + + gridBuilder->buildGrids(lbmOrGks, false); + + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// + + if (lbmOrGks == LBM) { + SPtr<Parameter> para = Parameter::make(); + + real DeltaT = 2.5 * (real)nx / para->getVelocityLB(); + + const uint timeStepOut = (int)DeltaT; + const uint timeStepEnd = (int)DeltaT * 12; + std::cout << "DeltaT=" << timeStepOut << "\n"; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// + const real velocityLB = para->getVelocityLB(); // Using default velocity in Parameter constructor (LB units) + const real dt = velocityLB / nx; + const real velocity = velocityLB * dx / dt; + + const real viscosityLB = nx * velocityLB / Re; // LB units + + const real g_r = (velocityLB * velocityLB) / nx; // LB units + + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; + + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// + + para->setOutputPath(path); + para->setOutputPrefix(simulationName); + + para->setPathAndFilename(para->getOutputPath() + "/" + para->getOutputPrefix()); + + para->setPrintFiles(true); + + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); + + para->setVelocityRatio(velocity / velocityLB); + + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); + + para->setIsADcalculationOn(true); + para->setIsBodyForceOn(true); + + para->setSc((real)Sc); + para->setNx((real)nx); + para->setG_r((real)g_r); + ////////////////////////////////////////////////////////////////////////// + // set initial conditions + ////////////////////////////////////////////////////////////////////////// + para->setInitialCondition( + [&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { + rho = (real)0.0; + vx = (real)0.0; + vy = (real)0.0; + vz = (real)0.0; + }); + + // set concentration + if (para->getIsADcalculationOn()) { + para->setInitialConditionAD([&](real coordX, real coordY, real coordZ, real &concentration) { + if (sqrt(coordX * coordX) < Gate) { + concentration = (real)1.0; + } else { + concentration = (real)0.0; + } + }); + } + + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// + + gridBuilder->setNoSlipBoundaryCondition(SideType::PZ); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// + + SPtr<CudaMemoryManager> cudaMemoryManager = CudaMemoryManager::make(para); + + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager); + + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// + + Simulation sim; + SPtr<FileWriter> fileWriter = SPtr<FileWriter>(new FileWriter()); + sim.init(para, gridGenerator, fileWriter, cudaMemoryManager); + sim.run(); + sim.free(); + } + + } catch (const std::bad_alloc &e) { + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception &e) { + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; + } + + return 0; +} diff --git a/gpu.cmake b/gpu.cmake index f4f74ea741c249c706a98e25efe3a90fbfecf171..ca3929cc1fdc5d15af4b82cd1158ed5b0ad93d10 100644 --- a/gpu.cmake +++ b/gpu.cmake @@ -16,5 +16,11 @@ add_subdirectory(src/gpu/GksMeshAdapter) add_subdirectory(src/gpu/GksGpu) add_subdirectory(apps/gpu/LidDrivenCavityGPU) -add_subdirectory(apps/gpu/Cases_1_3_5_7) -add_subdirectory(apps/gpu/Cases_2_4_6_8) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case1) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case2) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case3) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case4) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case5) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case6) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case7) +add_subdirectory(apps/gpu/DiluteGravityCurrents_Case8) diff --git a/src/gpu/VirtualFluids_GPU/AdvectionDiffusion/AdvectionDiffusion.cpp b/src/gpu/VirtualFluids_GPU/AdvectionDiffusion/AdvectionDiffusion.cpp index 192d8b7d38558538183cf143768b73fc4eec7f5f..3c408bd657fe33c48a565d6a0b8ec39bdad978a6 100644 --- a/src/gpu/VirtualFluids_GPU/AdvectionDiffusion/AdvectionDiffusion.cpp +++ b/src/gpu/VirtualFluids_GPU/AdvectionDiffusion/AdvectionDiffusion.cpp @@ -95,17 +95,10 @@ void setInitialNodeValuesAD(SPtr<Parameter> para, SPtr<CudaMemoryManager> cudaMe const real coordZ = para->getParH()->coordinateZ[j]; real concentration; - real dist = 0; - - //float rand_min=-0.01, rand_max=0.01; - //float random = ((float) rand()) / (float) RAND_MAX; - //float diff = rand_max - rand_min; - //float r = random * diff; - //dist = rand_min + r; // call functor object with initial condition if (para->getInitialConditionAD()) { - para->getInitialConditionAD()(coordX, coordY, coordZ, concentration, dist); + para->getInitialConditionAD()(coordX, coordY, coordZ, concentration); } else { concentration = real(0.0); } diff --git a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h index b74624c7398cbbdae016e9f91830392e45a1119b..24b472f5ac3230e2925389d66b7a840f813f5e31 100644 --- a/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h +++ b/src/gpu/VirtualFluids_GPU/Parameter/Parameter.h @@ -39,7 +39,7 @@ #include "VirtualFluids_GPU_export.h" //! \struct ParameterStruct -//! \brief struct holds and manages the LB-parameter of the simulation +//! \brief struct holds and manages the LB-parameter of the simulation that correspond to a certain level //! \brief For this purpose it holds structures and pointer for host and device data, respectively. struct ParameterStruct{ ////////////////////////////////////////////////////////////////////////// @@ -149,8 +149,8 @@ public: //! \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 + //! \brief sets the status, if body force should be calculated + //! \param if calcBF is true, the body force 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 @@ -199,7 +199,7 @@ public: bool getIsTimestepEven(); //! \brief return true if Advection Diffusion calculation is switched on bool getIsADcalculationOn(); - //! \brief return true if Advection Diffusion calculation is switched on + //! \brief return true if body force calculation is switched on bool getIsBodyForceOn(); //! \brief return if the simulation should write VTK files bool getPrintFiles(); @@ -247,8 +247,8 @@ public: 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(); + void setInitialConditionAD(std::function<void(real, real, real, real &)> initialConditionAD); + std::function<void(real, real, real, real &)> &getInitialConditionAD(); ////////////////////////////////////////////////////////////////////////// //! Class destructor @@ -295,7 +295,7 @@ private: //! \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; + std::function<void(real, real, real, real &)> initialConditionAD; //! \brief pointer to LB-parameter struct on host system ParameterStruct* parametersOnHost;