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-2023 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/math/Matrix3.h>
24
#include <core/math/Vector3.h>
25
26
#include <
utils/Vector.hpp
>
27
#include <
utils/interpolation/bspline_3d.hpp
>
28
29
namespace
walberla
{
30
31
template
<
typename
T,
typename
U = T>
inline
U
es2walberla
(T v) {
32
return
numeric_cast<U>(v);
33
}
34
template
<>
inline
Vector3<float>
es2walberla
(
Utils::Vector3d
const
v) {
35
return
Vector3<float>{numeric_cast<float>(v[0]), numeric_cast<float>(v[1]),
36
numeric_cast<float>(v[2])};
37
}
38
template
<>
inline
Vector3<double>
es2walberla
(
Utils::Vector3d
const
v) {
39
return
Vector3<double>{v[0], v[1], v[2]};
40
}
41
42
template
<
typename
T>
inline
T
walberla2es
(T v) {
return
v; }
43
inline
Utils::Vector3d
walberla2es
(Vector3<float>
const
v) {
44
return
Utils::Vector3d
{double_c(v[0]), double_c(v[1]), double_c(v[2])};
45
}
46
inline
Utils::Vector3d
walberla2es
(Vector3<double>
const
v) {
47
return
Utils::Vector3d
{v[0], v[1], v[2]};
48
}
49
50
// Vector conversion helpers
51
inline
Utils::Vector3d
to_vector3d
(Vector3<float>
const
&v) {
52
return
{double_c(v[0]), double_c(v[1]), double_c(v[2])};
53
}
54
inline
Utils::Vector3d
to_vector3d
(Vector3<double>
const
&v) {
55
return
{v[0], v[1], v[2]};
56
}
57
template
<
typename
FloatType>
58
inline
Vector3<FloatType>
to_vector3
(
Utils::Vector3d
const
&v) {
59
return
Vector3<FloatType>{numeric_cast<FloatType>(v[0]),
60
numeric_cast<FloatType>(v[1]),
61
numeric_cast<FloatType>(v[2])};
62
}
63
inline
Utils::VectorXd<9>
to_vector9d
(Matrix3<double>
const
&m) {
64
return
{m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8]};
65
}
66
inline
Utils::VectorXd<9>
to_vector9d
(Matrix3<float>
const
&m) {
67
return
{double_c(m[0]), double_c(m[1]), double_c(m[2]),
68
double_c(m[3]), double_c(m[4]), double_c(m[5]),
69
double_c(m[6]), double_c(m[7]), double_c(m[8])};
70
}
71
72
template
<
typename
Function>
73
void
interpolate_bspline_at_pos
(
Utils::Vector3d
const
&pos, Function
const
&f) {
74
Utils::Interpolation::bspline_3d<2>(
75
pos, f,
Utils::Vector3d::broadcast
(1.),
// grid spacing
76
Utils::Vector3d::broadcast
(.5));
// offset
77
}
78
79
}
// namespace walberla
Vector.hpp
Vector implementation and trait types for boost qvm interoperability.
bspline_3d.hpp
Utils::Vector
Definition
Vector.hpp:48
Utils::Vector::broadcast
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value)
Create a vector that has all entries set to the same value.
Definition
Vector.hpp:110
walberla
\file PackInfoPdfDoublePrecision.cpp \author pystencils
Definition
EKWalberla.hpp:36
walberla::walberla2es
T walberla2es(T v)
Definition
types_conversion.hpp:42
walberla::es2walberla
U es2walberla(T v)
Definition
types_conversion.hpp:31
walberla::interpolate_bspline_at_pos
void interpolate_bspline_at_pos(Utils::Vector3d const &pos, Function const &f)
Definition
types_conversion.hpp:73
walberla::to_vector3
Vector3< FloatType > to_vector3(Utils::Vector3d const &v)
Definition
types_conversion.hpp:58
walberla::to_vector9d
Utils::VectorXd< 9 > to_vector9d(Matrix3< double > const &m)
Definition
types_conversion.hpp:63
walberla::to_vector3d
Utils::Vector3d to_vector3d(Vector3< float > const &v)
Definition
types_conversion.hpp:51
src
walberla_bridge
src
utils
types_conversion.hpp
Generated on Fri Nov 22 2024 02:13:56 for ESPResSo by
1.9.8