Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
serialize.hpp
Go to the documentation of this file.
1
// ----------------------------------------------------------------------
2
//
3
// Copyright (C) 2024 - 2025 by the Vulpes authors.
4
// This file is part of Vulpes.
5
//
6
// Vulpes is free software; you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// Vulpes is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
// General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18
//
19
// ----------------------------------------------------------------------
20
21
// Author: Matteo Caldana <matteo.caldana@polimi.it>
22
23
#ifndef VULPES_UTILS_SERIALIZE_HPP_
24
#define VULPES_UTILS_SERIALIZE_HPP_
25
26
#include <utility>
27
#include <vector>
28
29
#include <Eigen/Dense>
30
31
#include <boost/unordered/unordered_flat_map.hpp>
32
33
namespace
boost
{
34
namespace
serialization
{
38
template
<
class
Archive,
typename
Scalar,
int
Size>
39
void
serialize
(
40
Archive& ar, Eigen::Matrix<Scalar, Size, 1>& vec,
const
unsigned
int
) {
41
for
(
int
i = 0; i < Size; ++i) {
42
ar& vec[i];
43
}
44
}
45
49
template
<
class
Archive,
typename
Key,
typename
Value>
50
void
serialize
(
51
Archive& ar,
52
boost::unordered_flat_map<Key, Value>& map,
53
const
unsigned
int
) {
54
std::vector<std::pair<Key, Value>> vec;
55
56
if
(Archive::is_saving::value) {
57
vec.insert(vec.end(), map.begin(), map.end());
58
}
59
60
ar & vec;
61
62
if
(Archive::is_loading::value) {
63
map.clear();
64
for
(
const
auto
& pair : vec) {
65
map.insert(pair);
66
}
67
}
68
}
69
}
// namespace serialization
70
}
// namespace boost
71
72
#endif
// VULPES_UTILS_SERIALIZE_HPP_
boost::serialization
Definition
serialize.hpp:34
boost::serialization::serialize
void serialize(Archive &ar, Eigen::Matrix< Scalar, Size, 1 > &vec, const unsigned int)
Serialize with boost an Eigen Vector of static size.
Definition
serialize.hpp:39
boost
Definition
serialize.hpp:33
vulpes
utils
serialize.hpp
Generated on
for Vulpes by
1.15.0