Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
tobuffer.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef DUNE_FUFEM_HDF5_TOBUFFER_HH
5#define DUNE_FUFEM_HDF5_TOBUFFER_HH
6
9#include <dune/istl/matrix.hh>
10
11template <int k, typename ctype>
13 std::vector<ctype> &buffer) {
14 buffer.resize(data.N() * data.M() * k);
15 auto it = buffer.begin();
16 for (auto &&row : data)
17 for (auto &&localVector : row)
18 it = std::copy(localVector.begin(), localVector.end(), it);
19}
20
21template <int k, typename ctype>
23 std::vector<ctype> &buffer) {
24 buffer.resize(data.size() * k);
25 auto it = buffer.begin();
26 for (auto &&localVector : data)
27 it = std::copy(localVector.begin(), localVector.end(), it);
28}
29
30template <typename ctype>
32 std::vector<ctype> &buffer) {
33 buffer.resize(data.size());
34 auto it = buffer.begin();
35 for (auto &&localVector : data)
36 *(it++) = localVector[0];
37}
38
39template <typename ctype>
40void toBuffer(ctype const &data, std::vector<ctype> &buffer) {
41 buffer.resize(1);
42 buffer[0] = data;
43}
44#endif
void toBuffer(Dune::Matrix< Dune::FieldVector< ctype, k > > const &data, std::vector< ctype > &buffer)
Definition tobuffer.hh:12
T begin(T... args)
T copy(T... args)
T resize(T... args)