|
6 | 6 |
|
7 | 7 | #include "arch/kokkos_aliases.h" |
8 | 8 | #include "arch/traits.h" |
| 9 | +#include "utils/numeric.h" |
9 | 10 |
|
10 | 11 | #include "archetypes/problem_generator.h" |
11 | 12 | #include "framework/domain/metadomain.h" |
12 | 13 |
|
| 14 | +#include <string> |
| 15 | + |
13 | 16 | namespace user { |
14 | 17 | using namespace ntt; |
15 | 18 |
|
| 19 | + enum class FieldGeometry { |
| 20 | + dipole, |
| 21 | + monopole |
| 22 | + }; |
| 23 | + |
16 | 24 | template <Dimension D> |
17 | 25 | struct InitFields { |
18 | | - InitFields(real_t bsurf, real_t rstar) : Bsurf { bsurf }, Rstar { rstar } {} |
| 26 | + InitFields(real_t bsurf, real_t rstar, const std::string& field_geometry) |
| 27 | + : Bsurf { bsurf } |
| 28 | + , Rstar { rstar } |
| 29 | + , field_geom { field_geometry == "monopole" ? FieldGeometry::monopole |
| 30 | + : FieldGeometry::dipole } {} |
19 | 31 |
|
20 | 32 | Inline auto bx1(const coord_t<D>& x_Ph) const -> real_t { |
21 | | - return Bsurf * math::cos(x_Ph[1]) / CUBE(x_Ph[0] / Rstar); |
| 33 | + if (field_geom == FieldGeometry::monopole) { |
| 34 | + return Bsurf / SQR(x_Ph[0] / Rstar); |
| 35 | + } else { |
| 36 | + return Bsurf * math::cos(x_Ph[1]) / CUBE(x_Ph[0] / Rstar); |
| 37 | + } |
22 | 38 | } |
23 | 39 |
|
24 | 40 | Inline auto bx2(const coord_t<D>& x_Ph) const -> real_t { |
25 | | - return Bsurf * HALF * math::sin(x_Ph[1]) / CUBE(x_Ph[0] / Rstar); |
| 41 | + if (field_geom == FieldGeometry::monopole) { |
| 42 | + return ZERO; |
| 43 | + } else { |
| 44 | + return Bsurf * HALF * math::sin(x_Ph[1]) / CUBE(x_Ph[0] / Rstar); |
| 45 | + } |
26 | 46 | } |
27 | 47 |
|
28 | 48 | private: |
29 | | - const real_t Bsurf, Rstar; |
| 49 | + const real_t Bsurf, Rstar; |
| 50 | + const FieldGeometry field_geom; |
30 | 51 | }; |
31 | 52 |
|
32 | 53 | template <Dimension D> |
33 | 54 | struct DriveFields : public InitFields<D> { |
34 | | - DriveFields(real_t time, real_t bsurf, real_t rstar, real_t omega) |
35 | | - : InitFields<D> { bsurf, rstar } |
| 55 | + DriveFields(real_t time, |
| 56 | + real_t bsurf, |
| 57 | + real_t rstar, |
| 58 | + real_t omega, |
| 59 | + const std::string& field_geometry) |
| 60 | + : InitFields<D> { bsurf, rstar, field_geometry } |
36 | 61 | , time { time } |
37 | 62 | , Omega { omega } {} |
38 | 63 |
|
@@ -73,25 +98,27 @@ namespace user { |
73 | 98 | using arch::ProblemGenerator<S, M>::C; |
74 | 99 | using arch::ProblemGenerator<S, M>::params; |
75 | 100 |
|
76 | | - const real_t Bsurf, Rstar, Omega; |
77 | | - InitFields<D> init_flds; |
| 101 | + const real_t Bsurf, Rstar, Omega; |
| 102 | + const std::string field_geom; |
| 103 | + InitFields<D> init_flds; |
78 | 104 |
|
79 | 105 | inline PGen(const SimulationParams& p, const Metadomain<S, M>& m) |
80 | 106 | : arch::ProblemGenerator<S, M>(p) |
81 | 107 | , Bsurf { p.template get<real_t>("setup.Bsurf", ONE) } |
82 | 108 | , Rstar { m.mesh().extent(in::x1).first } |
83 | 109 | , Omega { static_cast<real_t>(constant::TWO_PI) / |
84 | 110 | p.template get<real_t>("setup.period", ONE) } |
85 | | - , init_flds { Bsurf, Rstar } {} |
| 111 | + , field_geom { p.template get<std::string>("setup.field_geometry", "dipole") } |
| 112 | + , init_flds { Bsurf, Rstar, field_geom } {} |
86 | 113 |
|
87 | 114 | inline PGen() {} |
88 | 115 |
|
89 | 116 | auto AtmFields(real_t time) const -> DriveFields<D> { |
90 | | - return DriveFields<D> { time, Bsurf, Rstar, Omega }; |
| 117 | + return DriveFields<D> { time, Bsurf, Rstar, Omega, field_geom }; |
91 | 118 | } |
92 | 119 |
|
93 | 120 | auto MatchFields(real_t) const -> InitFields<D> { |
94 | | - return InitFields<D> { Bsurf, Rstar }; |
| 121 | + return InitFields<D> { Bsurf, Rstar, field_geom }; |
95 | 122 | } |
96 | 123 | }; |
97 | 124 |
|
|
0 commit comments