1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
#ifndef WARPX_MACROSCOPICPROPERTIES_H_
#define WARPX_MACROSCOPICPROPERTIES_H_
#include "MacroscopicProperties_fwd.H"
#include "Utils/WarpXConst.H"
#include <AMReX_Array.H>
#include <AMReX_Extension.H>
#include <AMReX_GpuQualifiers.H>
#include <AMReX_MultiFab.H>
#include <AMReX_Parser.H>
#include <AMReX_REAL.H>
#include <memory>
#include <string>
/**
* \brief This class contains the macroscopic properties of the medium needed to
* evaluate macroscopic Maxwell equation.
*/
class
MacroscopicProperties
{
public:
MacroscopicProperties (); // constructor
/** Read user-defined macroscopic properties. Called in constructor. */
void ReadParameters ();
/** Initialize multifabs storing macroscopic multifabs */
void InitData ();
/** return MultiFab, sigma (conductivity) of the medium. */
amrex::MultiFab& getsigma_mf () {return (*m_sigma_mf);}
/** return MultiFab, epsilon (permittivity) of the medium. */
amrex::MultiFab& getepsilon_mf () {return (*m_eps_mf);}
/** return MultiFab, mu (permeability) of the medium. */
amrex::MultiFab& getmu_mf () {return (*m_mu_mf);}
/** Initializes the Multifabs storing macroscopic properties
* with user-defined functions(x,y,z).
*/
void InitializeMacroMultiFabUsingParser (amrex::MultiFab *macro_mf,
amrex::ParserExecutor<3> const& macro_parser,
int lev);
/** Gpu Vector with index type of the conductivity multifab */
amrex::GpuArray<int, 3> sigma_IndexType;
/** Gpu Vector with index type of the permittivity multifab */
amrex::GpuArray<int, 3> epsilon_IndexType;
/** Gpu Vector with index type of the permeability multifab */
amrex::GpuArray<int, 3> mu_IndexType;
/** Gpu Vector with index type of the Ex multifab */
amrex::GpuArray<int, 3> Ex_IndexType;
/** Gpu Vector with index type of the Ey multifab */
amrex::GpuArray<int, 3> Ey_IndexType;
/** Gpu Vector with index type of the Ez multifab */
amrex::GpuArray<int, 3> Ez_IndexType;
/** Gpu Vector with index type of coarsening ratio with default value (1,1,1) */
amrex::GpuArray<int, 3> macro_cr_ratio;
private:
/** Conductivity, sigma, of the medium */
amrex::Real m_sigma = 0.0;
/** Permittivity, epsilon, of the medium */
amrex::Real m_epsilon = PhysConst::ep0;
/** Permeability, mu, of the medium */
amrex::Real m_mu = PhysConst::mu0;
/** Multifab for m_sigma */
std::unique_ptr<amrex::MultiFab> m_sigma_mf;
/** Multifab for m_epsilon */
std::unique_ptr<amrex::MultiFab> m_eps_mf;
/** Multifab for m_mu */
std::unique_ptr<amrex::MultiFab> m_mu_mf;
/** Stores initialization type for conductivity : constant or parser */
std::string m_sigma_s = "constant";
/** Stores initialization type for permittivity : constant or parser */
std::string m_epsilon_s = "constant";
/** Stores initialization type for permeability : constant or parser */
std::string m_mu_s = "constant";
/** string for storing parser function */
std::string m_str_sigma_function;
std::string m_str_epsilon_function;
std::string m_str_mu_function;
/** Parser Wrappers */
std::unique_ptr<amrex::Parser> m_sigma_parser;
std::unique_ptr<amrex::Parser> m_epsilon_parser;
std::unique_ptr<amrex::Parser> m_mu_parser;
};
/**
* \brief
* This struct contains only static functions to compute the co-efficients for the
* Lax-Wendroff scheme of macroscopic Maxwells equations using
* macroscopic properties, namely, conductivity (sigma), permittivity (epsilon).
* Permeability of the material, mu, is used as (beta/mu) for the E-update
* defined in MacroscopicEvolveECartesian().
*/
struct LaxWendroffAlgo {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real alpha (amrex::Real const sigma,
amrex::Real const epsilon,
amrex::Real dt) {
using namespace amrex;
amrex::Real fac1 = 0.5_rt * sigma * dt / epsilon;
amrex::Real alpha = (1._rt - fac1)/(1._rt + fac1);
return alpha;
}
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real beta (amrex::Real const sigma,
amrex::Real const epsilon,
amrex::Real dt) {
using namespace amrex;
amrex::Real fac1 = 0.5_rt * sigma * dt / epsilon;
amrex::Real beta = dt / ( epsilon * (1._rt + fac1) );
return beta;
}
};
/**
* \brief
* This struct contains only static functions to compute the co-efficients for the
* BackwardEuler scheme of macroscopic Maxwells equations using
* macroscopic properties, namely, conductivity (sigma) and permittivity (epsilon).
* Permeability of the material, mu, is used as (beta/mu) for the E-update
* defined in MacroscopicEvolveECartesian().
*/
struct BackwardEulerAlgo {
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real alpha (amrex::Real const sigma,
amrex::Real const epsilon,
amrex::Real dt) {
using namespace amrex;
amrex::Real fac1 = sigma * dt / epsilon;
amrex::Real alpha = (1._rt)/(1._rt + fac1);
return alpha;
}
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
static amrex::Real beta (amrex::Real const sigma,
amrex::Real const epsilon,
amrex::Real dt) {
using namespace amrex;
amrex::Real fac1 = sigma * dt / epsilon;
amrex::Real beta = dt / ( epsilon * (1._rt + fac1) );
return beta;
}
};
#endif // WARPX_MACROSCOPIC_PROPERTIES_H_
|