Alamo
Advect.H
Go to the documentation of this file.
1#ifndef NUMERIC_ADVECT_ADVECT_H
2#define NUMERIC_ADVECT_ADVECT_H
3
4#include <string>
5#include <tuple>
6
7#include "AMReX_Extension.H"
8#include "IO/ParmParse.H"
9#include "Numeric/Stencil.H"
10#include "Set/Set.H"
11#include "Util/Util.H"
12
13namespace Numeric
14{
15namespace Advect
16{
17
18enum class Form
19{
22};
23
28
29
30template<typename... OBJ>
31class Advect
32{
33private:
34 friend IO::ParmParse;
35
36 std::tuple<OBJ...> obj;
37 static constexpr const char* names[] = { OBJ::name... };
38 int selected = -1;
39
40public:
41 template<int I = 0, class Phi, class Velocity>
44 Velocity const& velocity,
45 int i, int j, int k,
46 int comp,
47 const Set::Scalar* DX,
48 Options options = {},
49 std::array<Numeric::StencilType, AMREX_SPACEDIM> stencil = Numeric::DefaultType) const
50 {
51 if constexpr (I < sizeof...(OBJ))
52 {
53 if (selected == I)
54 return std::get<I>(obj)(phi, velocity, i, j, k, comp, DX, options, stencil);
55 else
56 return this->template operator()<I + 1>(phi, velocity, i, j, k, comp, DX, options, stencil);
57 }
58 else
59 {
61 return NAN;
62 }
63 }
64
65 template<int I = 0, class Phi, class Velocity>
67 Set::Scalar Scalar( Phi const& phi,
68 Velocity const& velocity,
69 int i, int j, int k,
70 int comp,
71 const Set::Scalar* DX,
72 Options options = {},
73 std::array<Numeric::StencilType, AMREX_SPACEDIM> stencil = Numeric::DefaultType) const
74 {
75 return this->template operator()<I>(phi, velocity, i, j, k, comp, DX, options, stencil);
76 }
77
78 template<class Phi, class Velocity>
80 Set::Vector Vector( Phi const& phi,
81 Velocity const& velocity,
82 int i, int j, int k,
83 int comp,
84 const Set::Scalar* DX,
85 Options options = {},
86 std::array<Numeric::StencilType, AMREX_SPACEDIM> stencil = Numeric::DefaultType) const
87 {
88 Set::Vector ret = Set::Vector::Zero();
89 for (int d = 0; d < AMREX_SPACEDIM; ++d)
90 ret(d) = (*this)(phi, velocity, i, j, k, comp + d, DX, options, stencil);
91 return ret;
92 }
93
94 template<int I = 0>
96 int NGhost() const
97 {
98 if constexpr (I < sizeof...(OBJ))
99 {
100 if (selected == I)
101 return std::get<I>(obj).NGhost();
102 else
103 return NGhost<I + 1>();
104 }
105 else
106 {
108 return 0;
109 }
110 }
111
113 bool IsDefined() const
114 {
115 return selected >= 0;
116 }
117
118 template<int I = 0>
121 {
122 if constexpr (I < sizeof...(OBJ))
123 {
124 if (selected == I)
125 return std::get<I>(obj).phi_location;
126 else
127 return PhiLocation<I + 1>();
128 }
129 else
130 {
132 return Set::HC::Cell;
133 }
134 }
135
136 template<int I = 0>
139 {
140 if constexpr (I < sizeof...(OBJ))
141 {
142 if (selected == I)
143 return std::get<I>(obj).velocity_location;
144 else
146 }
147 else
148 {
150 return Set::HC::Cell;
151 }
152 }
153};
154
155}
156}
157
158#endif
#define INFO
Definition Util.H:24
static constexpr const char * names[]
Definition Advect.H:37
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Set::Vector Vector(Phi const &phi, Velocity const &velocity, int i, int j, int k, int comp, const Set::Scalar *DX, Options options={}, std::array< Numeric::StencilType, AMREX_SPACEDIM > stencil=Numeric::DefaultType) const
Definition Advect.H:80
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE bool IsDefined() const
Definition Advect.H:113
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE int NGhost() const
Definition Advect.H:96
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Set::Scalar operator()(Phi const &phi, Velocity const &velocity, int i, int j, int k, int comp, const Set::Scalar *DX, Options options={}, std::array< Numeric::StencilType, AMREX_SPACEDIM > stencil=Numeric::DefaultType) const
Definition Advect.H:43
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Set::HC PhiLocation() const
Definition Advect.H:120
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Set::HC VelocityLocation() const
Definition Advect.H:138
AMREX_FORCE_INLINE AMREX_GPU_HOST_DEVICE Set::Scalar Scalar(Phi const &phi, Velocity const &velocity, int i, int j, int k, int comp, const Set::Scalar *DX, Options options={}, std::array< Numeric::StencilType, AMREX_SPACEDIM > stencil=Numeric::DefaultType) const
Definition Advect.H:67
std::tuple< OBJ... > obj
Definition Advect.H:36
This namespace contains some numerical tools.
Definition Advect.H:14
static std::array< StencilType, AMREX_SPACEDIM > DefaultType
Definition Stencil.H:23
amrex::Real Scalar
Definition Base.H:19
Hypercube
Definition Set.H:31
@ Cell
Definition Set.H:32
Eigen::Matrix< amrex::Real, AMREX_SPACEDIM, 1 > Vector
Definition Base.H:21
void Abort(const char *msg)
Definition Util.cpp:269