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
80a1606f
Commit
80a1606f
authored
11 months ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
Add tests for ItemArray checkpointing
parent
0c880621
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_ItemArray.cpp
+82
-0
82 additions, 0 deletions
tests/test_checkpointing_ItemArray.cpp
with
83 additions
and
0 deletions
tests/CMakeLists.txt
+
1
−
0
View file @
80a1606f
...
...
@@ -162,6 +162,7 @@ if(PUGS_HAS_HDF5)
list
(
APPEND checkpointing_TESTS
test_checkpointing_Array.cpp
test_checkpointing_HFTypes.cpp
test_checkpointing_ItemArray.cpp
test_checkpointing_ItemValue.cpp
test_checkpointing_OStream.cpp
test_checkpointing_IBoundaryDescriptor.cpp
...
...
This diff is collapsed.
Click to expand it.
tests/test_checkpointing_ItemArray.cpp
0 → 100644
+
82
−
0
View file @
80a1606f
#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/Mesh.hpp>
#include
<mesh/MeshVariant.hpp>
#include
<utils/checkpointing/ReadItemArray.hpp>
#include
<utils/checkpointing/WriteItemArray.hpp>
#include
<MeshDataBaseForTests.hpp>
#include
<filesystem>
// clazy:excludeall=non-pod-global-static
TEST_CASE
(
"checkpointing_ItemArray"
,
"[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
(
"ItemArray"
)
{
HighFive
::
Group
checkpoint_group
=
file
.
createGroup
(
"checkpoint_group"
);
HighFive
::
Group
useless_group
;
auto
mesh_2d
=
MeshDataBaseForTests
::
get
().
hybrid2DMesh
()
->
get
<
Mesh
<
2
>>
();
CellArray
<
double
>
item_array
{
mesh_2d
->
connectivity
(),
3
};
item_array
.
fill
(
0
);
for
(
CellId
cell_id
=
0
;
cell_id
<
mesh_2d
->
numberOfCells
();
++
cell_id
)
{
for
(
size_t
i
=
0
;
i
<
3
;
++
i
)
{
item_array
[
cell_id
][
i
]
=
(
1.
*
std
::
rand
())
/
(
1.
/
3
*
RAND_MAX
);
}
}
checkpointing
::
write
(
checkpoint_group
,
"item_array"
,
item_array
);
file
.
flush
();
auto
is_same
=
[](
const
auto
&
a
,
const
auto
&
b
)
{
bool
same
=
true
;
for
(
size_t
i
=
0
;
i
<
a
.
numberOfRows
();
++
i
)
{
for
(
size_t
j
=
0
;
j
<
a
.
numberOfColumns
();
++
j
)
{
if
(
a
[
i
][
j
]
!=
b
[
i
][
j
])
{
same
=
false
;
}
}
}
return
parallel
::
allReduceAnd
(
same
);
};
CellArray
<
double
>
read_item_array
=
checkpointing
::
readItemArray
<
double
,
ItemType
::
cell
>
(
checkpoint_group
,
"item_array"
,
mesh_2d
->
connectivity
());
REQUIRE
(
is_same
(
item_array
.
tableView
(),
read_item_array
.
tableView
()));
}
}
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