ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
h5md_specification.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2010-2025 The ESPResSo project
3
* Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009,2010
4
* Max-Planck-Institute for Polymer Research, Theory Group
5
*
6
* This file is part of ESPResSo.
7
*
8
* ESPResSo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
11
* (at your option) any later version.
12
*
13
* ESPResSo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*
18
* You should have received a copy of the GNU General Public License
19
* along with this program. If not, see <http://www.gnu.org/licenses/>.
20
*/
21
22
#include "
hdf5_patches.hpp
"
// must appear first
23
24
#include "
h5md_core.hpp
"
25
#include "
h5md_dataset.hpp
"
26
#include "
h5md_specification.hpp
"
27
28
#include <highfive/highfive.hpp>
29
30
#include <hdf5.h>
31
32
#include <algorithm>
33
#include <filesystem>
34
#include <string>
35
#include <utility>
36
37
namespace
Writer
{
38
namespace
H5md {
39
40
Specification::Specification
(
unsigned
int
fields) {
41
auto
const
add_time_series
= [
this
](
Dataset
&&
dataset
,
bool
link
=
true
) {
42
auto
const
group =
dataset
.group;
43
m_datasets.push_back(std::move(
dataset
));
44
m_datasets.push_back({group,
"step"
, 1,
H5T_NATIVE_INT
, 1,
link
});
45
m_datasets.push_back({group,
"time"
, 1,
H5T_NATIVE_DOUBLE
, 1,
link
});
46
};
47
48
if
(fields &
H5MD_OUT_BOX_L
) {
49
add_time_series
({
"/particles/atoms/box/edges"
,
"value"
, 2,
50
H5T_NATIVE_DOUBLE
, 3,
false
});
51
}
52
if
(fields &
H5MD_OUT_LE_OFF
) {
53
add_time_series
({
"/particles/atoms/lees_edwards/offset"
,
"value"
, 2,
54
H5T_NATIVE_DOUBLE
, 1,
false
});
55
}
56
if
(fields &
H5MD_OUT_LE_DIR
) {
57
add_time_series
({
"/particles/atoms/lees_edwards/direction"
,
"value"
, 2,
58
H5T_NATIVE_INT
, 1,
false
});
59
}
60
if
(fields &
H5MD_OUT_LE_NORMAL
) {
61
add_time_series
({
"/particles/atoms/lees_edwards/normal"
,
"value"
, 2,
62
H5T_NATIVE_INT
, 1,
false
});
63
}
64
if
(fields &
H5MD_OUT_MASS
) {
65
add_time_series
(
66
{
"/particles/atoms/mass"
,
"value"
, 2,
H5T_NATIVE_DOUBLE
, 1,
false
});
67
}
68
if
(fields &
H5MD_OUT_CHARGE
) {
69
add_time_series
(
70
{
"/particles/atoms/charge"
,
"value"
, 2,
H5T_NATIVE_DOUBLE
, 1,
false
});
71
}
72
add_time_series
({
"/particles/atoms/id"
,
"value"
, 2,
H5T_NATIVE_INT
, 1,
false
},
73
false
);
74
if
(fields &
H5MD_OUT_TYPE
) {
75
add_time_series
(
76
{
"/particles/atoms/species"
,
"value"
, 2,
H5T_NATIVE_INT
, 1,
false
});
77
}
78
if
(fields &
H5MD_OUT_POS
) {
79
add_time_series
(
80
{
"/particles/atoms/position"
,
"value"
, 3,
H5T_NATIVE_DOUBLE
, 3,
false
});
81
}
82
if
(fields &
H5MD_OUT_VEL
) {
83
add_time_series
(
84
{
"/particles/atoms/velocity"
,
"value"
, 3,
H5T_NATIVE_DOUBLE
, 3,
false
});
85
}
86
if
(fields &
H5MD_OUT_FORCE
) {
87
add_time_series
(
88
{
"/particles/atoms/force"
,
"value"
, 3,
H5T_NATIVE_DOUBLE
, 3,
false
});
89
}
90
if
(fields &
H5MD_OUT_IMG
) {
91
add_time_series
(
92
{
"/particles/atoms/image"
,
"value"
, 3,
H5T_NATIVE_INT
, 3,
false
});
93
}
94
if
(fields &
H5MD_OUT_BONDS
) {
95
add_time_series
(
96
{
"/connectivity/atoms"
,
"value"
, 3,
H5T_NATIVE_INT
, 2,
false
});
97
}
98
}
99
100
bool
Specification::is_compliant
(std::filesystem::path
const
&file)
const
{
101
HighFive::File
h5md_file
(file.string(), HighFive::File::ReadOnly);
102
103
auto
const
all_groups_exist
=
104
std::ranges::all_of(m_datasets, [&
h5md_file
](
auto
const
&d) {
105
return
h5md_file
.exist(d.group);
106
});
107
auto
const
all_datasets_exist
=
108
std::ranges::all_of(m_datasets, [&
h5md_file
](
auto
const
&d) {
109
return
h5md_file
.exist(d.path());
110
});
111
return
all_groups_exist
and
all_datasets_exist
;
112
}
113
114
}
// namespace H5md
115
}
// namespace Writer
stream
cudaStream_t stream[1]
CUDA streams for parallel computing on CPU and GPU.
Definition
common_cuda.cu:34
h5md_core.hpp
h5md_dataset.hpp
h5md_specification.hpp
hdf5_patches.hpp
Writer::H5md::H5MD_OUT_LE_DIR
@ H5MD_OUT_LE_DIR
Definition
h5md_core.hpp:67
Writer::H5md::H5MD_OUT_FORCE
@ H5MD_OUT_FORCE
Definition
h5md_core.hpp:61
Writer::H5md::H5MD_OUT_BONDS
@ H5MD_OUT_BONDS
Definition
h5md_core.hpp:64
Writer::H5md::H5MD_OUT_LE_OFF
@ H5MD_OUT_LE_OFF
Definition
h5md_core.hpp:66
Writer::H5md::H5MD_OUT_BOX_L
@ H5MD_OUT_BOX_L
Definition
h5md_core.hpp:65
Writer::H5md::H5MD_OUT_TYPE
@ H5MD_OUT_TYPE
Definition
h5md_core.hpp:57
Writer::H5md::H5MD_OUT_POS
@ H5MD_OUT_POS
Definition
h5md_core.hpp:58
Writer::H5md::H5MD_OUT_MASS
@ H5MD_OUT_MASS
Definition
h5md_core.hpp:62
Writer::H5md::H5MD_OUT_CHARGE
@ H5MD_OUT_CHARGE
Definition
h5md_core.hpp:63
Writer::H5md::H5MD_OUT_IMG
@ H5MD_OUT_IMG
Definition
h5md_core.hpp:59
Writer::H5md::H5MD_OUT_VEL
@ H5MD_OUT_VEL
Definition
h5md_core.hpp:60
Writer::H5md::H5MD_OUT_LE_NORMAL
@ H5MD_OUT_LE_NORMAL
Definition
h5md_core.hpp:68
Writer
Definition
h5md_core.cpp:58
Writer::H5md::Dataset
Definition
h5md_dataset.hpp:33
Writer::H5md::Specification::Specification
Specification(unsigned int fields)
Definition
h5md_specification.cpp:40
Writer::H5md::Specification::is_compliant
bool is_compliant(std::filesystem::path const &file) const
Definition
h5md_specification.cpp:100
src
core
io
writer
h5md_specification.cpp
Generated on Tue Dec 9 2025 02:28:52 for ESPResSo by
1.9.8