ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
types_conversion.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2020-2026 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo 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
* ESPResSo 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
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
20
#pragma once
21
22
#include <core/DataTypes.h>
23
#include <core/cell/Cell.h>
24
#include <core/math/Matrix3.h>
25
#include <core/math/Vector3.h>
26
27
#include <
utils/Vector.hpp
>
28
29
#include <type_traits>
30
31
namespace
walberla
{
32
33
template
<
typename
T,
typename
U = T>
inline
U
es2walberla
(T
const
&v) {
34
static_assert
(std::is_arithmetic_v<T> and std::is_arithmetic_v<U>,
35
"a partial specialization of es2walberla is missing for the "
36
"type you are trying to convert"
);
37
return
numeric_cast<U>(v);
38
}
39
template
<>
inline
Vector3<float>
es2walberla
(
Utils::Vector3d
const
&v) {
40
return
Vector3<float>{numeric_cast<float>(v[0]), numeric_cast<float>(v[1]),
41
numeric_cast<float>(v[2])};
42
}
43
template
<>
inline
Vector3<double>
es2walberla
(
Utils::Vector3d
const
&v) {
44
return
Vector3<double>{v[0], v[1], v[2]};
45
}
46
47
template
<
typename
T>
auto
to_vector3d
(Vector3<T>
const
&v)
noexcept
{
48
return
Utils::Vector3d
{Utils::detail::carray_alias<double, 3u>{
49
double_c(v[0]), double_c(v[1]), double_c(v[2])}};
50
}
51
52
inline
Utils::Vector3i
to_vector3i
(Vector3<int>
const
&v)
noexcept
{
53
return
Utils::Vector3i
{
54
Utils::detail::carray_alias<int, 3u>{v[0], v[1], v[2]}};
55
}
56
57
inline
Utils::Vector3i
to_vector3i
(
Cell
const
&v)
noexcept
{
58
return
Utils::Vector3i
{
59
Utils::detail::carray_alias<int, 3u>{v.x(), v.y(), v.z()}};
60
}
61
62
template
<
typename
T>
auto
to_vector3
(
Utils::Vector3d
const
&v)
noexcept
{
63
return
Vector3<T>{numeric_cast<T>(v[0]), numeric_cast<T>(v[1]),
64
numeric_cast<T>(v[2])};
65
}
66
67
template
<
typename
T>
auto
to_vector9d
(Matrix3<T>
const
&m)
noexcept
{
68
return
Utils::VectorXd<9>
{Utils::detail::carray_alias<double, 9u>{
69
double_c(m[0]), double_c(m[1]), double_c(m[2]), double_c(m[3]),
70
double_c(m[4]), double_c(m[5]), double_c(m[6]), double_c(m[7]),
71
double_c(m[8])}};
72
}
73
74
}
// namespace walberla
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
Cell
Definition
Cell.hpp:96
Utils::Vector
Definition
Vector.hpp:50
walberla
\file PackInfoPdfDoublePrecision.cpp \author pystencils
Definition
EKWalberla.hpp:38
walberla::to_vector3d
auto to_vector3d(Vector3< T > const &v) noexcept
Definition
types_conversion.hpp:47
walberla::to_vector3
auto to_vector3(Utils::Vector3d const &v) noexcept
Definition
types_conversion.hpp:62
walberla::to_vector3i
Utils::Vector3i to_vector3i(Vector3< int > const &v) noexcept
Definition
types_conversion.hpp:52
walberla::to_vector9d
auto to_vector9d(Matrix3< T > const &m) noexcept
Definition
types_conversion.hpp:67
walberla::es2walberla
U es2walberla(T const &v)
Definition
types_conversion.hpp:33
src
walberla_bridge
src
utils
types_conversion.hpp
Generated on Fri Mar 6 2026 02:34:39 for ESPResSo by
1.9.8