ImpactX
Toggle main menu visibility
Loading...
Searching...
No Matches
src
elements
mixin
lineartransport.H
Go to the documentation of this file.
1
/* Copyright 2022-2026 The Regents of the University of California, through Lawrence
2
* Berkeley National Laboratory (subject to receipt of any required
3
* approvals from the U.S. Dept. of Energy). All rights reserved.
4
*
5
* This file is part of ImpactX.
6
*
7
* Authors: Axel Huebl
8
* License: BSD-3-Clause-LBNL
9
*/
10
#ifndef IMPACTX_ELEMENTS_MIXIN_LINEAR_TRANSPORT_H
11
#define IMPACTX_ELEMENTS_MIXIN_LINEAR_TRANSPORT_H
12
13
#include "
particles/CovarianceMatrix.H
"
14
15
#include <
ablastr/constant.H
>
16
17
#include <
AMReX_Math.H
>
18
#include <
AMReX_Extension.H
>
19
#include <
AMReX_REAL.H
>
20
#include <
AMReX_SmallMatrix.H
>
21
22
#include <stdexcept>
23
#include <string>
24
#include <type_traits>
25
26
27
namespace
impactx::elements::mixin
28
{
48
template
<
typename
T_Element,
bool
Implemented = true>
49
struct
LinearTransport
50
{
51
static
constexpr
bool
has_linear_transport
= Implemented;
52
60
AMREX_GPU_HOST
AMREX_FORCE_INLINE
61
void
62
operator()
(
63
Map6x6
&
AMREX_RESTRICT
cm,
64
RefPart
const
&
AMREX_RESTRICT
ref
65
)
const
66
{
67
static_assert
(
68
std::is_base_of_v<LinearTransport, T_Element>,
69
"LinearTransport can only be used as a mixin class!"
70
);
71
72
// small trick to force every derived class has to implement a method transport_map
73
// (w/o using a purely virtual function)
74
T_Element
const
& element = *
static_cast<
T_Element const*
>
(
this
);
75
auto
const
R = element.transport_map(ref);
76
cm = R * cm * R.transpose();
77
}
78
};
79
97
template
<
typename
T_Element>
98
struct
LinearTransport
<T_Element, false>
99
{
100
static
constexpr
bool
has_linear_transport
=
false
;
101
105
AMREX_GPU_HOST
AMREX_FORCE_INLINE
106
Map6x6
107
transport_map
([[maybe_unused]]
RefPart
const
&
AMREX_RESTRICT
refpart)
const
108
{
109
throw
std::runtime_error(
110
std::string(T_Element::type)
111
+
": Linear transport map is not yet implemented for this element."
112
);
113
}
114
119
AMREX_GPU_HOST
AMREX_FORCE_INLINE
120
void
121
operator()
(
122
Map6x6
&
AMREX_RESTRICT
cm,
123
RefPart
const
&
AMREX_RESTRICT
ref
124
)
const
125
{
126
static_assert
(
127
std::is_base_of_v<LinearTransport, T_Element>,
128
"LinearTransport can only be used as a mixin class!"
129
);
130
131
T_Element
const
& element = *
static_cast<
T_Element const*
>
(
this
);
132
cm = element.transport_map(ref) * cm * element.transport_map(ref).transpose();
133
}
134
};
135
136
}
// namespace impactx::elements::mixin
137
138
#endif
// IMPACTX_ELEMENTS_MIXIN_LINEAR_TRANSPORT_H
AMReX_Extension.H
AMREX_FORCE_INLINE
#define AMREX_FORCE_INLINE
AMREX_RESTRICT
#define AMREX_RESTRICT
AMREX_GPU_HOST
#define AMREX_GPU_HOST
AMReX_Math.H
AMReX_REAL.H
AMReX_SmallMatrix.H
CovarianceMatrix.H
constant.H
impactx::elements::mixin
Definition
alignment.H:25
impactx::Map6x6
amrex::SmallMatrix< amrex::ParticleReal, 6, 6, amrex::Order::F, 1 > Map6x6
Definition
CovarianceMatrix.H:20
impactx::RefPart
Definition
ReferenceParticle.H:33
impactx::elements::mixin::LinearTransport< T_Element, false >::transport_map
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition
lineartransport.H:107
impactx::elements::mixin::LinearTransport< T_Element, false >::has_linear_transport
static constexpr bool has_linear_transport
Definition
lineartransport.H:100
impactx::elements::mixin::LinearTransport
Definition
lineartransport.H:50
impactx::elements::mixin::LinearTransport::has_linear_transport
static constexpr bool has_linear_transport
Definition
lineartransport.H:51
impactx::elements::mixin::LinearTransport::operator()
AMREX_GPU_HOST AMREX_FORCE_INLINE void operator()(Map6x6 &AMREX_RESTRICT cm, RefPart const &AMREX_RESTRICT ref) const
Definition
lineartransport.H:62
Generated by
1.17.0