VirtualFluids 0.2.0
Parallel CFD LBM Solver
Loading...
Searching...
No Matches
VirtualFluidSimulationFactory.cpp
Go to the documentation of this file.
1//=======================================================================================
2// ____ ____ __ ______ __________ __ __ __ __
3// \ \ | | | | | _ \ |___ ___| | | | | / \ | |
4// \ \ | | | | | |_) | | | | | | | / \ | |
5// \ \ | | | | | _ / | | | | | | / /\ \ | |
6// \ \ | | | | | | \ \ | | | \__/ | / ____ \ | |____
7// \ \ | | |__| |__| \__\ |__| \________/ /__/ \__\ |_______|
8// \ \ | | ________________________________________________________________
9// \ \ | | | ______________________________________________________________|
10// \ \| | | | __ __ __ __ ______ _______
11// \ | | |_____ | | | | | | | | | _ \ / _____)
12// \ | | _____| | | | | | | | | | | \ \ \_______
13// \ | | | | |_____ | \_/ | | | | |_/ / _____ |
14// \ _____| |__| |________| \_______/ |__| |______/ (_______/
15//
16// This file is part of VirtualFluids. VirtualFluids is free software: you can
17// redistribute it and/or modify it under the terms of the GNU General Public
18// License as published by the Free Software Foundation, either version 3 of
19// the License, or (at your option) any later version.
20//
21// VirtualFluids is distributed in the hope that it will be useful, but WITHOUT
22// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
23// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24// for more details.
25//
26// SPDX-License-Identifier: GPL-3.0-or-later
27// SPDX-FileCopyrightText: Copyright © VirtualFluids Project contributors, see AUTHORS.md in root folder
28//
32//=======================================================================================
34
39
42
45
47
48using namespace vf::gpu;
49
50std::shared_ptr<Parameter> vf::gpu::tests::makeParameter(std::shared_ptr<SimulationParameter> simPara)
51{
52 auto para = std::make_shared<Parameter>(1, 0);
53
54 para->setQuadricLimiters(0.01, 0.01, 0.01);
55
56 para->setMaxDev(simPara->getDevices().size());
57 para->setDevices(simPara->getDevices());
58
59 std::string _prefix = "cells";
60 std::string gridPath = simPara->getGridPath() + "/";
61 para->setOutputPath(simPara->getFilePath());
62 para->setOutputPrefix(_prefix);
63 para->setPrintFiles(true);
64
65 para->setD3Qxx(27);
66 para->setMaxLevel(simPara->getNumberOfGridLevels());
67
68 para->setTimestepEnd(simPara->getEndTime());
69 para->setTimestepOut(simPara->getTimeStepLength());
70 para->setTimestepStartOut(1);
71
72 para->setViscosityLB(simPara->getViscosity());
73 para->setVelocityLB(simPara->getMaxVelocity());
74 para->setViscosityRatio(1.0);
75 para->setVelocityRatio(1.0);
76 para->setDensityRatio(1.0);
77 para->setFactorPressBC(100000.0);
78
79 para->setgeoVec(gridPath + "geoVec.dat");
80 para->setcoordX(gridPath + "coordX.dat");
81 para->setcoordY(gridPath + "coordY.dat");
82 para->setcoordZ(gridPath + "coordZ.dat");
83 para->setneighborX(gridPath + "neighborX.dat");
84 para->setneighborY(gridPath + "neighborY.dat");
85 para->setneighborZ(gridPath + "neighborZ.dat");
86 para->setneighborWSB(gridPath + "neighborWSB.dat");
87 para->setgeomBoundaryBcQs(gridPath + "geomBoundaryQs.dat");
88 para->setgeomBoundaryBcValues(gridPath + "geomBoundaryValues.dat");
89 para->setinletBcQs(gridPath + "inletBoundaryQs.dat");
90 para->setinletBcValues(gridPath + "inletBoundaryValues.dat");
91 para->setoutletBcQs(gridPath + "outletBoundaryQs.dat");
92 para->setoutletBcValues(gridPath + "outletBoundaryValues.dat");
93 para->settopBcQs(gridPath + "topBoundaryQs.dat");
94 para->settopBcValues(gridPath + "topBoundaryValues.dat");
95 para->setbottomBcQs(gridPath + "bottomBoundaryQs.dat");
96 para->setbottomBcValues(gridPath + "bottomBoundaryValues.dat");
97 para->setfrontBcQs(gridPath + "frontBoundaryQs.dat");
98 para->setfrontBcValues(gridPath + "frontBoundaryValues.dat");
99 para->setbackBcQs(gridPath + "backBoundaryQs.dat");
100 para->setbackBcValues(gridPath + "backBoundaryValues.dat");
101 para->setnumberNodes(gridPath + "numberNodes.dat");
102 para->setLBMvsSI(gridPath + "LBMvsSI.dat");
103 para->setscaleCFC(gridPath + "scaleCFC.dat");
104 para->setscaleCFF(gridPath + "scaleCFF.dat");
105 para->setscaleFCC(gridPath + "scaleFCC.dat");
106 para->setscaleFCF(gridPath + "scaleFCF.dat");
107 para->setscaleOffsetCF(gridPath + "offsetVecCF.dat");
108 para->setscaleOffsetFC(gridPath + "offsetVecFC.dat");
109 para->setDiffOn(false);
110 para->setDoCheckPoint(false);
111 para->setDoRestart(false);
112 para->setUseGeometryValues(false);
113 para->setCalc2ndOrderMoments(false);
114 para->setCalc3rdOrderMoments(false);
115 para->setCalcHighOrderMoments(false);
116 para->setReadGeo(false);
117 para->setCalcMean(false);
118 para->setUseMeasurePoints(false);
119 para->setForcing(0.0, 0.0, 0.0);
120
121 para->configureMainKernel(simPara->getKernelConfiguration()->getMainKernel());
122 para->setMultiKernelOn(simPara->getKernelConfiguration()->getMultiKernelOn());
123 para->setMultiKernelLevel(simPara->getKernelConfiguration()->getMultiKernelLevel());
124 para->setMultiKernel(simPara->getKernelConfiguration()->getMultiKernel());
125
126 return para;
127}
128
129std::shared_ptr<NumericalTestGridReader> makeGridReader(std::shared_ptr<InitialCondition> initialCondition,
130 std::shared_ptr<Parameter> para,
131 std::shared_ptr<CudaMemoryManager> cudaManager)
132{
133 return NumericalTestGridReader::getNewInstance(para, initialCondition, cudaManager);
134}
135
136const std::function<void()> vf::gpu::tests::makeVirtualFluidSimulation(std::shared_ptr<Parameter> para,
137 std::shared_ptr<InitialCondition> condition,
138 std::shared_ptr<DataWriter> dataWriter)
139{
140 auto cudaManager = std::make_shared<CudaMemoryManager>(para);
141 auto grid = makeGridReader(condition, para, cudaManager);
144 auto simulation =
145 std::make_shared<Simulation>(para, cudaManager, communicator, *grid.get(), &bc_factory);
146 simulation->setDataWriter(dataWriter);
147
148 return [simulation]() { simulation->run(); };
149}
150
An abstract class for communication between processes in parallel computation.
static std::shared_ptr< Communicator > getInstance()
std::shared_ptr< NumericalTestGridReader > makeGridReader(std::shared_ptr< InitialCondition > initialCondition, std::shared_ptr< Parameter > para, std::shared_ptr< CudaMemoryManager > cudaManager)
static std::shared_ptr< NumericalTestGridReader > getNewInstance(std::shared_ptr< vf::gpu::Parameter > para, std::shared_ptr< InitialCondition > initialCondition, std::shared_ptr< vf::gpu::CudaMemoryManager > cudaManager)
std::shared_ptr< T > SPtr
const std::function< void()> makeVirtualFluidSimulation(std::shared_ptr< Parameter > para, std::shared_ptr< InitialCondition > condition, std::shared_ptr< DataWriter > dataWriter)
std::shared_ptr< Parameter > makeParameter(std::shared_ptr< SimulationParameter > simPara)