Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
palathark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
orestis.malaspin
palathark
Commits
55219fc3
Verified
Commit
55219fc3
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
corrected order of frees
parent
45c67335
No related branches found
No related tags found
No related merge requests found
Pipeline
#15853
passed
3 years ago
Stage: test
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
apps/cavity3d/cavity3d.c
+64
-44
64 additions, 44 deletions
apps/cavity3d/cavity3d.c
apps/kida/kida.c
+66
-46
66 additions, 46 deletions
apps/kida/kida.c
with
130 additions
and
90 deletions
apps/cavity3d/cavity3d.c
+
64
−
44
View file @
55219fc3
#include
<liblbm.h>
#include
"c_interface/includes.h"
#include
"c_interface/includes.h"
#include
<assert.h>
#include
<float.h>
#include
<liblbm.h>
#include
<math.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<string.h>
#include
<string.h>
#include
<assert.h>
#include
<time.h>
#include
<time.h>
#include
<float.h>
#include
<math.h>
#ifdef D3Q19
#ifdef D3Q19
const
fint
l_q
=
19
;
const
fint
l_q
=
19
;
...
@@ -19,11 +19,13 @@ const fint l_q = 27;
...
@@ -19,11 +19,13 @@ const fint l_q = 27;
* Print how the program is supposed to be called
* Print how the program is supposed to be called
*/
*/
void
usage
()
{
void
usage
()
{
printf
(
"%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
"
,
"
\n
usage:
\n
./lbm <n> <Re> <max_t> [<prefix>]"
,
printf
(
"%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
"
,
"where:"
,
" <n> is the mesh dimension in each spatial direction ( >= 10),"
,
"
\n
usage:
\n
./lbm <n> <Re> <max_t> [<prefix>]"
,
"where:"
,
" <n> is the mesh dimension in each spatial direction ( >= 10),"
,
"
\t
<Re> is the Reynolds number"
,
"
\t
<Re> is the Reynolds number"
,
"
\t
<max_t> is maximum simulation time in physical units."
,
"
\t
<max_t> is maximum simulation time in physical units."
,
"
\t
[<prefix>]: (optional argument) is the directory name where the output will be written."
);
"
\t
[<prefix>]: (optional argument) is the directory name where the "
"output will be written."
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
...
@@ -50,24 +52,33 @@ int main(int argc, char **argv) {
...
@@ -50,24 +52,33 @@ int main(int argc, char **argv) {
// const T log_t = 2.0;
// const T log_t = 2.0;
const
T
u_max
=
0
.
1
;
const
T
u_max
=
0
.
1
;
units_converter
units
=
units_converter_create_inertial
(
Re
,
1
.
0
,
n
,
1
.
0
,
u_max
,
1
.
0
,
1
.
0
,
1
.
0
);
units_converter
units
=
units_converter_create_inertial
(
Re
,
1
.
0
,
n
,
1
.
0
,
u_max
,
1
.
0
,
1
.
0
,
1
.
0
);
units_converter_print
(
units
);
units_converter_print
(
units
);
const
fint
iter
=
(
fint
)(
end_time
/
units
.
delta_t
+
0
.
5
);
const
fint
iter
=
(
fint
)(
end_time
/
units
.
delta_t
+
0
.
5
);
// Norme des vitesses en chaque point du maillage (struct futhark et c)
// Norme des vitesses en chaque point du maillage (struct futhark et c)
T
rho
=
1
.
0
;
T
rho
=
1
.
0
;
// tensor_field lattice = lbm_allocate_and_ini_at_equilibrium_kida(rho, u_max, n+1, n+1, n+1, l_q);
// tensor_field lattice = lbm_allocate_and_ini_at_equilibrium_kida(rho,
tensor_field
lattice
=
lbm_allocate_and_ini_at_equilibrium_cavity
(
rho
,
u_max
,
n
+
1
,
n
+
1
,
n
+
1
,
l_q
);
// u_max, n+1, n+1, n+1, l_q);
tensor_field
lattice
=
lbm_allocate_and_ini_at_equilibrium_cavity
(
triangle
*
cavity
=
triangle_create_cube
(
point_create
(
0
.
5
,
0
.
5
,
0
.
5
),
point_create
(
n
-
0
.
5
,
n
-
0
.
5
,
n
-
0
.
5
));
rho
,
u_max
,
n
+
1
,
n
+
1
,
n
+
1
,
l_q
);
tensor_field
distances
=
create_distances
(
lattice
.
nx
,
lattice
.
ny
,
lattice
.
nz
,
lattice
.
q
,
cavity
,
12
);
triangle
*
cavity
=
triangle_create_cube
(
point_create
(
0
.
5
,
0
.
5
,
0
.
5
),
point_create
(
n
-
0
.
5
,
n
-
0
.
5
,
n
-
0
.
5
));
tensor_field
distances
=
create_distances
(
lattice
.
nx
,
lattice
.
ny
,
lattice
.
nz
,
lattice
.
q
,
cavity
,
12
);
if
(
prefix
!=
NULL
)
{
if
(
prefix
!=
NULL
)
{
triangle_write_stl
(
cavity
,
12
,
prefix
,
"cavity"
);
triangle_write_stl
(
cavity
,
12
,
prefix
,
"cavity"
);
printf
(
"output distances %d
\n
"
,
0
);
printf
(
"output distances %d
\n
"
,
0
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"dist"
,
0
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"dist"
,
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
1
.
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
vtk_file_write_tensor_field
(
&
vtk
,
&
distances
,
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
"distances"
,
base64
);
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
1
.
0
);
vtk_file_write_tensor_field
(
&
vtk
,
&
distances
,
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
"distances"
,
base64
);
vtk_file_close
(
&
vtk
);
vtk_file_close
(
&
vtk
);
free
(
fname
);
free
(
fname
);
...
@@ -82,7 +93,8 @@ int main(int argc, char **argv) {
...
@@ -82,7 +93,8 @@ int main(int argc, char **argv) {
// TODO add version with rho/u as outputu from futhark
// TODO add version with rho/u as outputu from futhark
// futhark_4d *f_vel = tensor_field_to_futhark_f32_4d(velocity, ctx);
// futhark_4d *f_vel = tensor_field_to_futhark_f32_4d(velocity, ctx);
// struct futhark_f32_3d *f_rho = scalar_field_to_futhark_f32_3d(density, ctx);
// struct futhark_f32_3d *f_rho = scalar_field_to_futhark_f32_3d(density,
// ctx);
struct
timespec
start
,
finish
;
struct
timespec
start
,
finish
;
fint
delta_iter
=
max
((
fint
)(
log_t
/
units
.
delta_t
+
0
.
5
),
1
);
fint
delta_iter
=
max
((
fint
)(
log_t
/
units
.
delta_t
+
0
.
5
),
1
);
...
@@ -101,20 +113,26 @@ int main(int argc, char **argv) {
...
@@ -101,20 +113,26 @@ int main(int argc, char **argv) {
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
it
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
it
);
box
domain
=
box_create
(
1
,
lattice
.
nx
-
2
,
1
,
lattice
.
ny
-
2
,
1
,
lattice
.
nz
-
2
);
box
domain
=
box_create
(
1
,
lattice
.
nx
-
2
,
1
,
lattice
.
ny
-
2
,
1
,
lattice
.
nz
-
2
);
// vtk_file vtk = vtk_file_create_default(fname, box_create(0, lattice.nx-1, 0, lattice.ny-1, 0, lattice.nz-1), 1.0);
// vtk_file vtk = vtk_file_create_default(fname, box_create(0,
// lattice.nx-1, 0, lattice.ny-1, 0, lattice.nz-1), 1.0);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file_write_scalar_field
(
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_scalar_field
(
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
vtk_file_close
(
&
vtk
);
vtk_file_close
(
&
vtk
);
free
(
fname
);
free
(
fname
);
}
}
f
=
lbm_collide_and_stream
(
ctx
,
&
f
,
vel_ini
,
d
,
units
.
omega
,
delta_iter
);
f
=
lbm_collide_and_stream
(
ctx
,
&
f
,
vel_ini
,
d
,
units
.
omega
,
delta_iter
);
// TODO add version with rho/u as output
// TODO add version with rho/u as output
// f = lbm_collide_and_stream_rho_u(ctx, &f, &f_rho, &f_vel, units.omega, delta_iter);
// f = lbm_collide_and_stream_rho_u(ctx, &f, &f_rho, &f_vel,
// units.omega, delta_iter);
i
+=
1
;
i
+=
1
;
}
}
...
@@ -124,8 +142,9 @@ int main(int argc, char **argv) {
...
@@ -124,8 +142,9 @@ int main(int argc, char **argv) {
T
elapsed
=
(
finish
.
tv_sec
-
start
.
tv_sec
)
*
1e6
;
T
elapsed
=
(
finish
.
tv_sec
-
start
.
tv_sec
)
*
1e6
;
elapsed
+=
(
finish
.
tv_nsec
-
start
.
tv_nsec
)
/
1e3
;
elapsed
+=
(
finish
.
tv_nsec
-
start
.
tv_nsec
)
/
1e3
;
printf
(
"elapsed microseconds = %f
\n
"
,
elapsed
);
printf
(
"elapsed microseconds = %f
\n
"
,
elapsed
);
printf
(
"approximative MLUSP = %f
\n
"
,
(
T
)
units
.
nx
*
(
T
)
units
.
ny
*
(
T
)
units
.
nz
*
(
T
)
i
*
(
T
)
delta_iter
/
elapsed
);
printf
(
"approximative MLUSP = %f
\n
"
,
(
T
)
units
.
nx
*
(
T
)
units
.
ny
*
(
T
)
units
.
nz
*
(
T
)
i
*
(
T
)
delta_iter
/
elapsed
);
if
(
prefix
!=
NULL
)
{
if
(
prefix
!=
NULL
)
{
printf
(
"output at iter %d
\n
"
,
iter
);
printf
(
"output at iter %d
\n
"
,
iter
);
...
@@ -135,18 +154,19 @@ int main(int argc, char **argv) {
...
@@ -135,18 +154,19 @@ int main(int argc, char **argv) {
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
iter
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
iter
);
box
domain
=
box_create
(
1
,
lattice
.
nx
-
2
,
1
,
lattice
.
ny
-
2
,
1
,
lattice
.
nz
-
2
);
box
domain
=
box_create
(
1
,
lattice
.
nx
-
2
,
1
,
lattice
.
ny
-
2
,
1
,
lattice
.
nz
-
2
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file_write_scalar_field
(
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_scalar_field
(
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
vtk_file_close
(
&
vtk
);
vtk_file_close
(
&
vtk
);
free
(
fname
);
free
(
fname
);
}
}
free
(
cavity
);
free
(
cavity
);
tensor_field_deallocate
(
lattice
);
tensor_field_deallocate
(
lattice
);
tensor_field_deallocate
(
velocity
);
tensor_field_deallocate
(
velocity
);
scalar_field_deallocate
(
density
);
scalar_field_deallocate
(
density
);
...
@@ -159,8 +179,8 @@ int main(int argc, char **argv) {
...
@@ -159,8 +179,8 @@ int main(int argc, char **argv) {
// futhark_free_4d(ctx, f_vel);
// futhark_free_4d(ctx, f_vel);
// futhark_free_f32_3d(ctx, f_rho);
// futhark_free_f32_3d(ctx, f_rho);
futhark_context_config_free
(
cfg
);
futhark_context_free
(
ctx
);
futhark_context_free
(
ctx
);
futhark_context_config_free
(
cfg
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
This diff is collapsed.
Click to expand it.
apps/kida/kida.c
+
66
−
46
View file @
55219fc3
#include
<liblbm.h>
#include
"c_interface/includes.h"
#include
"c_interface/includes.h"
#include
<assert.h>
#include
<float.h>
#include
<liblbm.h>
#include
<math.h>
#include
<stdio.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdlib.h>
#include
<string.h>
#include
<string.h>
#include
<assert.h>
#include
<time.h>
#include
<time.h>
#include
<float.h>
#include
<math.h>
#ifdef D3Q19
#ifdef D3Q19
const
fint
l_q
=
19
;
const
fint
l_q
=
19
;
...
@@ -19,11 +19,13 @@ const fint l_q = 27;
...
@@ -19,11 +19,13 @@ const fint l_q = 27;
* Print how the program is supposed to be called
* Print how the program is supposed to be called
*/
*/
void
usage
()
{
void
usage
()
{
printf
(
"%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
"
,
"
\n
usage:
\n
./lbm <n> <Re> <max_t> [<prefix>]"
,
printf
(
"%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
%s
\n
"
,
"where:"
,
" <n> is the mesh dimension in each spatial direction ( >= 10),"
,
"
\n
usage:
\n
./lbm <n> <Re> <max_t> [<prefix>]"
,
"where:"
,
" <n> is the mesh dimension in each spatial direction ( >= 10),"
,
"
\t
<Re> is the Reynolds number"
,
"
\t
<Re> is the Reynolds number"
,
"
\t
<max_t> is maximum simulation time in physical units."
,
"
\t
<max_t> is maximum simulation time in physical units."
,
"
\t
[<prefix>]: (optional argument) is the directory name where the output will be written."
);
"
\t
[<prefix>]: (optional argument) is the directory name where the "
"output will be written."
);
}
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
...
@@ -52,21 +54,28 @@ int main(int argc, char **argv) {
...
@@ -52,21 +54,28 @@ int main(int argc, char **argv) {
// const T log_t = 2.0;
// const T log_t = 2.0;
const
T
u_max
=
0
.
1
;
const
T
u_max
=
0
.
1
;
units_converter
units
=
units_converter_create_inertial
(
Re
,
1
.
0
,
n
,
1
.
0
,
u_max
,
1
.
0
,
1
.
0
,
1
.
0
);
units_converter
units
=
units_converter_create_inertial
(
Re
,
1
.
0
,
n
,
1
.
0
,
u_max
,
1
.
0
,
1
.
0
,
1
.
0
);
units_converter_print
(
units
);
units_converter_print
(
units
);
const
fint
iter
=
(
fint
)(
end_time
/
units
.
delta_t
+
0
.
5
);
const
fint
iter
=
(
fint
)(
end_time
/
units
.
delta_t
+
0
.
5
);
// Norme des vitesses en chaque point du maillage (struct futhark et c)
// Norme des vitesses en chaque point du maillage (struct futhark et c)
T
rho
=
1
.
0
;
T
rho
=
1
.
0
;
tensor_field
lattice
=
lbm_allocate_and_ini_at_equilibrium_kida
(
rho
,
u_max
,
n
+
1
,
n
+
1
,
n
+
1
,
l_q
);
tensor_field
lattice
=
lbm_allocate_and_ini_at_equilibrium_kida
(
rho
,
u_max
,
n
+
1
,
n
+
1
,
n
+
1
,
l_q
);
tensor_field
distances
=
create_distances_inactive
(
lattice
.
nx
,
lattice
.
ny
,
lattice
.
nz
,
lattice
.
q
);
tensor_field
distances
=
create_distances_inactive
(
lattice
.
nx
,
lattice
.
ny
,
lattice
.
nz
,
lattice
.
q
);
if
(
prefix
!=
NULL
)
{
if
(
prefix
!=
NULL
)
{
printf
(
"output distances %d
\n
"
,
0
);
printf
(
"output distances %d
\n
"
,
0
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"dist"
,
0
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"dist"
,
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
1
.
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
vtk_file_write_tensor_field
(
&
vtk
,
&
distances
,
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
"distances"
,
base64
);
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
1
.
0
);
vtk_file_write_tensor_field
(
&
vtk
,
&
distances
,
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
),
"distances"
,
base64
);
vtk_file_close
(
&
vtk
);
vtk_file_close
(
&
vtk
);
free
(
fname
);
free
(
fname
);
...
@@ -81,7 +90,8 @@ int main(int argc, char **argv) {
...
@@ -81,7 +90,8 @@ int main(int argc, char **argv) {
// TODO add version with rho/u as outputu from futhark
// TODO add version with rho/u as outputu from futhark
// futhark_4d *f_vel = tensor_field_to_futhark_f32_4d(velocity, ctx);
// futhark_4d *f_vel = tensor_field_to_futhark_f32_4d(velocity, ctx);
// struct futhark_f32_3d *f_rho = scalar_field_to_futhark_f32_3d(density, ctx);
// struct futhark_f32_3d *f_rho = scalar_field_to_futhark_f32_3d(density,
// ctx);
struct
timespec
start
,
finish
;
struct
timespec
start
,
finish
;
fint
delta_iter
=
max
((
fint
)(
log_t
/
units
.
delta_t
+
0
.
5
),
1
);
fint
delta_iter
=
max
((
fint
)(
log_t
/
units
.
delta_t
+
0
.
5
),
1
);
...
@@ -100,25 +110,32 @@ int main(int argc, char **argv) {
...
@@ -100,25 +110,32 @@ int main(int argc, char **argv) {
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
it
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
it
);
box
domain
=
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
);
box
domain
=
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
);
// vtk_file vtk = vtk_file_create_default(fname, box_create(0, lattice.nx-1, 0, lattice.ny-1, 0, lattice.nz-1), 1.0);
// vtk_file vtk = vtk_file_create_default(fname, box_create(0,
// lattice.nx-1, 0, lattice.ny-1, 0, lattice.nz-1), 1.0);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file_write_scalar_field
(
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_scalar_field
(
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
vtk_file_close
(
&
vtk
);
vtk_file_close
(
&
vtk
);
free
(
fname
);
free
(
fname
);
triangle_field
tri
=
triangle_field_polygonise
(
density
,
ctx
,
1
.
0
,
mtetras
);
// mtetras or mcubes
triangle_field
tri
=
triangle_field_polygonise
(
density
,
ctx
,
1
.
0
,
mtetras
);
// mtetras or mcubes
char
*
stl_fname
=
stl_create_fname
(
prefix
,
"iso_surface_tetras"
,
it
);
char
*
stl_fname
=
stl_create_fname
(
prefix
,
"iso_surface_tetras"
,
it
);
stl_file
stl
=
stl_file_create
(
stl_fname
);
stl_file
stl
=
stl_file_create
(
stl_fname
);
stl_file_write_triangle_field
(
&
stl
,
tri
);
stl_file_write_triangle_field
(
&
stl
,
tri
);
stl_file_close
(
&
stl
);
stl_file_close
(
&
stl
);
free
(
stl_fname
);
free
(
stl_fname
);
triangle_field_deallocate
(
tri
);
triangle_field_deallocate
(
tri
);
tri
=
triangle_field_polygonise
(
density
,
ctx
,
1
.
0
,
mcubes
);
// mtetras or mcubes
tri
=
triangle_field_polygonise
(
density
,
ctx
,
1
.
0
,
mcubes
);
// mtetras or mcubes
stl_fname
=
stl_create_fname
(
prefix
,
"iso_surface_cubes"
,
it
);
stl_fname
=
stl_create_fname
(
prefix
,
"iso_surface_cubes"
,
it
);
stl
=
stl_file_create
(
stl_fname
);
stl
=
stl_file_create
(
stl_fname
);
...
@@ -126,12 +143,13 @@ int main(int argc, char **argv) {
...
@@ -126,12 +143,13 @@ int main(int argc, char **argv) {
stl_file_close
(
&
stl
);
stl_file_close
(
&
stl
);
free
(
stl_fname
);
free
(
stl_fname
);
triangle_field_deallocate
(
tri
);
triangle_field_deallocate
(
tri
);
}
}
f
=
lbm_collide_and_stream
(
ctx
,
&
f
,
vel_ini
,
d
,
units
.
omega
,
delta_iter
);
f
=
lbm_collide_and_stream
(
ctx
,
&
f
,
vel_ini
,
d
,
units
.
omega
,
delta_iter
);
// TODO add version with rho/u as output
// TODO add version with rho/u as output
// f = lbm_collide_and_stream_rho_u(ctx, &f, &f_rho, &f_vel, units.omega, delta_iter);
// f = lbm_collide_and_stream_rho_u(ctx, &f, &f_rho, &f_vel,
// units.omega, delta_iter);
i
+=
1
;
i
+=
1
;
}
}
...
@@ -141,8 +159,9 @@ int main(int argc, char **argv) {
...
@@ -141,8 +159,9 @@ int main(int argc, char **argv) {
T
elapsed
=
(
finish
.
tv_sec
-
start
.
tv_sec
)
*
1e6
;
T
elapsed
=
(
finish
.
tv_sec
-
start
.
tv_sec
)
*
1e6
;
elapsed
+=
(
finish
.
tv_nsec
-
start
.
tv_nsec
)
/
1e3
;
elapsed
+=
(
finish
.
tv_nsec
-
start
.
tv_nsec
)
/
1e3
;
printf
(
"elapsed microseconds = %f
\n
"
,
elapsed
);
printf
(
"elapsed microseconds = %f
\n
"
,
elapsed
);
printf
(
"approximative MLUSP = %f
\n
"
,
(
T
)
units
.
nx
*
(
T
)
units
.
ny
*
(
T
)
units
.
nz
*
(
T
)
i
*
(
T
)
delta_iter
/
elapsed
);
printf
(
"approximative MLUSP = %f
\n
"
,
(
T
)
units
.
nx
*
(
T
)
units
.
ny
*
(
T
)
units
.
nz
*
(
T
)
i
*
(
T
)
delta_iter
/
elapsed
);
if
(
prefix
!=
NULL
)
{
if
(
prefix
!=
NULL
)
{
printf
(
"output at iter %d
\n
"
,
iter
);
printf
(
"output at iter %d
\n
"
,
iter
);
...
@@ -152,17 +171,18 @@ int main(int argc, char **argv) {
...
@@ -152,17 +171,18 @@ int main(int argc, char **argv) {
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
iter
);
char
*
fname
=
vtk_create_fname
(
prefix
,
"out"
,
iter
);
box
domain
=
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
);
box
domain
=
box_create
(
0
,
lattice
.
nx
-
1
,
0
,
lattice
.
ny
-
1
,
0
,
lattice
.
nz
-
1
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file
vtk
=
vtk_file_create_default
(
fname
,
domain
,
1
.
0
);
vtk_file_write_scalar_field
(
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_scalar_field
(
&
vtk
,
&
density
,
domain
,
"density"
,
base64
);
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
vtk_file_write_tensor_field
(
&
vtk
,
&
velocity
,
domain
,
"velocity"
,
base64
);
vtk_file_close
(
&
vtk
);
vtk_file_close
(
&
vtk
);
free
(
fname
);
free
(
fname
);
}
}
tensor_field_deallocate
(
lattice
);
tensor_field_deallocate
(
lattice
);
tensor_field_deallocate
(
velocity
);
tensor_field_deallocate
(
velocity
);
scalar_field_deallocate
(
density
);
scalar_field_deallocate
(
density
);
...
@@ -175,8 +195,8 @@ int main(int argc, char **argv) {
...
@@ -175,8 +195,8 @@ int main(int argc, char **argv) {
// futhark_free_4d(ctx, f_vel);
// futhark_free_4d(ctx, f_vel);
// futhark_free_f32_3d(ctx, f_rho);
// futhark_free_f32_3d(ctx, f_rho);
futhark_context_config_free
(
cfg
);
futhark_context_free
(
ctx
);
futhark_context_free
(
ctx
);
futhark_context_config_free
(
cfg
);
return
EXIT_SUCCESS
;
return
EXIT_SUCCESS
;
}
}
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