25 T ***operator[](
char c)
const {
34 throw std::runtime_error(
"Have no element " + std::string(1, c));
37 T ***operator[](AxialDirection d)
const {
39 case AxialDirection::X:
41 case AxialDirection::Y:
43 case AxialDirection::Z:
46 throw std::runtime_error(
"Have no element " + std::to_string(d));
56 void allocate(
int I_total,
int J_total,
int K_total) {
57 x = (T ***) malloc(K_total *
sizeof(T **));
58 y = (T ***) malloc(K_total *
sizeof(T **));
59 z = (T ***) malloc(K_total *
sizeof(T **));
60 for (
int k = 0; k < K_total; k++) {
61 x[k] = (T **) malloc(J_total *
sizeof(T *));
62 y[k] = (T **) malloc(J_total *
sizeof(T *));
63 z[k] = (T **) malloc(J_total *
sizeof(T *));
64 for (
int j = 0; j < J_total; j++) {
65 x[k][j] = (T *) malloc(I_total *
sizeof(T));
66 y[k][j] = (T *) malloc(I_total *
sizeof(T));
67 z[k][j] = (T *) malloc(I_total *
sizeof(T));
82 explicit Vector(
const mxArray *ptr) {
83 n = (int) mxGetNumberOfElements(ptr);
84 vector = (T *) malloc((
unsigned) (n *
sizeof(T)));
86 auto matlab_ptr = mxGetPr(ptr);
87 for (
int i = 0; i < n; i++) { vector[i] = (T) matlab_ptr[i]; }
90 bool has_elements() {
return vector !=
nullptr; }
92 inline T operator[](
int value)
const {
return vector[value]; };
94 inline int size()
const {
return n; };
98 std::vector<double> x;
99 std::vector<double> y;
104 fftw_complex *v =
nullptr;
105 fftw_plan plan =
nullptr;
106 std::complex<double> **cm =
nullptr;
108 void initialise(
int n_rows,
int n_cols);
116class FullFieldSnapshot {
118 std::complex<double> Ex = 0.;
119 std::complex<double> Ey = 0.;
120 std::complex<double> Ez = 0.;
121 std::complex<double> Hx = 0.;
122 std::complex<double> Hy = 0.;
123 std::complex<double> Hz = 0.;
125 FullFieldSnapshot() =
default;
160 throw std::runtime_error(
"Index " + std::to_string(index) +
161 " does not correspond to a field component.");
void multiply_E_by(std::complex< double > factor)
Multiplies the electric field components by factor.
Definition arrays.h:170
void multiply_H_by(std::complex< double > factor)
Multiplies the magnetic field components by factor.
Definition arrays.h:179
std::complex< double > operator[](int index)
Return the component of the field corresponding to the index provided.
Definition arrays.h:139
void allocate(int I_total, int J_total, int K_total)
Allocates x, y, and z as (K_total+1) * (J_total+1) * (I_total+1) arrays.
Definition arrays.h:56
Type definitions and global constants.
Useful miscellaneous utility functions.