ImpactX
Loading...
Searching...
No Matches
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
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
28{
48 template <typename T_Element, bool Implemented = true>
50 {
51 static constexpr bool has_linear_transport = Implemented;
52
61 void
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
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
120 void
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
#define AMREX_FORCE_INLINE
#define AMREX_RESTRICT
#define AMREX_GPU_HOST
Definition alignment.H:23
amrex::SmallMatrix< amrex::ParticleReal, 6, 6, amrex::Order::F, 1 > Map6x6
Definition CovarianceMatrix.H:20
Definition ReferenceParticle.H:33
AMREX_GPU_HOST AMREX_FORCE_INLINE Map6x6 transport_map(RefPart const &AMREX_RESTRICT refpart) const
Definition lineartransport.H:107
static constexpr bool has_linear_transport
Definition lineartransport.H:100
Definition lineartransport.H:50
static constexpr bool has_linear_transport
Definition lineartransport.H:51
AMREX_GPU_HOST AMREX_FORCE_INLINE void operator()(Map6x6 &AMREX_RESTRICT cm, RefPart const &AMREX_RESTRICT ref) const
Definition lineartransport.H:62