diff --git a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp index 55000e4bd26963a6e17539f7744b05d6bf9c672b..48da54e327a7ca8588f49a7938c2609f22036298 100644 --- a/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp +++ b/apps/gpu/LBM/DrivenCavity/DrivenCavity.cpp @@ -1,375 +1,341 @@ - +//======================================================================================= +// ____ ____ __ ______ __________ __ __ __ __ +// \ \ | | | | | _ \ |___ ___| | | | | / \ | | +// \ \ | | | | | |_) | | | | | | | / \ | | +// \ \ | | | | | _ / | | | | | | / /\ \ | | +// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____ +// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______| +// \ \ | | ________________________________________________________________ +// \ \ | | | ______________________________________________________________| +// \ \| | | | __ __ __ __ ______ _______ +// \ | | |_____ | | | | | | | | | _ \ / _____) +// \ | | _____| | | | | | | | | | | \ \ \_______ +// \ | | | | |_____ | \_/ | | | | |_/ / _____ | +// \ _____| |__| |________| \_______/ |__| |______/ (_______/ +// +// 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 LidDrivenCavity.cpp +//! \ingroup Applications +//! \author Martin Schoenherr, Stephan Lenz +//======================================================================================= #define _USE_MATH_DEFINES -#include <string> -#include <sstream> -#include <iostream> -#include <stdexcept> -#include <fstream> #include <exception> +#include <fstream> +#include <iostream> #include <memory> -#include <filesystem> +#include <sstream> +#include <stdexcept> +#include <string> ////////////////////////////////////////////////////////////////////////// #include "Core/DataTypes.h" -#include "PointerDefinitions.h" - -#include "Core/StringUtilities/StringUtil.h" - +#include "Core/LbmOrGks.h" +#include "Core/Logger/Logger.h" #include "Core/VectorTypes.h" - -#include "basics/config/ConfigurationFile.h" - -#include "logger/Logger.h" +#include "PointerDefinitions.h" ////////////////////////////////////////////////////////////////////////// +#include "GridGenerator/grid/BoundaryConditions/Side.h" #include "GridGenerator/grid/GridBuilder/LevelGridBuilder.h" #include "GridGenerator/grid/GridBuilder/MultipleGridBuilder.h" -#include "GridGenerator/grid/BoundaryConditions/Side.h" #include "GridGenerator/grid/GridFactory.h" -#include "GridGenerator/io/SimulationFileWriter/SimulationFileWriter.h" -#include "GridGenerator/io/GridVTKWriter/GridVTKWriter.h" -#include "GridGenerator/io/STLReaderWriter/STLReader.h" -#include "GridGenerator/io/STLReaderWriter/STLWriter.h" - ////////////////////////////////////////////////////////////////////////// -#include "VirtualFluids_GPU/LBM/Simulation.h" -#include "VirtualFluids_GPU/Communication/Communicator.h" -#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" #include "VirtualFluids_GPU/DataStructureInitializer/GridProvider.h" -#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderFiles/GridReader.h" -#include "VirtualFluids_GPU/Parameter/Parameter.h" +#include "VirtualFluids_GPU/DataStructureInitializer/GridReaderGenerator/GridGenerator.h" +#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" +#include "VirtualFluids_GPU/Communication/Communicator.h" +#include "VirtualFluids_GPU/LBM/Simulation.h" #include "VirtualFluids_GPU/Output/FileWriter.h" +#include "VirtualFluids_GPU/Parameter/Parameter.h" +#include "VirtualFluids_GPU/BoundaryConditions/BoundaryConditionFactory.h" #include "VirtualFluids_GPU/BoundaryConditions/BoundaryConditionFactory.h" - -#include "VirtualFluids_GPU/GPU/CudaMemoryManager.h" ////////////////////////////////////////////////////////////////////////// -//#include "GksMeshAdapter/GksMeshAdapter.h" +// #include "GksMeshAdapter/GksMeshAdapter.h" +// #include "GksGpu/DataBase/DataBase.h" +// #include "GksGpu/Initializer/Initializer.h" +// #include "GksGpu/Parameters/Parameters.h" +// #include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" +// #include "GksGpu/BoundaryConditions/BoundaryCondition.h" +// #include "GksGpu/BoundaryConditions/IsothermalWall.h" +// #include "GksGpu/TimeStepping/NestedTimeStep.h" +// #include "GksGpu/Analyzer/ConvergenceAnalyzer.h" +// #include "GksGpu/Analyzer/CupsAnalyzer.h" +// #include "GksGpu/CudaUtility/CudaUtility.h" +// #include "GksGpu/Output/VtkWriter.h" -//#include "GksVtkAdapter/VTKInterface.h" -// -//#include "GksGpu/DataBase/DataBase.h" -//#include "GksGpu/Parameters/Parameters.h" -//#include "GksGpu/Initializer/Initializer.h" -// -//#include "GksGpu/FlowStateData/FlowStateDataConversion.cuh" -// -//#include "GksGpu/BoundaryConditions/BoundaryCondition.h" -//#include "GksGpu/BoundaryConditions/IsothermalWall.h" -// -//#include "GksGpu/TimeStepping/NestedTimeStep.h" -// -//#include "GksGpu/Analyzer/CupsAnalyzer.h" -//#include "GksGpu/Analyzer/ConvergenceAnalyzer.h" -// -//#include "GksGpu/CudaUtility/CudaUtility.h" - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// U s e r s e t t i n g s -// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//LbmOrGks lbmOrGks = GKS; -const LbmOrGks lbmOrGks = LBM; - -const real L = 1.0; - -const real Re = 1000.0; - -const real velocity = 1.0; - -const real dt = (real)0.5e-3; - -const uint nx = 64; - -const std::string path("output/"); -const std::string gridPath("grid/"); - -const std::string simulationName("DrivenCavityChim"); - -const uint timeStepOut = 10000; -const uint timeStepEnd = 250000; - -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// -void multipleLevel(const std::string& configPath) +int main(int argc, char *argv[]) { - 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); - - vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance(); - - auto gridFactory = GridFactory::make(); - gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); - auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - - real dx = L / real(nx); - - gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, - 0.5 * L, 0.5 * L, 0.5 * L, dx); - - // gridBuilder->addCoarseGrid(-2.0 * dx, -0.5 * L, -0.5 * L, - // 2.0 * dx, 0.5 * L, 0.5 * L, dx); - - auto refBox = new Cuboid(-0.1 * L, -0.1 * L, -0.1 * L, - 0.1 * L, 0.1 * L, 0.1 * L); - - gridBuilder->addGrid(refBox, 1); + try { + ////////////////////////////////////////////////////////////////////////// + // Simulation parameters + ////////////////////////////////////////////////////////////////////////// + std::string path("./output/DrivenCavity"); + std::string simulationName("LidDrivenCavity"); - gridBuilder->setNumberOfLayers(0, 0); + const real L = 1.0; + const real Re = 1000.0; + const real velocity = 1.0; + const real dt = (real)0.5e-3; + const uint nx = 64; - gridBuilder->setPeriodicBoundaryCondition(false, false, false); + const uint timeStepOut = 1000; + const uint timeStepEnd = 10000; - gridBuilder->buildGrids(lbmOrGks, false); // buildGrids() has to be called before setting the BCs!!!! + // switch between LBM and GKS solver here + // LbmOrGks lbmOrGks = GKS; + LbmOrGks lbmOrGks = LBM; - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // setup logger + ////////////////////////////////////////////////////////////////////////// - if( lbmOrGks == LBM ) - { + 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); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - vf::basics::ConfigurationFile config; - config.load(configPath); + ////////////////////////////////////////////////////////////////////////// + // setup gridGenerator + ////////////////////////////////////////////////////////////////////////// - SPtr<Parameter> para = std::make_shared<Parameter>(config, communicator.getNummberOfProcess(), communicator.getPID()); - BoundaryConditionFactory bcFactory = BoundaryConditionFactory(); + auto gridFactory = GridFactory::make(); + gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT); + auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // create grid + ////////////////////////////////////////////////////////////////////////// - const real velocityLB = velocity * dt / dx; // LB units + real dx = L / real(nx); - const real vx = velocityLB / (real)sqrt(2.0); // LB units - const real vy = velocityLB / (real)sqrt(2.0); // LB units + gridBuilder->addCoarseGrid(-0.5 * L, -0.5 * L, -0.5 * L, 0.5 * L, 0.5 * L, 0.5 * L, dx); - const real viscosityLB = nx * velocityLB / Re; // LB units + gridBuilder->setPeriodicBoundaryCondition(false, false, false); - VF_LOG_INFO("velocity [dx/dt] = {}", velocityLB); - VF_LOG_INFO("viscosity [dx^2/dt] = {}", viscosityLB); + gridBuilder->buildGrids(lbmOrGks, false); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // branch between LBM and GKS + ////////////////////////////////////////////////////////////////////////// - para->setDevices(std::vector<uint>{(uint)0}); + if (lbmOrGks == LBM) { + SPtr<Parameter> para =std::make_shared<Parameter>(); + BoundaryConditionFactory bcFactory = BoundaryConditionFactory(); + vf::gpu::Communicator& communicator = vf::gpu::Communicator::getInstance();; + ////////////////////////////////////////////////////////////////////////// + // compute parameters in lattice units + ////////////////////////////////////////////////////////////////////////// - para->setOutputPath( path ); // optional, default is output/ - para ->setGridPath( gridPath ); // optional, default is grid/ + const real velocityLB = velocity * dt / dx; // LB units - para->setOutputPrefix( simulationName ); + const real vx = velocityLB / sqrt(2.0); // LB units + const real vy = velocityLB / sqrt(2.0); // LB units - para->setPrintFiles(true); + const real viscosityLB = nx * velocityLB / Re; // LB units - para->setMaxLevel(2); + *logging::out << logging::Logger::INFO_HIGH << "velocity [dx/dt] = " << velocityLB << " \n"; + *logging::out << logging::Logger::INFO_HIGH << "viscosity [dx^2/dt] = " << viscosityLB << "\n"; - para->setVelocityLB(velocityLB); - para->setViscosityLB(viscosityLB); + ////////////////////////////////////////////////////////////////////////// + // set parameters + ////////////////////////////////////////////////////////////////////////// - para->setVelocityRatio(velocity / velocityLB); + para->setOutputPath(path); + para->setOutputPrefix(simulationName); - //para->setMainKernel("CumulantK17CompChim"); + para->setPrintFiles(true); - para->setInitialCondition([&](real coordX, real coordY, real coordZ, real &rho, real &vx, real &vy, real &vz) { - rho = (real)0.0; - vx = (real)0.0; //(6 * velocityLB * coordZ * (L - coordZ) / (L * L)); - vy = (real)0.0; - vz = (real)0.0; - }); + para->setVelocityLB(velocityLB); + para->setViscosityLB(viscosityLB); - para->setTimestepOut( timeStepOut ); - para->setTimestepEnd( timeStepEnd ); + para->setVelocityRatio(velocity / velocityLB); - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + para->setTimestepOut(timeStepOut); + para->setTimestepEnd(timeStepEnd); - gridBuilder->setNoSlipBoundaryCondition(SideType::PX); - gridBuilder->setNoSlipBoundaryCondition(SideType::MX); - gridBuilder->setNoSlipBoundaryCondition(SideType::PY); - gridBuilder->setNoSlipBoundaryCondition(SideType::MY); - gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vx, vx, 0.0); - gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); + ////////////////////////////////////////////////////////////////////////// + // set boundary conditions + ////////////////////////////////////////////////////////////////////////// - bcFactory.setNoSlipBoundaryCondition(BoundaryConditionFactory::NoSlipBC::NoSlipBounceBack); - bcFactory.setVelocityBoundaryCondition(BoundaryConditionFactory::VelocityBC::VelocitySimpleBounceBackCompressible); + gridBuilder->setNoSlipBoundaryCondition(SideType::PX); + gridBuilder->setNoSlipBoundaryCondition(SideType::MX); + gridBuilder->setNoSlipBoundaryCondition(SideType::PY); + gridBuilder->setNoSlipBoundaryCondition(SideType::MY); + gridBuilder->setVelocityBoundaryCondition(SideType::PZ, vx, vy, 0.0); + gridBuilder->setNoSlipBoundaryCondition(SideType::MZ); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + bcFactory.setNoSlipBoundaryCondition(BoundaryConditionFactory::NoSlipBC::NoSlipBounceBack); + bcFactory.setVelocityBoundaryCondition(BoundaryConditionFactory::VelocityBC::VelocitySimpleBounceBackCompressible); + ////////////////////////////////////////////////////////////////////////// + // set copy mesh to simulation + ////////////////////////////////////////////////////////////////////////// - gridBuilder->writeGridsToVtk(para->getGridPath()); + auto cudaMemoryManager = std::make_shared<CudaMemoryManager>(para); + SPtr<GridProvider> gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager, communicator); - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // run simulation + ////////////////////////////////////////////////////////////////////////// - auto cudaMemoryManager = std::make_shared<CudaMemoryManager>(para); + Simulation sim(para, cudaMemoryManager, communicator, *gridGenerator, &bcFactory); + sim.run(); + } // else { + // CudaUtility::setCudaDevice(0); - auto gridGenerator = GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager, communicator); + // Parameters parameters; - Simulation sim(para, cudaMemoryManager, communicator, *gridGenerator, &bcFactory); - sim.run(); + // ////////////////////////////////////////////////////////////////////////// + // // compute remaining parameters + // ////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - } - else - { - // CudaUtility::setCudaDevice(0); - // - // Parameters parameters; + // const real vx = velocity / sqrt(2.0); + // const real vy = velocity / sqrt(2.0); - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // parameters.K = 2.0; + // parameters.Pr = 1.0; - //const real vx = velocity / sqrt(2.0); - //const real vy = velocity / sqrt(2.0); + // const real Ma = (real)0.1; - // parameters.K = 2.0; - // parameters.Pr = 1.0; - // - // const real Ma = 0.1; + // real rho = 1.0; - // real rho = 1.0; + // real cs = velocity / Ma; + // real lambda = c1o2 * ((parameters.K + 5.0) / (parameters.K + 3.0)) / (cs * cs); - // real cs = velocity / Ma; - // real lambda = c1o2 * ( ( parameters.K + 5.0 ) / ( parameters.K + 3.0 ) ) / ( cs * cs ); + // const real mu = velocity * L * rho / Re; - // const real mu = velocity * L * rho / Re; + // *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " m^2/s\n"; - // *logging::out << logging::Logger::INFO_HIGH << "mu = " << mu << " m^2/s\n"; + // *logging::out << logging::Logger::INFO_HIGH << "CFL = " << dt * (velocity + cs) / dx << "\n"; - // *logging::out << logging::Logger::INFO_HIGH << "CFL = " << dt * ( velocity + cs ) / dx << "\n"; + // ////////////////////////////////////////////////////////////////////////// + // // set parameters + // ////////////////////////////////////////////////////////////////////////// - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // parameters.mu = mu; - // parameters.mu = mu; + // parameters.dt = dt; + // parameters.dx = dx; - // parameters.dt = dt; - // parameters.dx = dx; + // parameters.lambdaRef = lambda; - // parameters.lambdaRef = lambda; + // ////////////////////////////////////////////////////////////////////////// + // // set copy mesh to simulation + // ////////////////////////////////////////////////////////////////////////// - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // GksMeshAdapter meshAdapter(gridBuilder); - // GksMeshAdapter meshAdapter( gridBuilder ); + // meshAdapter.inputGrid(); - // meshAdapter.inputGrid(); + // auto dataBase = std::make_shared<DataBase>("GPU"); - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// + // // set boundary conditions + // ////////////////////////////////////////////////////////////////////////// - // auto dataBase = std::make_shared<DataBase>( "GPU" ); + // SPtr<BoundaryCondition> bcLid = + // std::make_shared<IsothermalWall>(dataBase, Vec3(vx, vy, 0.0), lambda, false); + // SPtr<BoundaryCondition> bcWall = + // std::make_shared<IsothermalWall>(dataBase, Vec3(0.0, 0.0, 0.0), lambda, false); - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // bcLid->findBoundaryCells(meshAdapter, false, [&](Vec3 center) { + // return center.z > 0.5 && center.x > -0.5 && center.x < 0.5 && center.y > -0.5 && center.y < 0.5; + // }); - // SPtr<BoundaryCondition> bcLid = std::make_shared<IsothermalWall>( dataBase, Vec3( vx, vy, 0.0 ), lambda, false ); - // SPtr<BoundaryCondition> bcWall = std::make_shared<IsothermalWall>( dataBase, Vec3( 0.0, 0.0, 0.0 ), lambda, false ); + // bcWall->findBoundaryCells(meshAdapter, true, [&](Vec3 center) { + // return center.x < -0.5 || center.x > 0.5 || center.y < -0.5 || center.y > 0.5 || center.z < -0.5; + // }); - // bcLid->findBoundaryCells ( meshAdapter, true, [&](Vec3 center){ return center.z > 0.5; } ); - // bcWall->findBoundaryCells( meshAdapter, false, [&](Vec3 center){ return center.z < 0.5; } ); + // dataBase->boundaryConditions.push_back(bcLid); + // dataBase->boundaryConditions.push_back(bcWall); - // dataBase->boundaryConditions.push_back( bcLid ); - // dataBase->boundaryConditions.push_back( bcWall ); + // ////////////////////////////////////////////////////////////////////////// + // // set initial condition and upload mesh and initial condition to GPGPU + // ////////////////////////////////////////////////////////////////////////// - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // dataBase->setMesh(meshAdapter); - // dataBase->setMesh( meshAdapter ); + // Initializer::interpret(dataBase, [&](Vec3 cellCenter) -> ConservedVariables { + // return toConservedVariables(PrimitiveVariables(rho, 0.0, 0.0, 0.0, lambda), parameters.K); + // }); - // Initializer::interpret(dataBase, [&] ( Vec3 cellCenter ) -> ConservedVariables { + // dataBase->copyDataHostToDevice(); - // return toConservedVariables( PrimitiveVariables( rho, 0.0, 0.0, 0.0, lambda ), parameters.K ); - // }); + // Initializer::initializeDataUpdate(dataBase); - // dataBase->copyDataHostToDevice(); + // VtkWriter::write(dataBase, parameters, path + "/" + simulationName + "_0"); - // Initializer::initializeDataUpdate(dataBase); + // ////////////////////////////////////////////////////////////////////////// + // // set analyzers + // ////////////////////////////////////////////////////////////////////////// - // writeVtkXML( dataBase, parameters, 0, path + simulationName + "_0" ); + // CupsAnalyzer cupsAnalyzer(dataBase, false, 60.0, true, 10000); - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // ConvergenceAnalyzer convergenceAnalyzer(dataBase, 10000); - // CupsAnalyzer cupsAnalyzer( dataBase, false, 60.0, true, 10000 ); + // cupsAnalyzer.start(); - // ConvergenceAnalyzer convergenceAnalyzer( dataBase, 10000 ); + // ////////////////////////////////////////////////////////////////////////// + // // run simulation + // ////////////////////////////////////////////////////////////////////////// - // cupsAnalyzer.start(); + // for (uint iter = 1; iter <= timeStepEnd; iter++) { + // TimeStepping::nestedTimeStep(dataBase, parameters, 0); - // //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // if (iter % timeStepOut == 0) { + // dataBase->copyDataDeviceToHost(); - // for( uint iter = 1; iter <= timeStepEnd; iter++ ) - // { - // TimeStepping::nestedTimeStep(dataBase, parameters, 0); + // VtkWriter::write(dataBase, parameters, path + "/" + simulationName + "_" + std::to_string(iter)); + // } - // if( iter % timeStepOut == 0 ) - // { - // dataBase->copyDataDeviceToHost(); + // int crashCellIndex = dataBase->getCrashCellIndex(); + // if (crashCellIndex >= 0) { + // *logging::out << logging::Logger::LOGGER_ERROR + // << "Simulation crashed at CellIndex = " << crashCellIndex << "\n"; + // dataBase->copyDataDeviceToHost(); + // VtkWriter::write(dataBase, parameters, path + "/" + simulationName + "_" + std::to_string(iter)); - // writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); - // } - // - // int crashCellIndex = dataBase->getCrashCellIndex(); - // if( crashCellIndex >= 0 ) - // { - // *logging::out << logging::Logger::LOGGER_ERROR << "Simulation Crashed at CellIndex = " << crashCellIndex << "\n"; - // dataBase->copyDataDeviceToHost(); - // writeVtkXML( dataBase, parameters, 0, path + simulationName + "_" + std::to_string( iter ) ); + // break; + // } - // break; - // } + // dataBase->getCrashCellIndex(); - // dataBase->getCrashCellIndex(); + // cupsAnalyzer.run(iter, parameters.dt); - // cupsAnalyzer.run( iter, parameters.dt ); + // convergenceAnalyzer.run(iter); + // } + // } + } catch (const std::bad_alloc& e) { - // convergenceAnalyzer.run( iter ); - // } - } -} - -int main( int argc, char* argv[]) -{ - try - { - vf::logging::Logger::initalizeLogger(); + *logging::out << logging::Logger::LOGGER_ERROR << "Bad Alloc:" << e.what() << "\n"; + } catch (const std::exception& e) { - // assuming that the config files is stored parallel to this file. - std::filesystem::path filePath = __FILE__; - filePath.replace_filename("configDrivenCavity.txt"); + *logging::out << logging::Logger::LOGGER_ERROR << e.what() << "\n"; + } catch (std::string &s) { - multipleLevel(filePath.string()); - } - catch (const spdlog::spdlog_ex &ex) { - std::cout << "Log initialization failed: " << ex.what() << std::endl; - } - catch (const std::bad_alloc& e) - { - VF_LOG_CRITICAL("Bad Alloc: {}", e.what()); - } - catch (const std::exception& e) - { - VF_LOG_CRITICAL("exception: {}", e.what()); - } - catch (...) - { - VF_LOG_CRITICAL("Unknown exception!"); + *logging::out << logging::Logger::LOGGER_ERROR << s << "\n"; + } catch (...) { + *logging::out << logging::Logger::LOGGER_ERROR << "Unknown exception!\n"; } - return 0; + return 0; }