forked from mabl/wgms3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
diffops.h
140 lines (108 loc) · 4.03 KB
/
diffops.h
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
/*
wgms3d - a full-vectorial finite-difference mode solver.
Copyright (C) 2005-2012 Michael Krause <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _DIFFOPS_H
#define _DIFFOPS_H
#include <complex>
#include <unordered_map>
#include "wgms3d.h"
#include "stencil.h"
#include "mgp.h"
/* The diffop arrays (M0) contain the expressions for the derivatives
* in terms of the surrounding mesh points.
* M0(1,:) is expression for H^x_x
* M0(2,:) is expression for H^x_y
* M0(3,:) is expression for H^x_xx
* M0(4,:) is expression for H^x_xy
* M0(5,:) is expression for H^x_yy
* etc.
* M0(NDO+1,:) is expression for H^y_x
* M0(NDO+2,:) is expression for H^y_y
* etc.
* The order of the coefficients in one row of M0 is:
* M0(:,1:NSP) are for Hx values at stencil points (starting with P)
* M0(:,NSP+1:(2*NSP)) are for Hy values at stencil points (starting with P)
* M0 dimension is 2*NDO x 2*NSP
*/
namespace wgms3d {
struct SimulationParameters;
class Diffops
{
public:
Diffops (MGP *waveguide_geometry,
std::shared_ptr<SimulationParameters> simulation_parameters);
~Diffops (void);
/* Calculate finite-difference approximations for differential
* operators at point (xp,yp). The FD weights may be complex if
* we're inside a PML region, since the interface conditions
* depend on the complex stretching function s. However, even for
* points in the non-PML regions, we return a complex<double>
* array in order to minimize code duplication. */
/* Returns an array that must be freed with delete[] by the
* caller. */
std::complex<double> * calculate_diffop (double xp,
double yp,
std::complex<double> epsp,
const direction *dirs);
/* Returns an array that must not be freed -- it's only valid
* until the next call to this function: */
std::complex<double> * get_standard_diffop (double n,
double e,
double s,
double w);
void store_diffops (std::complex<double> *M0,
int i,
int j);
/* get_diffops(): return previously calculated FD approximation to
* differential operators at given point. Needed for
* post-processing. */
std::complex<double> * get_diffops (const std::vector<double> &rs,
const std::vector<double> &zs,
int i,
int j);
int get_num_stored_diffops (void) {
return diffops.size();
}
private:
int TayA_M, TayA_N, Tay_nrhs;
char Tay_trans;
int Tay_lwork;
std::complex<double> *Tay_wwork;
std::unordered_map<int, std::complex<double>*> diffops;
std::complex<double> _stddiffop[(2*NDO) * (2*NSP)];
MGP *mgp;
std::shared_ptr<SimulationParameters> sp;
void make_curv_interface_matrix (
std::complex<double> *MLR,
double theta, /* angle of interface at intersection point */
double d, /* curvature of interface */
std::complex<double> m, /* n^2 before interface */
std::complex<double> p, /* n^2 behind interface */
double rho, double z); /* non-stretched (real) coordinates of intersection point*/
/* This function returns the field values H^{rho|z}(rp+dr,zp+dz)
in terms of the values of the fields H^{rho|z} and their
derivatives at (rp,zp). */
void do_matched_taylor_expansion (
std::complex<double> *dstR,
std::complex<double> *dstZ,
int incd,
double rp,
double zp,
double dr,
double dz,
std::complex<double> epsp,
int &found_interfaces);
};
} // namespace wgms3d
#endif // _DIFFOPS_H