Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TurTLE
TurTLE
Commits
11fa51cb
Commit
11fa51cb
authored
Jan 08, 2016
by
Cristian Lalescu
Browse files
Merge branch 'feature/particle-API' into develop
parents
66b02365
553a7bb8
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
bfps/NavierStokes.py
View file @
11fa51cb
This diff is collapsed.
Click to expand it.
bfps/cpp/rFFTW_interpolator.cpp
View file @
11fa51cb
...
...
@@ -32,15 +32,13 @@
template
<
class
rnumber
,
int
interp_neighbours
>
rFFTW_interpolator
<
rnumber
,
interp_neighbours
>::
rFFTW_interpolator
(
fluid_solver_base
<
rnumber
>
*
fs
,
base_polynomial_values
BETA_POLYS
)
base_polynomial_values
BETA_POLYS
,
rnumber
*
FIELD
)
{
this
->
descriptor
=
fs
->
rd
;
this
->
field_size
=
2
*
fs
->
cd
->
local_size
;
this
->
compute_beta
=
BETA_POLYS
;
if
(
sizeof
(
rnumber
)
==
4
)
this
->
field
=
(
rnumber
*
)((
void
*
)
fftwf_alloc_real
(
this
->
field_size
));
else
if
(
sizeof
(
rnumber
)
==
8
)
this
->
field
=
(
rnumber
*
)((
void
*
)
fftw_alloc_real
(
this
->
field_size
));
this
->
field
=
FIELD
;
// compute dx, dy, dz;
this
->
dx
=
4
*
acos
(
0
)
/
(
fs
->
dkx
*
this
->
descriptor
->
sizes
[
2
]);
...
...
@@ -59,24 +57,9 @@ rFFTW_interpolator<rnumber, interp_neighbours>::rFFTW_interpolator(
template
<
class
rnumber
,
int
interp_neighbours
>
rFFTW_interpolator
<
rnumber
,
interp_neighbours
>::~
rFFTW_interpolator
()
{
if
(
sizeof
(
rnumber
)
==
4
)
fftwf_free
((
float
*
)((
void
*
)
this
->
field
));
else
if
(
sizeof
(
rnumber
)
==
8
)
fftw_free
((
double
*
)((
void
*
)
this
->
field
));
delete
[]
this
->
compute
;
}
template
<
class
rnumber
,
int
interp_neighbours
>
int
rFFTW_interpolator
<
rnumber
,
interp_neighbours
>::
read_rFFTW
(
void
*
void_src
)
{
rnumber
*
src
=
(
rnumber
*
)
void_src
;
/* do big copy of middle stuff */
std
::
copy
(
src
,
src
+
this
->
field_size
,
this
->
field
);
return
EXIT_SUCCESS
;
}
template
<
class
rnumber
,
int
interp_neighbours
>
void
rFFTW_interpolator
<
rnumber
,
interp_neighbours
>::
get_grid_coordinates
(
const
int
nparticles
,
...
...
bfps/cpp/rFFTW_interpolator.hpp
View file @
11fa51cb
...
...
@@ -60,7 +60,8 @@ class rFFTW_interpolator
rFFTW_interpolator
(
fluid_solver_base
<
rnumber
>
*
FSOLVER
,
base_polynomial_values
BETA_POLYS
);
base_polynomial_values
BETA_POLYS
,
rnumber
*
FIELD_DATA
);
~
rFFTW_interpolator
();
/* map real locations to grid coordinates */
...
...
@@ -83,7 +84,6 @@ class rFFTW_interpolator
const
double
*
__restrict__
xx
,
double
*
__restrict__
dest
,
const
int
*
deriv
=
NULL
);
int
read_rFFTW
(
void
*
src
);
};
#endif//RFFTW_INTERPOLATOR
...
...
bfps/fluid_base.py
View file @
11fa51cb
...
...
@@ -130,9 +130,10 @@ class fluid_particle_base(bfps.code):
'hsize_t dset;
\n
'
)
for
key
in
[
'state'
,
'velocity'
,
'acceleration'
]:
self
.
definitions
+=
(
'full_name = (std::string(name) + std::string("/{0}"));
\n
'
.
format
(
key
)
+
'if (H5Lexists(g_id, full_name.c_str(), H5P_DEFAULT))
\n
{
\n
'
+
'dset = H5Dopen(g_id, full_name.c_str(), H5P_DEFAULT);
\n
'
+
'grow_single_dataset(dset, niter_todo/niter_part);
\n
'
+
'H5Dclose(dset);
\n
'
)
'H5Dclose(dset);
\n
}
\n
'
)
self
.
definitions
+=
(
'full_name = (std::string(name) + std::string("/rhs"));
\n
'
+
'if (H5Lexists(g_id, full_name.c_str(), H5P_DEFAULT))
\n
{
\n
'
+
'dset = H5Dopen(g_id, full_name.c_str(), H5P_DEFAULT);
\n
'
+
...
...
@@ -445,25 +446,24 @@ class fluid_particle_base(bfps.code):
dtype
=
np
.
int64
,
compression
=
'gzip'
)
for
s
in
range
(
self
.
particle_species
):
if
self
.
parameters
[
'tracers{0}_integration_method'
.
format
(
s
)]
==
'AdamsBashforth'
:
time_chunk
=
2
**
20
//
(
8
*
3
*
self
.
parameters
[
'nparticles'
]
*
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)])
time_chunk
=
max
(
time_chunk
,
1
)
ofile
.
create_dataset
(
'particles/tracers{0}/rhs'
.
format
(
s
),
(
1
,
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)],
self
.
parameters
[
'nparticles'
],
3
),
maxshape
=
(
None
,
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)],
self
.
parameters
[
'nparticles'
],
3
),
chunks
=
(
time_chunk
,
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)],
self
.
parameters
[
'nparticles'
],
3
),
dtype
=
np
.
float64
)
time_chunk
=
2
**
20
//
(
8
*
3
*
self
.
parameters
[
'nparticles'
]
*
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)])
time_chunk
=
max
(
time_chunk
,
1
)
ofile
.
create_dataset
(
'particles/tracers{0}/rhs'
.
format
(
s
),
(
1
,
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)],
self
.
parameters
[
'nparticles'
],
3
),
maxshape
=
(
None
,
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)],
self
.
parameters
[
'nparticles'
],
3
),
chunks
=
(
time_chunk
,
self
.
parameters
[
'tracers{0}_integration_steps'
.
format
(
s
)],
self
.
parameters
[
'nparticles'
],
3
),
dtype
=
np
.
float64
)
time_chunk
=
2
**
20
//
(
8
*
3
*
self
.
parameters
[
'nparticles'
])
time_chunk
=
max
(
time_chunk
,
1
)
ofile
.
create_dataset
(
...
...
@@ -474,14 +474,15 @@ class fluid_particle_base(bfps.code):
chunks
=
(
time_chunk
,
self
.
parameters
[
'nparticles'
],
3
),
maxshape
=
(
None
,
self
.
parameters
[
'nparticles'
],
3
),
dtype
=
np
.
float64
)
ofile
.
create_dataset
(
'/particles/tracers{0}/acceleration'
.
format
(
s
),
(
1
,
self
.
parameters
[
'nparticles'
],
3
),
chunks
=
(
time_chunk
,
self
.
parameters
[
'nparticles'
],
3
),
maxshape
=
(
None
,
self
.
parameters
[
'nparticles'
],
3
),
dtype
=
np
.
float64
)
if
self
.
parameters
[
'tracers{0}_acc_on'
.
format
(
s
)]:
ofile
.
create_dataset
(
'/particles/tracers{0}/acceleration'
.
format
(
s
),
(
1
,
self
.
parameters
[
'nparticles'
],
3
),
chunks
=
(
time_chunk
,
self
.
parameters
[
'nparticles'
],
3
),
maxshape
=
(
None
,
self
.
parameters
[
'nparticles'
],
3
),
dtype
=
np
.
float64
)
ofile
.
close
()
return
None
done.txt
View file @
11fa51cb
...
...
@@ -6,3 +6,7 @@ x 2015-12-26 call interpolation only when needed @optimizati
x 2015-12-26 clean up tox files, make sure all tests run @tests +v1.0
x 2016-01-03 check divfree function
x 2016-01-03 compute kMeta(t) as well
x 2016-01-03 split library into core and extra @optimization +v1.0
x 2016-01-07 FFTW interpolator doesn't need its own field @optimization +v1.0 +particle_api
x 2016-01-08 simplify tracer/field addition mechanism @design +v1.0 +particle_api
x 2016-01-08 add stat choice parameter to add_particles @design +v1.0 +particle_api
tests/base.py
View file @
11fa51cb
...
...
@@ -102,29 +102,19 @@ def launch(
c
.
parameters
[
'famplitude'
]
=
0.2
c
.
fill_up_fluid_code
()
if
c
.
parameters
[
'nparticles'
]
>
0
:
c
.
add_particle_fields
(
name
=
'regular'
,
c
.
add_3D_rFFTW_field
(
name
=
'rFFTW_acc'
)
c
.
add_interpolator
(
name
=
'spline'
,
neighbours
=
opt
.
neighbours
,
smoothness
=
opt
.
smoothness
)
c
.
add_particle_fields
(
kcut
=
'fs->kM/2'
,
name
=
'filtered'
,
neighbours
=
opt
.
neighbours
)
c
.
add_particles
(
kcut
=
'fs->kM/2'
,
integration_steps
=
1
,
fields_name
=
'filtered'
)
#for integr_steps in range(1, 7):
# c.add_particles(
# integration_steps = integr_steps,
# neighbours = opt.neighbours,
# smoothness = opt.smoothness,
# fields_name = 'regular')
for
info
in
[(
2
,
'AdamsBashforth'
),
(
3
,
'AdamsBashforth'
),
(
4
,
'AdamsBashforth'
),
(
6
,
'AdamsBashforth'
)]:
c
.
add_particles
(
integration_steps
=
info
[
0
],
integration_method
=
info
[
1
],
fields_name
=
'regular'
)
kcut
=
[
'fs->kM/2'
,
'fs->kM/3'
],
integration_steps
=
3
,
interpolator
=
'spline'
)
c
.
add_particles
(
integration_steps
=
[
2
,
3
,
4
,
6
],
interpolator
=
'spline'
,
acc_name
=
'rFFTW_acc'
)
c
.
finalize_code
()
c
.
write_src
()
c
.
write_par
()
...
...
@@ -158,6 +148,8 @@ def launch(
def
acceleration_test
(
c
,
m
=
3
,
species
=
0
):
if
not
c
.
parameters
[
'tracers{0}_acc_on'
.
format
(
species
)]:
return
None
import
numpy
as
np
import
matplotlib.pyplot
as
plt
from
bfps.tools
import
get_fornberg_coeffs
...
...
@@ -182,13 +174,12 @@ def acceleration_test(c, m = 3, species = 0):
pid
=
np
.
argmin
(
SNR
(
num_acc1
,
acc
[
n
+
1
:
-
n
-
1
]))
pars
=
d
[
'parameters'
]
to_print
=
(
'integration={0}, steps={1}, interp={2}, neighbours={3}, '
.
format
(
pars
[
'tracers{0}_integration_method'
.
format
(
species
)].
value
,
'steps={0}, interp={1}, neighbours={2}, '
.
format
(
pars
[
'tracers{0}_integration_steps'
.
format
(
species
)].
value
,
pars
[
str
(
pars
[
'tracers{0}_
field
'
.
format
(
species
)].
value
)
+
'_type'
].
value
,
pars
[
str
(
pars
[
'tracers{0}_
field
'
.
format
(
species
)].
value
)
+
'_neighbours'
].
value
))
if
'spline'
in
pars
[
'tracers{0}_
field
'
.
format
(
species
)].
value
:
to_print
+=
'smoothness = {0}, '
.
format
(
pars
[
str
(
pars
[
'tracers{0}_
field
'
.
format
(
species
)].
value
)
+
'_smoothness'
].
value
)
pars
[
str
(
pars
[
'tracers{0}_
interpolator
'
.
format
(
species
)].
value
)
+
'_type'
].
value
,
pars
[
str
(
pars
[
'tracers{0}_
interpolator
'
.
format
(
species
)].
value
)
+
'_neighbours'
].
value
))
if
'spline'
in
pars
[
'tracers{0}_
interpolator
'
.
format
(
species
)].
value
:
to_print
+=
'smoothness = {0}, '
.
format
(
pars
[
str
(
pars
[
'tracers{0}_
interpolator
'
.
format
(
species
)].
value
)
+
'_smoothness'
].
value
)
to_print
+=
(
'SNR d1p-vel={0:.3f}, d1v-acc={1:.3f}, d2p-acc={2:.3f}'
.
format
(
np
.
mean
(
SNR
(
num_vel1
,
vel
[
n
+
1
:
-
n
-
1
])),
...
...
todo.txt
View file @
11fa51cb
(B) FFTW interpolator doesn't need its own field @optimization +v1.0
(B) compute z polynomials only when needed @optimization +v1.0
(B) compute z polynomials only when needed @optimization +v1.0
(B) read https://www.xsede.org/documents/271087/369161/ExtScale-Koziol.pdf @optimization @HDF5 +I/O
(B) set up mechanism for adding in new PDEs @design +v2.0 +alternate_algorithms
(B)
split library into core and extra
@optimization
+v1.0
(B)
tweak HDF5 settings
@optimization
@HDF5 +I/O
(
B) use less memory
@
optimization
(C) c
lean up machine_settings mess @design
@documentation
+v2.0
(C)
code overview
@d
ocumentation
(C)
move stat I/O to cpp lib
@
d
es
ign @HDF5
(C)
test involving hydrodynamic similarity
@
t
es
ts
(
C
)
use HDF5 io for fields
@
d
es
ign @HDF5 +I/O
(D) genera
lize interpolation comparison test @test
s
(D) test anisotropic grids @tests
(D) test non-cubic domains @tests
(D) tests should not overwrite other tests (tox_full) @tests
(E) add u-equation algorithm for testing purposes @tests +alternate_algorithms
(E) pure python DNS addon: pros and cons @tests +alternate_algorithms
(B) set up mechanism for adding in new PDEs
@design +v2.0 +alternate_algorithms
(B)
tweak HDF5 settings
@optimization
@HDF5 +I/O
(B)
use less memory
@optimization
(
C) clean up machine_settings mess
@
design @documentation +v2.0
(C) c
ode overview
@documentation
(C)
move stat I/O to cpp lib
@d
esign @HDF5
(C)
test involving hydrodynamic similarity
@
t
es
ts
(C)
use HDF5 io for fields
@
d
es
ign @HDF5 +I/O
(
D
)
generalize interpolation comparison test
@
t
es
ts
(D) genera
te separate lib(s) with extra classes @tests +alternate_algorithm
s
(D) test anisotropic grids
@tests
(D) test non-cubic domains
@tests
(D) tests should not overwrite other tests (tox_full)
@tests
(E) add u-equation algorithm for testing purposes
@tests +alternate_algorithms
(E) pure python DNS addon: pros and cons
@tests +alternate_algorithms
(F) add switch to turn off simulation
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment