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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TurTLE
TurTLE
Commits
b8b0b821
Commit
b8b0b821
authored
5 years ago
by
Lukas Bentkamp
Browse files
Options
Downloads
Patches
Plain Diff
kraichnan_field checkpoint writer
parent
5b34b233
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cpp/full_code/kraichnan_field.cpp
+62
-1
62 additions, 1 deletion
cpp/full_code/kraichnan_field.cpp
cpp/full_code/kraichnan_field.hpp
+15
-0
15 additions, 0 deletions
cpp/full_code/kraichnan_field.hpp
with
77 additions
and
1 deletion
cpp/full_code/kraichnan_field.cpp
+
62
−
1
View file @
b8b0b821
...
...
@@ -121,7 +121,6 @@ int kraichnan_field<rnumber>::step(void)
this
->
spectrum_coefficient
*
3.
/
2.
);
// incompressibility projection factor
this
->
velocity
->
ift
();
// PUT THE INCOMPRESSIBILITY PROJECTION FACTOR sqrt(2/3)
DEBUG_MSG
(
"L2Norm before: %g
\n
"
,
this
->
velocity
->
L2norm
(
this
->
kk
));
this
->
kk
->
template
project_divfree
<
rnumber
>(
this
->
velocity
->
get_cdata
());
...
...
@@ -137,6 +136,7 @@ template <typename rnumber>
int
kraichnan_field
<
rnumber
>::
write_checkpoint
(
void
)
{
TIMEZONE
(
"kraichnan_file::write_checkpoint"
);
this
->
io_checkpoint
(
false
);
this
->
particles_output_writer_mpi
->
open_file
(
this
->
get_current_fname
());
this
->
particles_output_writer_mpi
->
template
save
<
3
>(
this
->
ps
->
getParticlesState
(),
...
...
@@ -145,6 +145,7 @@ int kraichnan_field<rnumber>::write_checkpoint(void)
this
->
ps
->
getLocalNbParticles
(),
this
->
iteration
);
this
->
particles_output_writer_mpi
->
close_file
();
this
->
write_iteration
();
return
EXIT_SUCCESS
;
}
...
...
@@ -238,6 +239,66 @@ int kraichnan_field<rnumber>::read_parameters(void)
return
EXIT_SUCCESS
;
}
template
<
class
rnumber
>
void
kraichnan_field
<
rnumber
>::
update_checkpoint
()
{
std
::
string
fname
=
this
->
get_current_fname
();
if
(
this
->
kk
->
layout
->
myrank
==
0
)
{
bool
file_exists
=
false
;
{
struct
stat
file_buffer
;
file_exists
=
(
stat
(
fname
.
c_str
(),
&
file_buffer
)
==
0
);
}
if
(
file_exists
)
{
// check how many fields there are in the checkpoint file
// increment checkpoint if needed
hsize_t
fields_stored
;
hid_t
fid
,
group_id
;
fid
=
H5Fopen
(
fname
.
c_str
(),
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
group_id
=
H5Gopen
(
fid
,
"velocity/real"
,
H5P_DEFAULT
);
H5Gget_num_objs
(
group_id
,
&
fields_stored
);
bool
dset_exists
=
H5Lexists
(
group_id
,
std
::
to_string
(
this
->
iteration
).
c_str
(),
H5P_DEFAULT
);
H5Gclose
(
group_id
);
H5Fclose
(
fid
);
if
((
int
(
fields_stored
)
>=
this
->
checkpoints_per_file
)
&&
!
dset_exists
)
this
->
checkpoint
++
;
}
else
{
// create file, create fields_stored dset
hid_t
fid
=
H5Fcreate
(
fname
.
c_str
(),
H5F_ACC_EXCL
,
H5P_DEFAULT
,
H5P_DEFAULT
);
hid_t
gg
=
H5Gcreate
(
fid
,
"velocity"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
hid_t
ggg
=
H5Gcreate
(
gg
,
"real"
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
H5Gclose
(
ggg
);
H5Gclose
(
gg
);
H5Fclose
(
fid
);
}
}
MPI_Bcast
(
&
this
->
checkpoint
,
1
,
MPI_INT
,
0
,
this
->
kk
->
layout
->
comm
);
}
template
class
kraichnan_field
<
float
>;
template
class
kraichnan_field
<
double
>;
This diff is collapsed.
Click to expand it.
cpp/full_code/kraichnan_field.hpp
+
15
−
0
View file @
b8b0b821
...
...
@@ -86,6 +86,21 @@ class kraichnan_field: public direct_numerical_simulation
virtual
int
read_parameters
(
void
);
int
write_checkpoint
(
void
);
int
do_stats
(
void
);
void
update_checkpoint
(
void
);
inline
void
io_checkpoint
(
bool
read
=
true
)
{
assert
(
this
->
velocity
->
real_space_representation
);
if
(
!
read
)
this
->
update_checkpoint
();
std
::
string
fname
=
this
->
get_current_fname
();
this
->
velocity
->
io
(
fname
,
"velocity"
,
this
->
iteration
,
read
);
}
};
#endif//KRAICHNAN_FIELD_HPP
...
...
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