Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
VirtualFluids
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
iRMB
VirtualFluids
Commits
cd729fdd
Commit
cd729fdd
authored
2 years ago
by
Anna Wellmann
Browse files
Options
Downloads
Patches
Plain Diff
Remove GKS from app
parent
fe4c8a1f
No related branches found
No related tags found
1 merge request
!112
Synchronize OpenSource GridGenerator and Develop
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/gpu/FlowAroundSphere/FlowAroundSphere.cpp
+55
-207
55 additions, 207 deletions
apps/gpu/FlowAroundSphere/FlowAroundSphere.cpp
with
55 additions
and
207 deletions
apps/gpu/FlowAroundSphere/FlowAroundSphere.cpp
+
55
−
207
View file @
cd729fdd
...
@@ -68,26 +68,6 @@
...
@@ -68,26 +68,6 @@
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
#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"
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
try
{
try
{
...
@@ -97,19 +77,15 @@ int main(int argc, char *argv[])
...
@@ -97,19 +77,15 @@ int main(int argc, char *argv[])
std
::
string
outputPath
(
"./output/Sphere"
);
std
::
string
outputPath
(
"./output/Sphere"
);
std
::
string
simulationName
(
"Sphere"
);
std
::
string
simulationName
(
"Sphere"
);
const
real
L
=
1.0
;
const
real
L
=
1.0
;
const
real
Re
=
1000.0
;
const
real
Re
=
1000.0
;
const
real
velocity
=
1.0
;
const
real
velocity
=
1.0
;
const
real
dt
=
(
real
)
0.5e-3
;
const
real
dt
=
(
real
)
0.5e-3
;
const
uint
nx
=
64
;
const
uint
nx
=
64
;
const
uint
timeStepOut
=
10000
;
const
uint
timeStepOut
=
10000
;
const
uint
timeStepEnd
=
250000
;
const
uint
timeStepEnd
=
250000
;
// switch between LBM and GKS solver here
// LbmOrGks lbmOrGks = GKS;
LbmOrGks
lbmOrGks
=
LBM
;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// setup logger
// setup logger
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
...
@@ -134,217 +110,89 @@ int main(int argc, char *argv[])
...
@@ -134,217 +110,89 @@ int main(int argc, char *argv[])
gridBuilder
->
addCoarseGrid
(
-
1.0
*
L
,
-
1.0
*
L
,
-
1.0
*
L
,
1.0
*
L
,
1.0
*
L
,
1.0
*
L
,
dx
);
gridBuilder
->
addCoarseGrid
(
-
1.0
*
L
,
-
1.0
*
L
,
-
1.0
*
L
,
1.0
*
L
,
1.0
*
L
,
1.0
*
L
,
dx
);
// use primitive
// use primitive
Object
*
sphere
=
new
Sphere
(
0.0
,
0.0
,
0.0
,
0.2
);
Object
*
sphere
=
new
Sphere
(
0.0
,
0.0
,
0.0
,
0.2
);
// use stl
// use stl
// Object* sphere = TriangularMesh::make("stl/sphere.stl");
// Object* sphere = TriangularMesh::make("stl/sphere.stl");
gridBuilder
->
addGeometry
(
sphere
);
gridBuilder
->
addGeometry
(
sphere
);
gridBuilder
->
setPeriodicBoundaryCondition
(
false
,
false
,
false
);
gridBuilder
->
setPeriodicBoundaryCondition
(
false
,
false
,
false
);
gridBuilder
->
buildGrids
(
lbmOrGks
,
false
);
gridBuilder
->
buildGrids
(
LBM
,
false
);
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
//
branch between LBM and GKS
//
setup simulation parameters
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
if
(
lbmOrGks
==
LBM
)
{
SPtr
<
Parameter
>
para
=
Parameter
::
make
();
SPtr
<
Parameter
>
para
=
Parameter
::
make
();
//////////////////////////////////////////////////////////////////////////
// compute parameters in lattice units
//////////////////////////////////////////////////////////////////////////
const
real
velocityLB
=
velocity
*
dt
/
dx
;
// LB units
const
real
vx
=
velocityLB
/
sqrt
(
2.0
);
// LB units
const
real
vy
=
velocityLB
/
sqrt
(
2.0
);
// LB units
const
real
viscosityLB
=
nx
*
velocityLB
/
Re
;
// 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
(
outputPath
);
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
);
//////////////////////////////////////////////////////////////////////////
// set boundary conditions
//////////////////////////////////////////////////////////////////////////
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
);
gridBuilder
->
setVelocityBoundaryCondition
(
SideType
::
GEOMETRY
,
0.0
,
0.0
,
0.0
);
//////////////////////////////////////////////////////////////////////////
// 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
();
}
else
{
CudaUtility
::
setCudaDevice
(
0
);
Parameters
parameters
;
//////////////////////////////////////////////////////////////////////////
// compute remaining 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
Ma
=
(
real
)
0.1
;
//////////////////////////////////////////////////////////////////////////
// compute parameters in lattice units
real
rho
=
1.0
;
//////////////////////////////////////////////////////////////////////////
real
cs
=
velocity
/
Ma
;
real
lambda
=
c1o2
*
((
parameters
.
K
+
5.0
)
/
(
parameters
.
K
+
3.0
))
/
(
cs
*
cs
);
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
<<
"CFL = "
<<
dt
*
(
velocity
+
cs
)
/
dx
<<
"
\n
"
;
//////////////////////////////////////////////////////////////////////////
// set parameters
//////////////////////////////////////////////////////////////////////////
parameters
.
mu
=
mu
;
parameters
.
dt
=
dt
;
parameters
.
dx
=
dx
;
parameters
.
lambdaRef
=
lambda
;
//////////////////////////////////////////////////////////////////////////
// set copy mesh to simulation
//////////////////////////////////////////////////////////////////////////
GksMeshAdapter
meshAdapter
(
gridBuilder
);
meshAdapter
.
inputGrid
();
auto
dataBase
=
std
::
make_shared
<
DataBase
>
(
"GPU"
);
//////////////////////////////////////////////////////////////////////////
// set boundary conditions
//////////////////////////////////////////////////////////////////////////
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
;
});
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
;
});
dataBase
->
boundaryConditions
.
push_back
(
bcLid
);
dataBase
->
boundaryConditions
.
push_back
(
bcWall
);
//////////////////////////////////////////////////////////////////////////
// set initial condition and upload mesh and initial condition to GPGPU
//////////////////////////////////////////////////////////////////////////
dataBase
->
setMesh
(
meshAdapter
);
Initializer
::
interpret
(
dataBase
,
[
&
](
Vec3
cellCenter
)
->
ConservedVariables
{
const
real
velocityLB
=
velocity
*
dt
/
dx
;
// LB units
return
toConservedVariables
(
PrimitiveVariables
(
rho
,
0.0
,
0.0
,
0.0
,
lambda
),
parameters
.
K
);
});
dataBase
->
copyDataHostToDevice
();
const
real
vx
=
velocityLB
/
sqrt
(
2.0
);
// LB units
const
real
vy
=
velocityLB
/
sqrt
(
2.0
);
// LB units
Initializer
::
initializeDataUpdate
(
dataBase
);
const
real
viscosityLB
=
nx
*
velocityLB
/
Re
;
// LB units
VtkWriter
::
write
(
dataBase
,
parameters
,
outputPath
+
"/"
+
simulationName
+
"_0"
);
*
logging
::
out
<<
logging
::
Logger
::
INFO_HIGH
<<
"velocity [dx/dt] = "
<<
velocityLB
<<
"
\n
"
;
*
logging
::
out
<<
logging
::
Logger
::
INFO_HIGH
<<
"viscosity [dx^2/dt] = "
<<
viscosityLB
<<
"
\n
"
;
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
// set
analyz
ers
// set
paramet
ers
//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////
CupsAnalyzer
cupsAnalyzer
(
dataBase
,
false
,
60.0
,
true
,
10000
);
para
->
setOutputPath
(
outputPath
);
para
->
setOutputPrefix
(
simulationName
);
ConvergenceAnalyzer
convergenceAnalyzer
(
dataBase
,
10000
);
para
->
setPathAndFilename
(
para
->
getOutputPath
()
+
"/"
+
para
->
getOutputPrefix
()
);
cupsAnalyzer
.
start
(
);
para
->
setPrintFiles
(
true
);
//////////////////////////////////////////////////////////////////////////
para
->
setVelocityLB
(
velocityLB
);
// run simulation
para
->
setViscosityLB
(
viscosityLB
);
//////////////////////////////////////////////////////////////////////////
for
(
uint
iter
=
1
;
iter
<=
timeStepEnd
;
iter
++
)
{
para
->
setVelocityRatio
(
velocity
/
velocityLB
);
TimeStepping
::
nestedTimeStep
(
dataBase
,
parameters
,
0
);
if
(
iter
%
timeStepOut
==
0
)
{
para
->
setTimestepOut
(
timeStepOut
);
dataBase
->
copyDataDeviceToHost
(
);
para
->
setTimestepEnd
(
timeStepEnd
);
VtkWriter
::
write
(
dataBase
,
parameters
,
outputPath
+
"/"
+
simulationName
+
"_"
+
std
::
to_string
(
iter
));
//////////////////////////////////////////////////////////////////////////
}
// set boundary conditions
//////////////////////////////////////////////////////////////////////////
int
crashCellIndex
=
dataBase
->
getCrashCellIndex
();
gridBuilder
->
setNoSlipBoundaryCondition
(
SideType
::
PX
);
if
(
crashCellIndex
>=
0
)
{
gridBuilder
->
setNoSlipBoundaryCondition
(
SideType
::
MX
);
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
gridBuilder
->
setNoSlipBoundaryCondition
(
SideType
::
PY
);
<<
"Simulation crashed at CellIndex = "
<<
crashCellIndex
<<
"
\n
"
;
gridBuilder
->
setNoSlipBoundaryCondition
(
SideType
::
MY
);
dataBase
->
copyDataDeviceToHost
();
gridBuilder
->
setVelocityBoundaryCondition
(
SideType
::
PZ
,
vx
,
vy
,
0.0
);
VtkWriter
::
write
(
dataBase
,
parameters
,
outputPath
+
"/"
+
simulationName
+
"_"
+
std
::
to_string
(
iter
));
gridBuilder
->
setNoSlipBoundaryCondition
(
SideType
::
MZ
);
gridBuilder
->
setVelocityBoundaryCondition
(
SideType
::
GEOMETRY
,
0.0
,
0.0
,
0.0
);
break
;
//////////////////////////////////////////////////////////////////////////
}
// set copy mesh to simulation
//////////////////////////////////////////////////////////////////////////
dataBase
->
getCrashCellIndex
(
);
SPtr
<
CudaMemoryManager
>
cudaMemoryManager
=
CudaMemoryManager
::
make
(
para
);
cupsAnalyzer
.
run
(
iter
,
parameters
.
dt
);
SPtr
<
GridProvider
>
gridGenerator
=
GridProvider
::
makeGridGenerator
(
gridBuilder
,
para
,
cudaMemoryManager
);
convergenceAnalyzer
.
run
(
iter
);
//////////////////////////////////////////////////////////////////////////
}
// run simulation
}
//////////////////////////////////////////////////////////////////////////
}
catch
(
const
std
::
bad_alloc
&
e
)
{
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
"
;
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
"Bad Alloc:"
<<
e
.
what
()
<<
"
\n
"
;
}
catch
(
const
std
::
exception
&
e
)
{
}
catch
(
const
std
::
exception
&
e
)
{
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
e
.
what
()
<<
"
\n
"
;
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
e
.
what
()
<<
"
\n
"
;
}
catch
(
std
::
string
&
s
)
{
}
catch
(
std
::
string
&
s
)
{
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
s
<<
"
\n
"
;
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
s
<<
"
\n
"
;
}
catch
(...)
{
}
catch
(...)
{
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
"Unknown exception!
\n
"
;
*
logging
::
out
<<
logging
::
Logger
::
LOGGER_ERROR
<<
"Unknown exception!
\n
"
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment