Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TurTLE
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
TurTLE
TurTLE
Commits
268acdb9
Commit
268acdb9
authored
Sep 30, 2015
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
make data_file a pointer
parent
cb211d61
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
bfps/NavierStokes.py
+28
-22
28 additions, 22 deletions
bfps/NavierStokes.py
bfps/base.py
+1
-1
1 addition, 1 deletion
bfps/base.py
bfps/code.py
+7
-8
7 additions, 8 deletions
bfps/code.py
with
36 additions
and
31 deletions
bfps/NavierStokes.py
+
28
−
22
View file @
268acdb9
...
@@ -50,7 +50,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -50,7 +50,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
hsize_t dims[4];
hsize_t dims[4];
hsize_t old_dims[4];
hsize_t old_dims[4];
// store kspace information
// store kspace information
dset = data_file
.
openDataSet(
"
/kspace/kshell
"
);
dset = data_file
->
openDataSet(
"
/kspace/kshell
"
);
dspace = dset.getSpace();
dspace = dset.getSpace();
dspace.getSimpleExtentDims(dims);
dspace.getSimpleExtentDims(dims);
if (fs->nshells != dims[0])
if (fs->nshells != dims[0])
...
@@ -59,34 +59,34 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -59,34 +59,34 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
file_problems++;
file_problems++;
}
}
dset.write(fs->kshell, double_dtype);
dset.write(fs->kshell, double_dtype);
dset = data_file
.
openDataSet(
"
/kspace/nshell
"
);
dset = data_file
->
openDataSet(
"
/kspace/nshell
"
);
dset.write(fs->nshell, ptrdiff_t_dtype);
dset.write(fs->nshell, ptrdiff_t_dtype);
dset = data_file
.
openDataSet(
"
/kspace/kM
"
);
dset = data_file
->
openDataSet(
"
/kspace/kM
"
);
dset.write(&fs->kM, double_dtype);
dset.write(&fs->kM, double_dtype);
dset = data_file
.
openDataSet(
"
/kspace/dk
"
);
dset = data_file
->
openDataSet(
"
/kspace/dk
"
);
dset.write(&fs->dk, double_dtype);
dset.write(&fs->dk, double_dtype);
// moments
// moments
dset = data_file
.
openDataSet(
"
/statistics/moments/velocity
"
);
dset = data_file
->
openDataSet(
"
/statistics/moments/velocity
"
);
dspace = dset.getSpace();
dspace = dset.getSpace();
dspace.getSimpleExtentDims(old_dims);
dspace.getSimpleExtentDims(old_dims);
dims[0] = niter_todo + old_dims[0];
dims[0] = niter_todo + old_dims[0];
dims[1] = old_dims[1];
dims[1] = old_dims[1];
dims[2] = old_dims[2];
dims[2] = old_dims[2];
dset.extend(dims);
dset.extend(dims);
dset = data_file
.
openDataSet(
"
/statistics/moments/vorticity
"
);
dset = data_file
->
openDataSet(
"
/statistics/moments/vorticity
"
);
dset.extend(dims);
dset.extend(dims);
// histograms
// histograms
dset = data_file
.
openDataSet(
"
/statistics/histograms/velocity
"
);
dset = data_file
->
openDataSet(
"
/statistics/histograms/velocity
"
);
dspace = dset.getSpace();
dspace = dset.getSpace();
dspace.getSimpleExtentDims(old_dims);
dspace.getSimpleExtentDims(old_dims);
dims[0] = niter_todo + old_dims[0];
dims[0] = niter_todo + old_dims[0];
dims[1] = old_dims[1];
dims[1] = old_dims[1];
dims[2] = old_dims[2];
dims[2] = old_dims[2];
dset.extend(dims);
dset.extend(dims);
dset = data_file
.
openDataSet(
"
/statistics/histograms/vorticity
"
);
dset = data_file
->
openDataSet(
"
/statistics/histograms/vorticity
"
);
dset.extend(dims);
dset.extend(dims);
// spectra
// spectra
dset = data_file
.
openDataSet(
"
/statistics/spectra/velocity_velocity
"
);
dset = data_file
->
openDataSet(
"
/statistics/spectra/velocity_velocity
"
);
dspace = dset.getSpace();
dspace = dset.getSpace();
dspace.getSimpleExtentDims(old_dims);
dspace.getSimpleExtentDims(old_dims);
dims[0] = niter_todo + old_dims[0];
dims[0] = niter_todo + old_dims[0];
...
@@ -94,8 +94,9 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -94,8 +94,9 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
dims[2] = old_dims[2];
dims[2] = old_dims[2];
dims[3] = old_dims[3];
dims[3] = old_dims[3];
dset.extend(dims);
dset.extend(dims);
dset = data_file
.
openDataSet(
"
/statistics/spectra/vorticity_vorticity
"
);
dset = data_file
->
openDataSet(
"
/statistics/spectra/vorticity_vorticity
"
);
dset.extend(dims);
dset.extend(dims);
dset.close();
//endcpp
//endcpp
"""
"""
self
.
style
=
{}
self
.
style
=
{}
...
@@ -133,7 +134,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -133,7 +134,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
H5::DataSpace memspace, writespace;
H5::DataSpace memspace, writespace;
hsize_t count[4], offset[4], old_dims[4];
hsize_t count[4], offset[4], old_dims[4];
//moments
//moments
dset = data_file
.
openDataSet(
"
statistics/moments/velocity
"
);
dset = data_file
->
openDataSet(
"
statistics/moments/velocity
"
);
writespace = dset.getSpace();
writespace = dset.getSpace();
writespace.getSimpleExtentDims(old_dims);
writespace.getSimpleExtentDims(old_dims);
count[0] = 1;
count[0] = 1;
...
@@ -145,10 +146,10 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -145,10 +146,10 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
offset[2] = 0;
offset[2] = 0;
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
dset.write(velocity_moments, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.write(velocity_moments, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset = data_file
.
openDataSet(
"
statistics/moments/vorticity
"
);
dset = data_file
->
openDataSet(
"
statistics/moments/vorticity
"
);
dset.write(vorticity_moments, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.write(vorticity_moments, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
//histograms
//histograms
dset = data_file
.
openDataSet(
"
statistics/histograms/velocity
"
);
dset = data_file
->
openDataSet(
"
statistics/histograms/velocity
"
);
writespace = dset.getSpace();
writespace = dset.getSpace();
count[0] = 1;
count[0] = 1;
count[1] = histogram_bins;
count[1] = histogram_bins;
...
@@ -159,10 +160,10 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -159,10 +160,10 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
offset[2] = 0;
offset[2] = 0;
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
dset.write(hist_velocity, H5::PredType::NATIVE_INT64, memspace, writespace);
dset.write(hist_velocity, H5::PredType::NATIVE_INT64, memspace, writespace);
dset = data_file
.
openDataSet(
"
statistics/histograms/vorticity
"
);
dset = data_file
->
openDataSet(
"
statistics/histograms/vorticity
"
);
dset.write(hist_vorticity, H5::PredType::NATIVE_INT64, memspace, writespace);
dset.write(hist_vorticity, H5::PredType::NATIVE_INT64, memspace, writespace);
//spectra
//spectra
dset = data_file
.
openDataSet(
"
statistics/spectra/velocity_velocity
"
);
dset = data_file
->
openDataSet(
"
statistics/spectra/velocity_velocity
"
);
writespace = dset.getSpace();
writespace = dset.getSpace();
count[1] = fs->nshells;
count[1] = fs->nshells;
count[2] = 3;
count[2] = 3;
...
@@ -171,8 +172,11 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -171,8 +172,11 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
offset[3] = 0;
offset[3] = 0;
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
dset.write(spec_velocity, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.write(spec_velocity, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset = data_file
.
openDataSet(
"
statistics/spectra/vorticity_vorticity
"
);
dset = data_file
->
openDataSet(
"
statistics/spectra/vorticity_vorticity
"
);
dset.write(spec_vorticity, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.write(spec_vorticity, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset = data_file->openDataSet(
"
iteration
"
);
dset.write(&fs->iteration, H5::PredType::NATIVE_INT);
dset.close();
}
}
fftw_free(spec_velocity);
fftw_free(spec_velocity);
fftw_free(spec_vorticity);
fftw_free(spec_vorticity);
...
@@ -236,7 +240,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -236,7 +240,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
temp_string = (std::string(
"
/particles/
"
) +
temp_string = (std::string(
"
/particles/
"
) +
std::string(ps{0}->name) +
std::string(ps{0}->name) +
std::string(
"
/{1}
"
));
std::string(
"
/{1}
"
));
dset = data_file
.
openDataSet(temp_string);
dset = data_file
->
openDataSet(temp_string);
dspace = dset.getSpace();
dspace = dset.getSpace();
dspace.getSimpleExtentDims(dims);
dspace.getSimpleExtentDims(dims);
dims[0] = niter_todo/niter_part + dims[0];
dims[0] = niter_todo/niter_part + dims[0];
...
@@ -274,7 +278,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -274,7 +278,7 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
std::string temp_string = (std::string(
"
/particles/
"
) +
std::string temp_string = (std::string(
"
/particles/
"
) +
std::string(ps{0}->name) +
std::string(ps{0}->name) +
std::string(
"
/velocity
"
));
std::string(
"
/velocity
"
));
H5::DataSet dset = data_file
.
openDataSet(temp_string);
H5::DataSet dset = data_file
->
openDataSet(temp_string);
H5::DataSpace memspace, writespace;
H5::DataSpace memspace, writespace;
hsize_t count[3], offset[3];
hsize_t count[3], offset[3];
writespace = dset.getSpace();
writespace = dset.getSpace();
...
@@ -286,13 +290,15 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -286,13 +290,15 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
memspace = H5::DataSpace(3, count);
memspace = H5::DataSpace(3, count);
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
writespace.selectHyperslab(H5S_SELECT_SET, count, offset);
dset.write(ps{0}->rhs[0], H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.write(ps{0}->rhs[0], H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.close();
//VELOCITY end
//VELOCITY end
//ACCELERATION begin
//ACCELERATION begin
temp_string = (std::string(
"
/particles/
"
) +
temp_string = (std::string(
"
/particles/
"
) +
std::string(ps{0}->name) +
std::string(ps{0}->name) +
std::string(
"
/acceleration
"
));
std::string(
"
/acceleration
"
));
dset = data_file
.
openDataSet(temp_string);
dset = data_file
->
openDataSet(temp_string);
dset.write(acceleration, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.write(acceleration, H5::PredType::NATIVE_DOUBLE, memspace, writespace);
dset.close();
//ACCELERATION end
//ACCELERATION end
}}
}}
fftw_free(acceleration);
fftw_free(acceleration);
...
@@ -308,13 +314,13 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
...
@@ -308,13 +314,13 @@ class NavierStokes(bfps.fluid_base.fluid_particle_base):
'
ps{1}->dt = dt;
\n
'
+
'
ps{1}->dt = dt;
\n
'
+
'
ps{1}->iteration = iteration;
\n
'
+
'
ps{1}->iteration = iteration;
\n
'
+
update_field
+
update_field
+
'
ps{1}->read(
&
data_file);
\n
'
).
format
(
self
.
C_dtype
,
self
.
particle_species
)
'
ps{1}->read(data_file);
\n
'
).
format
(
self
.
C_dtype
,
self
.
particle_species
)
self
.
particle_loop
+=
((
update_field
+
self
.
particle_loop
+=
((
update_field
+
'
ps{0}->step();
\n
'
+
'
ps{0}->step();
\n
'
+
'
if (ps{0}->iteration % niter_part == 0)
\n
'
+
'
if (ps{0}->iteration % niter_part == 0)
\n
'
+
'
ps{0}->write(
&
data_file, false);
\n
'
).
format
(
self
.
particle_species
)
+
'
ps{0}->write(data_file, false);
\n
'
).
format
(
self
.
particle_species
)
+
output_vel_acc
)
output_vel_acc
)
self
.
particle_end
+=
(
'
ps{0}->write(
&
data_file);
\n
'
+
self
.
particle_end
+=
(
'
ps{0}->write(data_file);
\n
'
+
'
delete ps{0};
\n
'
).
format
(
self
.
particle_species
)
'
delete ps{0};
\n
'
).
format
(
self
.
particle_species
)
self
.
particle_species
+=
1
self
.
particle_species
+=
1
return
None
return
None
...
...
...
...
This diff is collapsed.
Click to expand it.
bfps/base.py
+
1
−
1
View file @
268acdb9
...
@@ -63,7 +63,7 @@ class base(object):
...
@@ -63,7 +63,7 @@ class base(object):
+
'
H5::DataSpace strdspace(H5S_SCALAR);
\n
'
+
'
H5::DataSpace strdspace(H5S_SCALAR);
\n
'
+
'
std::string tempstr;
'
)
+
'
std::string tempstr;
'
)
for
i
in
range
(
len
(
key
)):
for
i
in
range
(
len
(
key
)):
src_txt
+=
'
dset = data_file
.
openDataSet(
"
parameters/{0}
"
);
\n
'
.
format
(
key
[
i
])
src_txt
+=
'
dset = data_file
->
openDataSet(
"
parameters/{0}
"
);
\n
'
.
format
(
key
[
i
])
if
type
(
self
.
parameters
[
key
[
i
]])
==
int
:
if
type
(
self
.
parameters
[
key
[
i
]])
==
int
:
src_txt
+=
'
dset.read(&{0}, H5::PredType::NATIVE_INT);
\n
'
.
format
(
key
[
i
])
src_txt
+=
'
dset.read(&{0}, H5::PredType::NATIVE_INT);
\n
'
.
format
(
key
[
i
])
elif
type
(
self
.
parameters
[
key
[
i
]])
==
str
:
elif
type
(
self
.
parameters
[
key
[
i
]])
==
str
:
...
...
...
...
This diff is collapsed.
Click to expand it.
bfps/code.py
+
7
−
8
View file @
268acdb9
...
@@ -52,7 +52,7 @@ class code(base):
...
@@ -52,7 +52,7 @@ class code(base):
self
.
variables
=
'
int myrank, nprocs;
\n
'
self
.
variables
=
'
int myrank, nprocs;
\n
'
self
.
variables
+=
'
int iteration;
\n
'
self
.
variables
+=
'
int iteration;
\n
'
self
.
variables
+=
'
char simname[256];
\n
'
self
.
variables
+=
'
char simname[256];
\n
'
self
.
variables
+=
(
'
H5::H5File data_file;
\n
'
+
self
.
variables
+=
(
'
H5::H5File
*
data_file;
\n
'
+
'
H5::DataSet H5dset;
\n
'
)
'
H5::DataSet H5dset;
\n
'
)
self
.
definitions
=
''
self
.
definitions
=
''
self
.
main_start
=
"""
self
.
main_start
=
"""
...
@@ -71,17 +71,17 @@ class code(base):
...
@@ -71,17 +71,17 @@ class code(base):
else
else
{
{
strcpy(simname, argv[1]);
strcpy(simname, argv[1]);
if (myrank
=
= 0)
if (myrank
!
= 0)
data_file
.open
File(std::string(simname) + std::string(
"
.h5
"
), H5F_ACC_RD
WR
);
data_file
= new H5::H5
File(std::string(simname) + std::string(
"
.h5
"
), H5F_ACC_RD
ONLY
);
else
else
data_file
.open
File(std::string(simname) + std::string(
"
.h5
"
), H5F_ACC_RD
ONLY
);
data_file
= new H5::H5
File(std::string(simname) + std::string(
"
.h5
"
), H5F_ACC_RD
WR
);
H5dset = data_file
.
openDataSet(
"
iteration
"
);
H5dset = data_file
->
openDataSet(
"
iteration
"
);
H5dset.read(&iteration, H5::PredType::NATIVE_INT);
H5dset.read(&iteration, H5::PredType::NATIVE_INT);
DEBUG_MSG(
"
simname is %s and iteration is %d
\\
n
"
, simname, iteration);
DEBUG_MSG(
"
simname is %s and iteration is %d
\\
n
"
, simname, iteration);
}
}
read_parameters();
read_parameters();
if (myrank != 0)
if (myrank != 0)
data_file
.close()
;
delete
data_file;
//endcpp
//endcpp
"""
"""
for
ostream
in
[
'
cout
'
,
'
cerr
'
]:
for
ostream
in
[
'
cout
'
,
'
cerr
'
]:
...
@@ -91,9 +91,8 @@ class code(base):
...
@@ -91,9 +91,8 @@ class code(base):
// clean up
// clean up
if (myrank == 0)
if (myrank == 0)
{
{
H5dset = data_file
.
openDataSet(
"
iteration
"
);
H5dset = data_file
->
openDataSet(
"
iteration
"
);
H5dset.write(&iteration, H5::PredType::NATIVE_INT);
H5dset.write(&iteration, H5::PredType::NATIVE_INT);
data_file.close();
}
}
fftwf_mpi_cleanup();
fftwf_mpi_cleanup();
fftw_mpi_cleanup();
fftw_mpi_cleanup();
...
...
...
...
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
sign in
to comment