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 cm = element.transport_map(ref) * cm * element.transport_map(ref).transpose();
76 }
77 };
78
96 template <typename T_Element>
97 struct LinearTransport<T_Element, false>
98 {
99 static constexpr bool has_linear_transport = false;
100
105 Map6x6
106 transport_map ([[maybe_unused]] RefPart const & AMREX_RESTRICT refpart) const
107 {
108 throw std::runtime_error(
109 std::string(T_Element::type)
110 + ": Linear transport map is not yet implemented for this element."
111 );
112 }
113
119 void
122 RefPart const & AMREX_RESTRICT ref
123 ) const
124 {
125 static_assert(
126 std::is_base_of_v<LinearTransport, T_Element>,
127 "LinearTransport can only be used as a mixin class!"
128 );
129
130 T_Element const & element = *static_cast<T_Element const*>(this);
131 cm = element.transport_map(ref) * cm * element.transport_map(ref).transpose();
132 }
133 };
134
135} // namespace impactx::elements::mixin
136
137#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:106
static constexpr bool has_linear_transport
Definition lineartransport.H:99
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