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
8cc14e78
Commit
8cc14e78
authored
5 years ago
by
Cristian Lalescu
Browse files
Options
Downloads
Patches
Plain Diff
adds method to write vector with particle pairs
parent
1e4ae6ca
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cpp/hdf5_tools.cpp
+38
-0
38 additions, 0 deletions
cpp/hdf5_tools.cpp
cpp/hdf5_tools.hpp
+65
-0
65 additions, 0 deletions
cpp/hdf5_tools.hpp
with
103 additions
and
0 deletions
cpp/hdf5_tools.cpp
+
38
−
0
View file @
8cc14e78
...
...
@@ -274,6 +274,44 @@ std::string hdf5_tools::read_string(
}
}
template
<
class
partsize_t
>
int
hdf5_tools
::
write_particle_ID_pairs_with_single_rank
(
const
std
::
vector
<
partsize_t
>
v
,
const
hid_t
group
,
const
std
::
string
dset_name
)
{
TIMEZONE
(
"hdf5_tools::write_particle_ID_pairs_with_single_rank"
);
// the vector contains pair information, so its size must be a multiple of 2
assert
((
v
.
size
()
%
2
)
==
0
);
// file space creation
hid_t
fspace
;
hsize_t
dims
[
2
];
dims
[
0
]
=
v
.
size
()
/
2
;
dims
[
1
]
=
2
;
fspace
=
H5Screate_simple
(
2
,
dims
,
NULL
);
// create dataset
hsize_t
dset_id
=
H5Dcreate
(
group
,
dset_name
.
c_str
(),
hdf5_tools
::
hdf5_type_id
<
partsize_t
>
(),
fspace
,
H5P_DEFAULT
,
H5P_DEFAULT
,
H5P_DEFAULT
);
// write data
H5Dwrite
(
dset_id
,
hdf5_tools
::
hdf5_type_id
<
partsize_t
>
(),
H5S_ALL
,
H5S_ALL
,
H5P_DEFAULT
,
&
v
.
front
());
// clean up
H5Dclose
(
dset_id
);
H5Sclose
(
fspace
);
return
EXIT_SUCCESS
;
}
template
std
::
vector
<
int
>
hdf5_tools
::
read_vector
<
int
>
(
const
hid_t
,
...
...
This diff is collapsed.
Click to expand it.
cpp/hdf5_tools.hpp
+
65
−
0
View file @
8cc14e78
...
...
@@ -33,6 +33,65 @@
namespace
hdf5_tools
{
// see https://support.hdfgroup.org/HDF5/doc/H5.user/Datatypes.html
template
<
typename
data_type
>
hid_t
hdf5_type_id
();
template
<
>
hid_t
hdf5_type_id
<
char
>
()
{
return
H5T_NATIVE_CHAR
;
}
template
<
>
hid_t
hdf5_type_id
<
signed
char
>
()
{
return
H5T_NATIVE_SCHAR
;
}
template
<
>
hid_t
hdf5_type_id
<
unsigned
char
>
()
{
return
H5T_NATIVE_UCHAR
;
}
template
<
>
hid_t
hdf5_type_id
<
short
>
()
{
return
H5T_NATIVE_SHORT
;
}
template
<
>
hid_t
hdf5_type_id
<
unsigned
short
>
()
{
return
H5T_NATIVE_USHORT
;
}
template
<
>
hid_t
hdf5_type_id
<
int
>
()
{
return
H5T_NATIVE_INT
;
}
template
<
>
hid_t
hdf5_type_id
<
unsigned
>
()
{
return
H5T_NATIVE_UINT
;
}
template
<
>
hid_t
hdf5_type_id
<
long
>
()
{
return
H5T_NATIVE_LONG
;
}
template
<
>
hid_t
hdf5_type_id
<
unsigned
long
>
()
{
return
H5T_NATIVE_ULONG
;
}
template
<
>
hid_t
hdf5_type_id
<
long
long
>
()
{
return
H5T_NATIVE_LLONG
;
}
template
<
>
hid_t
hdf5_type_id
<
unsigned
long
long
>
()
{
return
H5T_NATIVE_ULLONG
;
}
template
<
>
hid_t
hdf5_type_id
<
float
>
()
{
return
H5T_NATIVE_FLOAT
;
}
template
<
>
hid_t
hdf5_type_id
<
double
>
()
{
return
H5T_NATIVE_DOUBLE
;
}
template
<
>
hid_t
hdf5_type_id
<
long
double
>
()
{
return
H5T_NATIVE_LDOUBLE
;
}
int
grow_single_dataset
(
hid_t
dset
,
int
tincrement
);
...
...
@@ -90,6 +149,12 @@ namespace hdf5_tools
const
hid_t
group
,
const
std
::
string
dset_name
,
const
number
value
);
template
<
class
partsize_t
>
int
write_particle_ID_pairs_with_single_rank
(
const
std
::
vector
<
partsize_t
>
v
,
const
hid_t
group
,
const
std
::
string
dset_name
);
}
#endif//HDF5_TOOLS_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