Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pugs
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
code
pugs
Commits
ec23407c
Commit
ec23407c
authored
Jul 10, 2024
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for IZoneDescriptor checkpointing
parent
6c24f6f5
No related branches found
No related tags found
1 merge request
!199
Integrate checkpointing
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/CMakeLists.txt
+1
-0
1 addition, 0 deletions
tests/CMakeLists.txt
tests/test_checkpointing_IZoneDescriptor.cpp
+88
-0
88 additions, 0 deletions
tests/test_checkpointing_IZoneDescriptor.cpp
with
89 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
ec23407c
...
@@ -163,6 +163,7 @@ if(PUGS_HAS_HDF5)
...
@@ -163,6 +163,7 @@ if(PUGS_HAS_HDF5)
test_checkpointing_HFTypes.cpp
test_checkpointing_HFTypes.cpp
test_checkpointing_IBoundaryDescriptor.cpp
test_checkpointing_IBoundaryDescriptor.cpp
test_checkpointing_IInterfaceDescriptor.cpp
test_checkpointing_IInterfaceDescriptor.cpp
test_checkpointing_IZoneDescriptor.cpp
)
)
endif
(
PUGS_HAS_HDF5
)
endif
(
PUGS_HAS_HDF5
)
...
...
This diff is collapsed.
Click to expand it.
tests/test_checkpointing_IZoneDescriptor.cpp
0 → 100644
+
88
−
0
View file @
ec23407c
#include
<catch2/catch_test_macros.hpp>
#include
<catch2/matchers/catch_matchers_all.hpp>
#include
<utils/Messenger.hpp>
#include
<language/utils/DataHandler.hpp>
#include
<language/utils/EmbeddedData.hpp>
#include
<mesh/NamedZoneDescriptor.hpp>
#include
<mesh/NumberedZoneDescriptor.hpp>
#include
<utils/checkpointing/ReadIZoneDescriptor.hpp>
#include
<utils/checkpointing/WriteIZoneDescriptor.hpp>
#include
<filesystem>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"checkpointing_IZoneDescriptor"
,
"[utils/checkpointing]"
)
{
std
::
string
tmp_dirname
;
{
{
if
(
parallel
::
rank
()
==
0
)
{
tmp_dirname
=
[
&
]()
->
std
::
string
{
std
::
string
temp_filename
=
std
::
filesystem
::
temp_directory_path
()
/
"pugs_checkpointing_XXXXXX"
;
return
std
::
string
{
mkdtemp
(
&
temp_filename
[
0
])};
}();
}
parallel
::
broadcast
(
tmp_dirname
,
0
);
}
std
::
filesystem
::
path
path
=
tmp_dirname
;
const
std
::
string
filename
=
path
/
"checkpoint.h5"
;
HighFive
::
FileAccessProps
fapl
;
fapl
.
add
(
HighFive
::
MPIOFileAccess
{
MPI_COMM_WORLD
,
MPI_INFO_NULL
});
fapl
.
add
(
HighFive
::
MPIOCollectiveMetadata
{});
HighFive
::
File
file
=
HighFive
::
File
(
filename
,
HighFive
::
File
::
Truncate
,
fapl
);
SECTION
(
"IZoneDescriptor"
)
{
HighFive
::
Group
symbol_table_group
=
file
.
createGroup
(
"symbol_table"
);
HighFive
::
Group
useless_group
;
auto
p_named_zone_descriptor
=
std
::
make_shared
<
const
NamedZoneDescriptor
>
(
"zone_name1"
);
checkpointing
::
writeIZoneDescriptor
(
"named_zone_descriptor"
,
EmbeddedData
{
std
::
make_shared
<
DataHandler
<
const
IZoneDescriptor
>>
(
p_named_zone_descriptor
)},
file
,
useless_group
,
symbol_table_group
);
auto
p_numbered_zone_descriptor
=
std
::
make_shared
<
const
NumberedZoneDescriptor
>
(
3
);
checkpointing
::
writeIZoneDescriptor
(
"numbered_zone_descriptor"
,
EmbeddedData
{
std
::
make_shared
<
DataHandler
<
const
IZoneDescriptor
>>
(
p_numbered_zone_descriptor
)},
file
,
useless_group
,
symbol_table_group
);
file
.
flush
();
EmbeddedData
read_named_zone_descriptor
=
checkpointing
::
readIZoneDescriptor
(
"named_zone_descriptor"
,
symbol_table_group
);
EmbeddedData
read_numbered_zone_descriptor
=
checkpointing
::
readIZoneDescriptor
(
"numbered_zone_descriptor"
,
symbol_table_group
);
auto
get_value
=
[](
const
EmbeddedData
&
embedded_data
)
->
const
IZoneDescriptor
&
{
return
*
dynamic_cast
<
const
DataHandler
<
const
IZoneDescriptor
>&>
(
embedded_data
.
get
()).
data_ptr
();
};
REQUIRE_NOTHROW
(
get_value
(
read_named_zone_descriptor
));
REQUIRE_NOTHROW
(
get_value
(
read_numbered_zone_descriptor
));
REQUIRE
(
get_value
(
read_named_zone_descriptor
).
type
()
==
IZoneDescriptor
::
Type
::
named
);
REQUIRE
(
get_value
(
read_numbered_zone_descriptor
).
type
()
==
IZoneDescriptor
::
Type
::
numbered
);
REQUIRE_NOTHROW
(
dynamic_cast
<
const
NamedZoneDescriptor
&>
(
get_value
(
read_named_zone_descriptor
)));
REQUIRE_NOTHROW
(
dynamic_cast
<
const
NumberedZoneDescriptor
&>
(
get_value
(
read_numbered_zone_descriptor
)));
auto
&
read_named
=
dynamic_cast
<
const
NamedZoneDescriptor
&>
(
get_value
(
read_named_zone_descriptor
));
auto
&
read_numbered
=
dynamic_cast
<
const
NumberedZoneDescriptor
&>
(
get_value
(
read_numbered_zone_descriptor
));
REQUIRE
(
read_named
.
name
()
==
p_named_zone_descriptor
->
name
());
REQUIRE
(
read_numbered
.
number
()
==
p_numbered_zone_descriptor
->
number
());
}
}
parallel
::
barrier
();
if
(
parallel
::
rank
()
==
0
)
{
std
::
filesystem
::
remove_all
(
std
::
filesystem
::
path
{
tmp_dirname
});
}
}
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