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

create new App SphereRefinded for a new regression test

parent 2a429310
No related branches found
No related tags found
1 merge request!254New app sphere refined for regression test
#################################################################################
# VirtualFluids MACHINE FILE
# Responsible: Martin Schoenherr
# OS: Windows 10
# OS: Windows 11
#################################################################################
# cuda compute capability
......@@ -14,3 +14,4 @@ list(APPEND VF_COMPILER_DEFINITION "PATH_NUMERICAL_TESTS=${PATH_NUMERICAL_TESTS}
# add invidual apps here
list(APPEND USER_APPS "apps/gpu/LBM/WTG_RUB")
list(APPEND USER_APPS "apps/gpu/LBM/TGV_3D_GridRef")
list(APPEND USER_APPS "apps/gpu/LBM/SphereRefined")
PROJECT(SphereRefined LANGUAGES CUDA CXX)
#LIST(APPEND CS_COMPILER_FLAGS_CXX "-DOMPI_SKIP_MPICXX" )
vf_add_library(BUILDTYPE binary PRIVATE_LINK basics VirtualFluids_GPU GridGenerator MPI::MPI_CXX FILES SphereRefined.cpp)
set_source_files_properties(SphereRefined.cpp PROPERTIES LANGUAGE CUDA)
set_target_properties(SphereRefined PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
//=======================================================================================
// ____ ____ __ ______ __________ __ __ __ __
// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
// \ \ | | | | | |_) | | | | | | | / \ | |
// \ \ | | | | | _ / | | | | | | / /\ \ | |
// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
// \ \ | | ________________________________________________________________
// \ \ | | | ______________________________________________________________|
// \ \| | | | __ __ __ __ ______ _______
// \ | | |_____ | | | | | | | | | _ \ / _____)
// \ | | _____| | | | | | | | | | | \ \ \_______
// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
// \ _____| |__| |________| \_______/ |__| |______/ (_______/
//
// 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 SphereRefined.cpp
//! \ingroup Applications
//! \author Martin Schoenherr
//=======================================================================================
#define _USE_MATH_DEFINES
#include <exception>
#include <fstream>
#include <iostream>
#include <memory>
#include <sstream>
#include <stdexcept>
#include <string>
//////////////////////////////////////////////////////////////////////////
#include "DataTypes.h"
#include "PointerDefinitions.h"
#include <logger/Logger.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 "GridGenerator/geometries/Cuboid/Cuboid.h"
#include "GridGenerator/geometries/Sphere/Sphere.h"
#include "GridGenerator/geometries/TriangularMesh/TriangularMesh.h"
//////////////////////////////////////////////////////////////////////////
#include "VirtualFluids_GPU/Factories/BoundaryConditionFactory.h"
#include "VirtualFluids_GPU/Factories/GridScalingFactory.h"
#include "VirtualFluids_GPU/Communication/MpiCommunicator.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"
#include "VirtualFluids_GPU/Factories/GridScalingFactory.h"
#include "VirtualFluids_GPU/Kernel/Utilities/KernelTypes.h"
//////////////////////////////////////////////////////////////////////////
int main()
{
try {
vf::gpu::Communicator &communicator = vf::gpu::MpiCommunicator::getInstance();
vf::logging::Logger::initializeLogger();
//////////////////////////////////////////////////////////////////////////
// Simulation parameters
//////////////////////////////////////////////////////////////////////////
std::string path("D:/output/SphereRefined");
std::string simulationName("SphereRefined");
const real L = 1.0;
const real dSphere = 0.2;
const real Re = 300.0;
const real velocity = 1.0;
const real velocityLB = (real)0.5e-2; // LB units
const uint nx = 50;
const uint timeStepOut = 10000;
const uint timeStepEnd = 10000;
//////////////////////////////////////////////////////////////////////////
// setup gridGenerator
//////////////////////////////////////////////////////////////////////////
auto gridFactory = GridFactory::make();
gridFactory->setTriangularMeshDiscretizationMethod(TriangularMeshDiscretizationMethod::POINT_IN_OBJECT);
auto gridBuilder = MultipleGridBuilder::makeShared(gridFactory);
//////////////////////////////////////////////////////////////////////////
// compute parameters in lattice units
//////////////////////////////////////////////////////////////////////////
const real dx = L / real(nx);
const real dt = velocityLB / velocity * dx;
const real viscosityLB = nx * velocityLB / Re; // LB units
//////////////////////////////////////////////////////////////////////////
// create grid
//////////////////////////////////////////////////////////////////////////
gridBuilder->addCoarseGrid(-1.0 * L, -0.6 * L, -0.6 * L,
2.0 * L, 0.6 * L, 0.6 * L, dx);
// add fine grid
gridBuilder->addGrid(std::make_shared<Sphere>(0., 0., 0., 0.3), 2);
GridScalingFactory scalingFactory = GridScalingFactory();
scalingFactory.setScalingFactory(GridScalingFactory::GridScaling::ScaleCompressible);
// use primitive
auto sphere = std::make_shared<Sphere>(0.0, 0.0, 0.0, dSphere / 2.0);
// use stl
//std::string stlPath = "C:\\Users\\schoen\\Desktop\\git\\VirtualFluids_dev_rz\\apps\\gpu\\LBM\\SphereRefined\\sphere02.stl";
//auto sphere = std::make_shared<TriangularMesh>(stlPath);
gridBuilder->addGeometry(sphere);
gridBuilder->setPeriodicBoundaryCondition(false, false, false);
gridBuilder->buildGrids(false);
//////////////////////////////////////////////////////////////////////////
// set parameters
//////////////////////////////////////////////////////////////////////////
SPtr<Parameter> para = std::make_shared<Parameter>();
para->setOutputPath(path);
para->setOutputPrefix(simulationName);
para->setPrintFiles(true);
para->setVelocityLB(velocityLB);
para->setViscosityLB(viscosityLB);
para->setVelocityRatio(velocity / velocityLB);
para->setDensityRatio(1.0);
para->setTimestepOut(timeStepOut);
para->setTimestepEnd(timeStepEnd);
para->setMainKernel(vf::CollisionKernel::Compressible::K17CompressibleNavierStokes);
//////////////////////////////////////////////////////////////////////////
// set boundary conditions
//////////////////////////////////////////////////////////////////////////
gridBuilder->setPressureBoundaryCondition(SideType::PX, 0.0);
gridBuilder->setVelocityBoundaryCondition(SideType::MX, velocityLB, 0.0, 0.0);
gridBuilder->setSlipBoundaryCondition(SideType::PY, 0.0, 0.0, 0.0);
gridBuilder->setSlipBoundaryCondition(SideType::MY, 0.0, 0.0, 0.0);
gridBuilder->setSlipBoundaryCondition(SideType::MZ, 0.0, 0.0, 0.0);
gridBuilder->setSlipBoundaryCondition(SideType::PZ, 0.0, 0.0, 0.0);
gridBuilder->setVelocityBoundaryCondition(SideType::GEOMETRY, 0.0, 0.0, 0.0);
BoundaryConditionFactory bcFactory;
bcFactory.setSlipBoundaryCondition(BoundaryConditionFactory::SlipBC::SlipCompressible);
bcFactory.setVelocityBoundaryCondition(BoundaryConditionFactory::VelocityBC::VelocityCompressible);
bcFactory.setPressureBoundaryCondition(BoundaryConditionFactory::PressureBC::PressureNonEquilibriumCompressible);
//////////////////////////////////////////////////////////////////////////
// set copy mesh to simulation
//////////////////////////////////////////////////////////////////////////
auto cudaMemoryManager = std::make_shared<CudaMemoryManager>(para);
SPtr<GridProvider> gridGenerator =
GridProvider::makeGridGenerator(gridBuilder, para, cudaMemoryManager, communicator);
//////////////////////////////////////////////////////////////////////////
// run simulation
//////////////////////////////////////////////////////////////////////////
VF_LOG_INFO("Start Running DrivenCavity Showcase...");
printf("\n");
VF_LOG_INFO("world parameter:");
VF_LOG_INFO("--------------");
VF_LOG_INFO("dt [s] = {}", dt);
VF_LOG_INFO("world_length [m] = {}", L);
VF_LOG_INFO("world_velocity [m/s] = {}", velocity);
VF_LOG_INFO("dx [m] = {}", dx);
printf("\n");
VF_LOG_INFO("LB parameter:");
VF_LOG_INFO("--------------");
VF_LOG_INFO("Re = {}", Re);
VF_LOG_INFO("lb_velocity [dx/dt] = {}", velocityLB);
VF_LOG_INFO("lb_viscosity [dx^2/dt] = {}", viscosityLB);
printf("\n");
VF_LOG_INFO("simulation parameter:");
VF_LOG_INFO("--------------");
VF_LOG_INFO("nx = {}", nx);
VF_LOG_INFO("ny = {}", nx);
VF_LOG_INFO("nz = {}", nx);
VF_LOG_INFO("number of nodes = {}", nx * nx * nx);
VF_LOG_INFO("n timesteps = {}", timeStepOut);
VF_LOG_INFO("write_nth_timestep = {}", timeStepEnd);
VF_LOG_INFO("output_path = {}", path);
Simulation sim(para, cudaMemoryManager, communicator, *gridGenerator, &bcFactory, &scalingFactory);
sim.run();
} 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!");
}
return 0;
}
##################################################
#GPU Mapping
##################################################
#Devices="0 1 2 3"
#NumberOfDevices=4
##################################################
#informations for Writing
##################################################
#Path = "output/"
#Prefix="DrivenCavity"
#WriteGrid=true
##################################################
#informations for reading
##################################################
#GridPath="grid/"
##################################################
#number of grid levels
##################################################
#NOGL=1
##################################################
#LBM Version
##################################################
#D3Qxx=27
#MainKernelName=CumulantAA2016CompSP27
##################################################
#simulation parameter
##################################################
#TimeEnd=100000
#TimeOut=1000
#TimeStartOut=0
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment