TDMS
Time Domain Maxwell Solver
All Classes Namespaces Files Functions Variables Typedefs Enumerations Macros Pages
surface_phasors.h
Go to the documentation of this file.
1/**
2 * @file surface_phasors.h
3 * @brief Contains a class that handles the complex amplitude extraction.
4 */
5#pragma once
6
7#include "arrays.h"
8#include "field.h"
9#include "grid_labels.h"
10
11/**
12 * @brief A class that handles the extraction of the phasors on the
13 * user-specified surface.
14 *
15 * This class stores:
16 * - The number of vertices on the surface,
17 * - Their indicies in the global indexing convention,
18 * - The data (phasors) at each of these vertices,
19 * - A pointer to the output array
20 *
21 */
23private:
24 int **surface_vertices = nullptr;//!< Pointer to the vertices on the surface
25 int n_surface_vertices = 0; //!< Number of vertices on the surface
26
27 mxArray *vertex_list = nullptr;//< List of vertices
28 double **vertex_list_data_ptr =
29 nullptr;//< Buffer to place vertex data into MATLAB array
30
31 mxArray *mx_surface_amplitudes = nullptr;//< Complex surface amplitudes
32 int f_ex_vector_size =
33 0;//< Number of elements in the frequency extraction vector
34
35 /* Storage for real and imag parts of mx_surface_amplitudes (these can be
36 f_ex_vector_size * n_surface_vertices arrays of FullFieldSnapshots when MATLAB
37 is removed!)
38
39 Arrays are index by [frequency_index][field component][vertex_id/number].
40 Frequency index corresponds to the frequencies at which the user has requested
41 we extract the amplitudes.
42 */
43 double ***surface_EHr = nullptr,
44 ***surface_EHi = nullptr;//!< @copydoc surface_EHr
45
46public:
47 SurfacePhasors() = default;
48 /**
49 * @brief Construct a new Surface Phasors object, using the
50 * set_from_matlab_array() method
51 */
52 SurfacePhasors(mxArray *mx_surface_vertices, int _f_ex_vector_size);
53 /**
54 * @brief Sets the surface_vertices pointer and number of surface vertices
55 * tracker from the MATLAB array passed in
56 *
57 * @param mx_surface_vertices MATLAB array containing the vertex information
58 * @param _f_ex_vector_size The FrequencyExtractionVector size, which we need
59 * to reserve sufficient memory
60 */
61 void set_from_matlab_array(mxArray *mx_surface_vertices,
62 int f_ex_vector_size);
63
64 /**
65 * @brief Zeros the surface_EH{r,i} arrays
66 */
68 for (int k = 0; k < f_ex_vector_size; k++) {
69 for (int j = 0; j < 6; j++) {// 6 field components: Ex, y, z, and Hx, y, z
70 for (int i = 0; i < n_surface_vertices; i++) {
71 surface_EHr[k][j][i] = 0.;
72 surface_EHi[k][j][i] = 0.;
73 }
74 }
75 }
76 }
77
78 /**
79 * @brief Get the number of surface vertices
80 */
82
83 /**
84 * @brief Get the list of vertices
85 */
86 mxArray *get_vertex_list() { return vertex_list; };
87
88 /**
89 * @brief Get the array of complex surface amplitudes
90 */
91 mxArray *get_mx_surface_amplitudes() { return mx_surface_amplitudes; };
92
93 /**
94 * @brief Normalise the surface amplitudes at frequency_vector_index by the E-
95 * and H-norms provided.
96 *
97 * E-field components in surface_EH are divided by the (complex) Enorm.
98 * H-field components in surface_EH are divided by the (complex) Hnorm.
99 *
100 * @param frequency_vector_index Frequency index,
101 * surface_EH{r,i}[frequency_vector_index] will be normalised
102 * @param Enorm,Hnorm The {E,H}-norm to normalise the {E,H}-components by
103 */
104 void normalise_surface(int frequency_index, std::complex<double> Enorm,
105 std::complex<double> Hnorm);
106
107 /**
108 * @brief Extract the phasor values at the vertices on the surface, for the
109 * given frequency index
110 *
111 * @param frequency_index The entries in surface_EH{r,i}[frequency_index] will
112 * be written to
113 * @param E,H The electric,magnetic field
114 * @param n Current timestep index
115 * @param omega Angular frequency
116 * @param Nt The number of timesteps in a sinusoidal period
117 * @param params The parameters for this simulation
118 * @param interpolate If true, perform interpolation on the fields when
119 * extracting phasors
120 */
121 void extractPhasorsSurface(int frequency_index, ElectricSplitField &E,
122 MagneticSplitField &H, int n, double omega, int Nt,
123 SimulationParameters &params,
124 bool interpolate = true);
125
126 /**
127 * @brief Pulls the GridLabels information of vertices on the surface into
128 * vertex_list, a continuous block of memory.
129 *
130 * The vertex_list attribute will consist only of vertices that lie on the
131 * surface that the given class instance defines.
132 *
133 * @param input_grid_labels
134 */
135 void create_vertex_list(GridLabels input_grid_labels);
136
137 /**
138 * @brief Incriments surface_EH{r,i} at the given index by the field values
139 * provided.
140 *
141 * If we allow element-wise assignment, we are essentially performing the
142 * operations: surface_EHr[frequency_vector_index][:][vertex_index] +=
143 * F.real(), surface_EHi[frequency_vector_index][:][vertex_index] += F.imag().
144 *
145 * @param frequency_index Frequency vector index (k) to assign to
146 * @param vertex_index Vertex index (i) to assign to
147 * @param F Field values to assign
148 */
149 void update_surface_EH(int frequency_index, int vertex_index,
151
153};
Classes describing arrays, vertices etc.
Definition field.h:161
Definition arrays.h:116
Definition grid_labels.h:13
Definition field.h:188
Class storing the various constants and behaviour flags for one executation of the tdms executable.
Definition simulation_parameters.h:69
A class that handles the extraction of the phasors on the user-specified surface.
Definition surface_phasors.h:22
double *** surface_EHi
Definition surface_phasors.h:44
void create_vertex_list(GridLabels input_grid_labels)
Pulls the GridLabels information of vertices on the surface into vertex_list, a continuous block of m...
Definition surface_phasors.cpp:160
int get_n_surface_vertices()
Get the number of surface vertices.
Definition surface_phasors.h:81
int ** surface_vertices
Pointer to the vertices on the surface.
Definition surface_phasors.h:24
mxArray * get_vertex_list()
Get the list of vertices.
Definition surface_phasors.h:86
void extractPhasorsSurface(int frequency_index, ElectricSplitField &E, MagneticSplitField &H, int n, double omega, int Nt, SimulationParameters &params, bool interpolate=true)
Extract the phasor values at the vertices on the surface, for the given frequency index.
Definition surface_phasors.cpp:74
void normalise_surface(int frequency_index, std::complex< double > Enorm, std::complex< double > Hnorm)
Normalise the surface amplitudes at frequency_vector_index by the E- and H-norms provided.
Definition surface_phasors.cpp:42
mxArray * get_mx_surface_amplitudes()
Get the array of complex surface amplitudes.
Definition surface_phasors.h:91
void set_from_matlab_array(mxArray *mx_surface_vertices, int f_ex_vector_size)
Sets the surface_vertices pointer and number of surface vertices tracker from the MATLAB array passed...
Definition surface_phasors.cpp:16
void update_surface_EH(int frequency_index, int vertex_index, FullFieldSnapshot F)
Incriments surface_EH{r,i} at the given index by the field values provided.
Definition surface_phasors.cpp:180
void zero_surface_EH()
Zeros the surface_EH{r,i} arrays.
Definition surface_phasors.h:67
int n_surface_vertices
Number of vertices on the surface.
Definition surface_phasors.h:25
Classes for the electric and magnetic (split) fields on a grid.
Class to hold the labels of a Yee cell.