Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
time_harmonic_maxwell_assemblers.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
5
8
9#include <deal.II/base/numbers.h>
10
11#include <algorithm>
12#include <cmath>
13#include <iterator>
14#include <string>
15#include <tuple>
16
17template <int dim>
18std::pair<Tensor<1, dim, std::complex<double>>,
19 Tensor<1, dim, std::complex<double>>>
21 const Parameters::TimeHarmonicMaxwell<dim> &time_harmonic_maxwell_parameters,
22 const Point<dim> &p,
23 const Tensor<1, dim> &normal,
24 const std::complex<double> &effective_electric_permittivity,
25 const std::complex<double> &effective_magnetic_permeability,
26 const unsigned int waveguide_port_index)
27{
28 // The waveguide port excitation would be completely different in 2D as curls
29 // and cross products are not defined the same way as in 3D. Therefore, we do
30 // not implement it for now and throw an error if someone tries to use the 2D
31 // version.
32 if constexpr (dim != 3)
33 {
34 (void)time_harmonic_maxwell_parameters;
35 (void)p;
36 (void)normal;
37 (void)effective_electric_permittivity;
38 (void)effective_magnetic_permeability;
39 (void)waveguide_port_index;
40 AssertThrow(false, TimeHarmonicMaxwellDimensionNotSupported(dim));
41 return std::pair<Tensor<1, dim, std::complex<double>>,
42 Tensor<1, dim, std::complex<double>>>();
43 }
44 // Define some constexpr values for the computation
45 static constexpr std::complex<double> imag{0., 1.};
46 static constexpr double PI = numbers::PI;
47
48 // Gather the relevant waveguide parameters
49 const double omega =
50 2.0 * PI * time_harmonic_maxwell_parameters.electromagnetic_frequency;
51 const auto &waveguide_corners =
52 time_harmonic_maxwell_parameters.waveguide_corners[waveguide_port_index];
53 const Parameters::WaveguideMode mode =
54 time_harmonic_maxwell_parameters.waveguide_mode[waveguide_port_index];
55 unsigned int m =
56 time_harmonic_maxwell_parameters.mode_order_m[waveguide_port_index];
57 unsigned int n =
58 time_harmonic_maxwell_parameters.mode_order_n[waveguide_port_index];
59
60 // We first define the transverse face vectors of the waveguide in the global
61 // system
62 Tensor<1, dim> transverse_vector_1 =
63 waveguide_corners[1] - waveguide_corners[0];
64 Tensor<1, dim> transverse_vector_2 =
65 waveguide_corners[2] - waveguide_corners[0];
66 double length_t1 = transverse_vector_1.norm();
67 double length_t2 = transverse_vector_2.norm();
68 Tensor<1, dim> e_t1 = transverse_vector_1 / length_t1;
69 Tensor<1, dim> e_t2 = transverse_vector_2 / length_t2;
70
71 // Check if the transverse vectors form a perfect rectangle (orthogonal and
72 // aligned with the axes)
73 AssertThrow(
74 std::abs(e_t1 * e_t2) < 1e-12,
75 ExcMessage(
76 "The transverse plane defined by the waveguide corners for the waveguide port at boundary ID " +
77 std::to_string(time_harmonic_maxwell_parameters
78 .waveguide_boundary_ids[waveguide_port_index]) +
79 " is not a perfect rectangle (i.e., the vector created by the waveguide corners are not orthogonal). Please check the waveguide corners definition in the input prm file."));
80
81
82 // Also verify that those transverse vectors are perpendicular to the normal
83 // of the face and form an orthogonal basis.
84 if ((std::abs(normal * e_t1) > 1e-12) || (std::abs(normal * e_t2) > 1e-12))
85 AssertThrow(
86 false,
87 ExcMessage(
88 "The transverse plane defined by the waveguide corners for the waveguide port at boundary ID " +
89 std::to_string(time_harmonic_maxwell_parameters
90 .waveguide_boundary_ids[waveguide_port_index]) +
91 " is not orthogonal to the boundary face normal. Please check the waveguide corners definition in the input prm file."));
92
93 // Create a third vector to complete the right-handed coordinate system
94 Tensor<1, dim> e_t3 = cross_product_3d(e_t1, e_t2);
95
96 // Determine if the system needs to be flipped so the e_t3 vector points in
97 // the direction opposite to the outward normal of the face boundary. For an
98 // incident wave at the inlet, the propagation direction should point into the
99 // domain (opposite to the outward normal). We use the sign of (normal · t3)
100 // to determine this:
101 // - If normal · t3 > 0: t3 points outward, need to flip entire system
102 // - If normal · t3 < 0: t3 points inward (correct for incident wave)
103 // The flip swaps e_t1 and e_t2 (and the associated lengths and mode orders,
104 // so the mode keeps the same transverse profile) and recomputes e_t3 as their
105 // cross product so the resulting system is right-handed.
106 if ((normal * e_t3) > 0)
107 {
108 std::swap(e_t1, e_t2);
109 std::swap(length_t1, length_t2);
110 std::swap(m, n);
111 e_t3 =
112 cross_product_3d(e_t1, e_t2); // Recompute t3 after swapping t1 and t2
113 // to be sure the system is right-handed
114 }
115
116 // Compute the various wavenumbers k in using this global coordinate system
117 double k_t1 = m * PI / length_t1; // Transverse wavenumber 1
118 double k_t2 = n * PI / length_t2; // Transverse wavenumber 2
119 double k_c = std::sqrt(k_t1 * k_t1 + k_t2 * k_t2); // Cutoff wavenumber
120 std::complex<double> k =
121 omega *
122 std::sqrt(effective_electric_permittivity *
123 effective_magnetic_permeability); // Wavenumber in the medium
124 std::complex<double> k_l = std::sqrt(
125 k * k - std::complex<double>(k_c * k_c, 0)); // Longitudinal wavenumber
126
127 // Verify that the mode is not evanescent, i.e. k_l is not purely imaginary
128 // (k_c^2 < k^2). std::norm computes the squared magnitude of a complex
129 // number.
130 AssertThrow(
131 std::norm(k) > (k_c * k_c),
132 ExcMessage("The chosen mode for the waveguide port at boundary ID " +
133 std::to_string(time_harmonic_maxwell_parameters
134 .waveguide_boundary_ids[waveguide_port_index]) +
135 " is evanescent at the given frequency. Please "
136 "choose another mode or increase the frequency."));
137
138 // Now we want to compute the electromagnetic field and surface admittance at
139 // point p as if the waveguide center was at the origin. So we will perform a
140 // change of basis to a local coordinate system where the waveguide center is
141 // at the origin.
142 Tensor<1, dim> origin_local =
143 0.25 * (waveguide_corners[0] + waveguide_corners[1] + waveguide_corners[2] +
144 waveguide_corners[3]);
145
146 Tensor<1, dim> p_local =
147 p - origin_local; // Coordinates of point p in this local system.
148
149 const double x_local =
150 p_local * e_t1; // Coordinate along e_t1 in the local system
151 const double y_local =
152 p_local * e_t2; // Coordinate along e_t2 in the local system
153 // We assume that the z_local coordinate is 0 since we are on the face.
154
155 // Compute the E and H field components for the TE mode in the local
156 // coordinate system {t1, t2, t3} = {x', y', z'}. We assume z' = 0 at the
157 // boundary.
158 Tensor<1, dim, std::complex<double>> E_inc_local;
159 Tensor<1, dim, std::complex<double>> H_inc_local;
160
161 // sin and cos functions that are repeatedly used in the computation of the E
162 // and H fields.
163 const double sin_k_t1_x = std::sin(k_t1 * (x_local + 0.5 * length_t1));
164 const double cos_k_t1_x = std::cos(k_t1 * (x_local + 0.5 * length_t1));
165 const double sin_k_t2_y = std::sin(k_t2 * (y_local + 0.5 * length_t2));
166 const double cos_k_t2_y = std::cos(k_t2 * (y_local + 0.5 * length_t2));
167
169 {
170 std::complex<double> factor =
171 imag * omega * effective_magnetic_permeability / (k_c * k_c);
172
173 E_inc_local[0] = -factor * k_t2 * cos_k_t1_x * sin_k_t2_y;
174 E_inc_local[1] = factor * k_t1 * sin_k_t1_x * cos_k_t2_y;
175 E_inc_local[2] = 0.0;
176
177 H_inc_local[0] =
178 -imag * k_l * k_t1 / (k_c * k_c) * sin_k_t1_x * cos_k_t2_y;
179 H_inc_local[1] =
180 -imag * k_l * k_t2 / (k_c * k_c) * cos_k_t1_x * sin_k_t2_y;
181 H_inc_local[2] = cos_k_t1_x * cos_k_t2_y;
182 }
183 else if (mode == Parameters::WaveguideMode::TM)
184 {
185 std::complex<double> factor =
186 imag * omega * effective_electric_permittivity / (k_c * k_c);
187
188 H_inc_local[0] = -factor * k_t2 * sin_k_t1_x * cos_k_t2_y;
189 H_inc_local[1] = factor * k_t1 * cos_k_t1_x * sin_k_t2_y;
190 H_inc_local[2] = 0.0;
191
192 E_inc_local[0] =
193 imag * k_l * k_t1 / (k_c * k_c) * cos_k_t1_x * sin_k_t2_y;
194 E_inc_local[1] =
195 imag * k_l * k_t2 / (k_c * k_c) * sin_k_t1_x * cos_k_t2_y;
196 E_inc_local[2] = sin_k_t1_x * sin_k_t2_y;
197 }
198 else
199 {
200 AssertThrow(false, ExcMessage("Unknown waveguide mode type."));
201 }
202
203 // Convert the E and H field components from the local coordinate system back
204 // to the global coordinate system using the basis vectors e_t1, e_t2, e_t3
205 const Tensor<1, dim, std::complex<double>> E_inc =
206 E_inc_local[0] * e_t1 + E_inc_local[1] * e_t2 + E_inc_local[2] * e_t3;
207 const Tensor<1, dim, std::complex<double>> H_inc =
208 H_inc_local[0] * e_t1 + H_inc_local[1] * e_t2 + H_inc_local[2] * e_t3;
209
210 return std::make_pair(E_inc, H_inc);
211}
212
213template <int dim>
214unsigned int
216 const Parameters::TimeHarmonicMaxwell<dim> &time_harmonic_maxwell_parameters,
217 const types::boundary_id boundary_id)
218{
219 // The waveguide port index is the position of the boundary id in the list of
220 // the port boundary ids of the waveguide inlets
221 const std::vector<int> &waveguide_boundary_ids =
222 time_harmonic_maxwell_parameters.waveguide_boundary_ids;
223 const unsigned int waveguide_port_index = static_cast<unsigned int>(
224 std::distance(waveguide_boundary_ids.begin(),
225 std::ranges::find(waveguide_boundary_ids,
226 static_cast<int>(boundary_id))));
227
228 return waveguide_port_index;
229}
230
231namespace
232{
233 /**
234 * @brief Add a complex value to a 2x2 block of a local matrix of the real DPG
235 * system. Each shape function is a real base function multiplied by s = 1
236 * (real part) or by the imaginary unit (imaginary part). This gives the block
237 * [[Re z, -Im z], [Im z, Re z]] for the (real, imaginary) rows of i and the
238 * (real, imaginary) columns of j when multiplying shape functions.
239 *
240 * @param[in,out] matrix Local matrix.
241 *
242 * @param[in] row_real Local dof index of the real part of the row base
243 * function.
244 *
245 * @param[in] row_imag Local dof index of the imaginary part of the row base
246 * function.
247 *
248 * @param[in] column_real Local dof index of the real part of the column base
249 * function.
250 *
251 * @param[in] column_imag Local dof index of the imaginary part of the column
252 * base function.
253 *
254 * @param[in] z Complex value associated with the pair of base functions.
255 */
256 void
257 add_complex_block(LAPACKFullMatrix<double> &matrix,
258 const unsigned int row_real,
259 const unsigned int row_imag,
260 const unsigned int column_real,
261 const unsigned int column_imag,
262 const std::complex<double> &z)
263 {
264 matrix(row_real, column_real) += z.real();
265 matrix(row_real, column_imag) -= z.imag();
266 matrix(row_imag, column_real) += z.imag();
267 matrix(row_imag, column_imag) += z.real();
268 }
269
270 /**
271 * @brief Add a real value to a 2x2 block of a local matrix of the real DPG
272 * system. This is a special case of the add_complex_block function to
273 * avoid the overhead of adding close to zero imaginary parts.
274 *
275 * @param[in,out] matrix Local matrix.
276 *
277 * @param[in] row_real Local dof index of the real part of the row base
278 * function.
279 *
280 * @param[in] row_imag Local dof index of the imaginary part of the row base
281 * function.
282 *
283 * @param[in] column_real Local dof index of the real part of the column base
284 * function.
285 *
286 * @param[in] column_imag Local dof index of the imaginary part of the column
287 * base function.
288 *
289 * @param[in] z Real value associated with the pair of base functions.
290 */
291 void
292 add_real_block(LAPACKFullMatrix<double> &matrix,
293 const unsigned int row_real,
294 const unsigned int row_imag,
295 const unsigned int column_real,
296 const unsigned int column_imag,
297 const double z)
298 {
299 matrix(row_real, column_real) += z;
300 matrix(row_imag, column_imag) += z;
301 }
302} // namespace
303
304template <int dim>
309
310template <int dim>
311void
313 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
314 DPGCopyData &copy_data)
315{
316 using ScratchData = TimeHarmonicMaxwellScratchData<dim>;
317
318 const unsigned int n_q_points = scratch_data.n_q_points;
319 const unsigned int n_base_functions_test = scratch_data.n_base_functions_test;
320 const unsigned int n_base_functions_trial_interior =
322
323 // Local dof indices of the real and imaginary parts of each base function:
324 // electric (F) and magnetic (I) test functions, and electric (E) and magnetic
325 // (H) interior trial functions
326 const std::vector<unsigned int> &test_dofs_F_real =
327 scratch_data.test_local_dof_index_map[ScratchData::E_real];
328 const std::vector<unsigned int> &test_dofs_F_imag =
329 scratch_data.test_local_dof_index_map[ScratchData::E_imag];
330 const std::vector<unsigned int> &test_dofs_I_real =
331 scratch_data.test_local_dof_index_map[ScratchData::H_real];
332 const std::vector<unsigned int> &test_dofs_I_imag =
333 scratch_data.test_local_dof_index_map[ScratchData::H_imag];
334 const std::vector<unsigned int> &trial_dofs_E_real =
335 scratch_data.trial_interior_local_dof_index_map[ScratchData::E_real];
336 const std::vector<unsigned int> &trial_dofs_E_imag =
337 scratch_data.trial_interior_local_dof_index_map[ScratchData::E_imag];
338 const std::vector<unsigned int> &trial_dofs_H_real =
339 scratch_data.trial_interior_local_dof_index_map[ScratchData::H_real];
340 const std::vector<unsigned int> &trial_dofs_H_imag =
341 scratch_data.trial_interior_local_dof_index_map[ScratchData::H_imag];
342
343 // Coefficients of the terms at the quadrature points, multiplied by JxW and
344 // computed by the scratch data, with iweps = i omega eps and
345 // iwmu = i omega mu. Since JxW is real, conj(iwmu) JxW is the complex
346 // conjugate of iwmu JxW.
347 const std::vector<double> &JxW = scratch_data.JxW;
348 const std::vector<double> &JxW_FF_container = scratch_data.JxW_FF_container;
349 const std::vector<double> &JxW_II_container = scratch_data.JxW_II_container;
350 const std::vector<std::complex<double>> &iweps_JxW_container =
351 scratch_data.iweps_JxW_container;
352 const std::vector<std::complex<double>> &iwmu_JxW_container =
353 scratch_data.iwmu_JxW_container;
354
355 LAPACKFullMatrix<double> &G_matrix = copy_data.G_matrix;
356 LAPACKFullMatrix<double> &B_matrix = copy_data.B_matrix;
357
358 // Gram matrix G (Riesz map of the test space norm). For the test base
359 // functions i (rows) and j (columns), the blocks are:
360 // - FF: (1 + |iweps|^2) (phi_i, phi_j) + (curl phi_i, curl phi_j)
361 // - II: (1 + |iwmu|^2) (phi_i, phi_j) + (curl phi_i, curl phi_j)
362 // - FI: iweps (phi_i, curl phi_j) - conj(iwmu) (curl phi_i, phi_j)
363 // - IF: since G is Hermitian, the block IF(j, i) is conj(FI(i, j)).
364 // FF and II are real and symmetric in i and j, so we only loop over the pairs
365 // i <= j and add the blocks of the pair (j, i) at the same time.
366 for (unsigned int i = 0; i < n_base_functions_test; ++i)
367 {
368 const auto phi_i = scratch_data.phi_test[i];
369 const auto curl_phi_i = scratch_data.curl_phi_test[i];
370
371 for (unsigned int j = i; j < n_base_functions_test; ++j)
372 {
373 const auto phi_j = scratch_data.phi_test[j];
374 const auto curl_phi_j = scratch_data.curl_phi_test[j];
375
376 double z_FF = 0.;
377 double z_II = 0.;
378 std::complex<double> z_FI_ij(0.);
379 std::complex<double> z_FI_ji(0.);
380 for (unsigned int q = 0; q < n_q_points; ++q)
381 {
382 // The four dot products are shared by the four blocks
383 const double phi_i_phi_j = phi_i[q] * phi_j[q];
384 const double curl_i_curl_j = curl_phi_i[q] * curl_phi_j[q];
385 const double phi_i_curl_j = phi_i[q] * curl_phi_j[q];
386 const double curl_i_phi_j = curl_phi_i[q] * phi_j[q];
387
388 z_FF +=
389 JxW_FF_container[q] * phi_i_phi_j + JxW[q] * curl_i_curl_j;
390 z_II +=
391 JxW_II_container[q] * phi_i_phi_j + JxW[q] * curl_i_curl_j;
392 z_FI_ij += iweps_JxW_container[q] * phi_i_curl_j -
393 std::conj(iwmu_JxW_container[q]) * curl_i_phi_j;
394 z_FI_ji += iweps_JxW_container[q] * curl_i_phi_j -
395 std::conj(iwmu_JxW_container[q]) * phi_i_curl_j;
396 }
397
398 // Blocks of the pair (i, j)
399 add_real_block(G_matrix,
400 test_dofs_F_real[i],
401 test_dofs_F_imag[i],
402 test_dofs_F_real[j],
403 test_dofs_F_imag[j],
404 z_FF);
405 add_real_block(G_matrix,
406 test_dofs_I_real[i],
407 test_dofs_I_imag[i],
408 test_dofs_I_real[j],
409 test_dofs_I_imag[j],
410 z_II);
411 add_complex_block(G_matrix,
412 test_dofs_F_real[i],
413 test_dofs_F_imag[i],
414 test_dofs_I_real[j],
415 test_dofs_I_imag[j],
416 z_FI_ij);
417 add_complex_block(G_matrix,
418 test_dofs_I_real[j],
419 test_dofs_I_imag[j],
420 test_dofs_F_real[i],
421 test_dofs_F_imag[i],
422 std::conj(z_FI_ij));
423
424 // Blocks of the pair (j, i), we skip the case i == j because the
425 // diagonal blocks are already filled by the pair (i, j)
426 if (j != i)
427 {
428 add_real_block(G_matrix,
429 test_dofs_F_real[j],
430 test_dofs_F_imag[j],
431 test_dofs_F_real[i],
432 test_dofs_F_imag[i],
433 z_FF);
434 add_real_block(G_matrix,
435 test_dofs_I_real[j],
436 test_dofs_I_imag[j],
437 test_dofs_I_real[i],
438 test_dofs_I_imag[i],
439 z_II);
440 add_complex_block(G_matrix,
441 test_dofs_F_real[j],
442 test_dofs_F_imag[j],
443 test_dofs_I_real[i],
444 test_dofs_I_imag[i],
445 z_FI_ji);
446 add_complex_block(G_matrix,
447 test_dofs_I_real[i],
448 test_dofs_I_imag[i],
449 test_dofs_F_real[j],
450 test_dofs_F_imag[j],
451 std::conj(z_FI_ji));
452 }
453 }
454 }
455
456 // Interior bilinear form B. For the test base function i (rows) and the
457 // interior trial base function j (columns), the blocks are:
458 // - FE: iweps (phi_i, phi_j)
459 // - FH and IE: (curl phi_i, phi_j)
460 // - IH: -iwmu (phi_i, phi_j)
461 for (unsigned int i = 0; i < n_base_functions_test; ++i)
462 {
463 const auto phi_i = scratch_data.phi_test[i];
464 const auto curl_phi_i = scratch_data.curl_phi_test[i];
465
466 for (unsigned int j = 0; j < n_base_functions_trial_interior; ++j)
467 {
468 const auto phi_j = scratch_data.phi_trial_interior[j];
469
470 std::complex<double> z_FE(0.);
471 double z_FH = 0.;
472 std::complex<double> z_IH(0.);
473 for (unsigned int q = 0; q < n_q_points; ++q)
474 {
475 const double phi_i_phi_j = phi_i[q] * phi_j[q];
476 const double curl_i_phi_j = curl_phi_i[q] * phi_j[q];
477
478 z_FE += iweps_JxW_container[q] * phi_i_phi_j;
479 z_FH += JxW[q] * curl_i_phi_j;
480 z_IH -= iwmu_JxW_container[q] * phi_i_phi_j;
481 }
482
483 add_complex_block(B_matrix,
484 test_dofs_F_real[i],
485 test_dofs_F_imag[i],
486 trial_dofs_E_real[j],
487 trial_dofs_E_imag[j],
488 z_FE);
489 add_real_block(B_matrix,
490 test_dofs_F_real[i],
491 test_dofs_F_imag[i],
492 trial_dofs_H_real[j],
493 trial_dofs_H_imag[j],
494 z_FH);
495 // This block is the addition for the result of z_IE = (curl phi_i,
496 // phi_j) which is the same as z_FH, so we can reuse it
497 add_real_block(B_matrix,
498 test_dofs_I_real[i],
499 test_dofs_I_imag[i],
500 trial_dofs_E_real[j],
501 trial_dofs_E_imag[j],
502 z_FH);
503 add_complex_block(B_matrix,
504 test_dofs_I_real[i],
505 test_dofs_I_imag[i],
506 trial_dofs_H_real[j],
507 trial_dofs_H_imag[j],
508 z_IH);
509 }
510 }
511}
512
513template <int dim>
514void
516 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
517 DPGCopyData &copy_data)
518{
519 using ScratchData = TimeHarmonicMaxwellScratchData<dim>;
520
521 Vector<double> &l_vector = copy_data.l_vector;
522
523 // We return early because there are no volume source terms in the
524 // time-harmonic Maxwell equations at the moment.
525 return;
526
527 // Loop over the quadrature points of the cell. No volume source term is
528 // considered at the moment, so the interior load vector is zero.
529 for (unsigned int q = 0; q < scratch_data.n_q_points; ++q)
530 {
531 for (unsigned int i = 0; i < scratch_data.n_base_functions_test; ++i)
532 {
533 l_vector[scratch_data
534 .test_local_dof_index_map[ScratchData::E_real][i]] += 0.0;
535 l_vector[scratch_data
536 .test_local_dof_index_map[ScratchData::E_imag][i]] += 0.0;
537 }
538 }
539}
540
541
542template <int dim>
543void
545 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
546 DPGCopyData &copy_data)
547{
548 using ScratchData = TimeHarmonicMaxwellScratchData<dim>;
549
550 // On the faces where a Robin boundary condition is applied, the magnetic
551 // trace term is replaced by the Robin boundary condition.
552 const bool robin_face = scratch_data.face_at_boundary &&
554 scratch_data.face_boundary_id));
555
556 // Local dof indices of the real and imaginary parts of each base function:
557 // electric (F) and magnetic (I) test functions, and electric (E_hat) and
558 // magnetic (H_hat) skeleton trial functions
559 const std::vector<unsigned int> &test_dofs_F_real =
560 scratch_data.test_local_dof_index_map[ScratchData::E_real];
561 const std::vector<unsigned int> &test_dofs_F_imag =
562 scratch_data.test_local_dof_index_map[ScratchData::E_imag];
563 const std::vector<unsigned int> &test_dofs_I_real =
564 scratch_data.test_local_dof_index_map[ScratchData::H_real];
565 const std::vector<unsigned int> &test_dofs_I_imag =
566 scratch_data.test_local_dof_index_map[ScratchData::H_imag];
567 const std::vector<unsigned int> &trial_dofs_E_hat_real =
568 scratch_data.trial_skeleton_local_dof_index_map[ScratchData::E_real];
569 const std::vector<unsigned int> &trial_dofs_E_hat_imag =
570 scratch_data.trial_skeleton_local_dof_index_map[ScratchData::E_imag];
571 const std::vector<unsigned int> &trial_dofs_H_hat_real =
572 scratch_data.trial_skeleton_local_dof_index_map[ScratchData::H_real];
573 const std::vector<unsigned int> &trial_dofs_H_hat_imag =
574 scratch_data.trial_skeleton_local_dof_index_map[ScratchData::H_imag];
575
576 const std::vector<double> &face_JxW = scratch_data.face_JxW;
577
578 LAPACKFullMatrix<double> &B_hat_matrix = copy_data.B_hat_matrix;
579
580 // For the test base function i (rows) and the skeleton trial base function j
581 // (columns), the blocks are:
582 // - IE_hat: <phi_i, n x e_hat_j>
583 // - FH_hat: <phi_i, n x h_hat_j>, the same value since the electric and
584 // magnetic skeleton fields share the same base functions
585 // Here we use the precomputed tangential base functions (a subset of base
586 // functions) of the test and trial spaces for the loop to avoid extra
587 // computations of non-contributing base functions.
588 for (const unsigned int i :
589 scratch_data.test_tangential_base_functions[scratch_data.face_no])
590 {
591 const auto phi_i = scratch_data.phi_test_face[i];
592
593 for (const unsigned int j :
594 scratch_data
595 .trial_skeleton_tangential_base_functions[scratch_data.face_no])
596 {
597 const auto n_cross_phi_j =
599
600 double z_IE = 0.;
601 for (unsigned int q = 0; q < scratch_data.n_face_q_points; ++q)
602 z_IE += face_JxW[q] * (phi_i[q] * n_cross_phi_j[q]);
603
604 add_real_block(B_hat_matrix,
605 test_dofs_I_real[i],
606 test_dofs_I_imag[i],
607 trial_dofs_E_hat_real[j],
608 trial_dofs_E_hat_imag[j],
609 z_IE);
610
611 // Here we also add z_FH, which is the same as z_IE. However, we only
612 // do this if the Robin boundary condition is not applied, because in
613 // that case, the magnetic trace term is replaced by the Robin
614 // boundary condition on the faces where it is applied.
615 if (!robin_face)
616 add_real_block(B_hat_matrix,
617 test_dofs_F_real[i],
618 test_dofs_F_imag[i],
619 trial_dofs_H_hat_real[j],
620 trial_dofs_H_hat_imag[j],
621 z_IE);
622 }
623 }
624}
625
626template <int dim>
627void
632
633template <int dim>
638 const std::vector<double> &waveguide_ports_electric_amplitudes)
641 , waveguide_ports_relative_amplitudes(waveguide_ports_electric_amplitudes)
642{
643 // In the case of multiple waveguide ports, we normalize their amplitudes by
644 // their maximum here before assembling the Robin boundary condition to avoid
645 // extra computations as this factor is constant across all quadrature points.
646 // This normalization is done to ensure that the waveguide port with the
647 // highest amplitude is set to 1, and the other ports are scaled accordingly.
649 return;
650
651 const double max_port_electric_amplitude =
652 *std::ranges::max_element(waveguide_ports_relative_amplitudes);
653 for (double &amplitude : waveguide_ports_relative_amplitudes)
654 amplitude /= max_port_electric_amplitude;
655}
656
657template <int dim>
658std::pair<Tensor<1, dim, std::complex<double>>, std::complex<double>>
660 const Point<dim> &p,
661 const Tensor<1, dim> &normal,
662 const std::complex<double> &effective_electric_permittivity,
663 const std::complex<double> &effective_magnetic_permeability,
664 const unsigned int waveguide_port_index) const
665{
666 // The waveguide port excitation would be completely different in 2D as curls
667 // and cross products are not defined the same way as in 3D. Therefore, we do
668 // not implement it for now and throw an error if someone tries to use the 2D
669 // version.
670 if constexpr (dim != 3)
671 {
672 (void)p;
673 (void)normal;
674 (void)effective_electric_permittivity;
675 (void)effective_magnetic_permeability;
676 (void)waveguide_port_index;
677 AssertThrow(false, TimeHarmonicMaxwellDimensionNotSupported(dim));
678 return std::pair<Tensor<1, dim, std::complex<double>>,
679 std::complex<double>>();
680 }
681
682 static constexpr double PI = numbers::PI;
683 const auto incident_fields =
685 p,
686 normal,
687 effective_electric_permittivity,
688 effective_magnetic_permeability,
689 waveguide_port_index);
690
691 // Gather the relevant waveguide parameters
692 const double omega =
693 2.0 * PI * time_harmonic_maxwell_parameters.electromagnetic_frequency;
694 const auto &waveguide_corners =
695 time_harmonic_maxwell_parameters.waveguide_corners[waveguide_port_index];
696 const Parameters::WaveguideMode mode =
697 time_harmonic_maxwell_parameters.waveguide_mode[waveguide_port_index];
698 unsigned int m =
699 time_harmonic_maxwell_parameters.mode_order_m[waveguide_port_index];
700 unsigned int n =
701 time_harmonic_maxwell_parameters.mode_order_n[waveguide_port_index];
702
703 const double k_t1 = m * PI /
704 (waveguide_corners[1] - waveguide_corners[0])
705 .norm(); // Transverse wavenumber 1
706 const double k_t2 = n * PI /
707 (waveguide_corners[2] - waveguide_corners[0])
708 .norm(); // Transverse wavenumber 2
709 const std::complex<double> k_l =
710 std::sqrt(omega * omega * effective_electric_permittivity *
711 effective_magnetic_permeability -
712 (k_t1 * k_t1 + k_t2 * k_t2)); // Longitudinal wavenumber
713
714 std::complex<double> surface_admittance =
716 k_l / (omega * effective_magnetic_permeability) :
717 omega * effective_electric_permittivity / k_l;
718
719 const Tensor<1, dim, std::complex<double>> &E_inc = incident_fields.first;
720 const Tensor<1, dim, std::complex<double>> &H_inc = incident_fields.second;
721
722 const Tensor<1, dim, std::complex<double>> excitation =
723 waveguide_ports_relative_amplitudes[waveguide_port_index] *
724 (cross_product_3d(normal, H_inc) +
725 tangential_component(surface_admittance * E_inc, normal));
726
727 return std::make_pair(excitation, surface_admittance);
728}
729
730template <int dim>
731std::pair<Tensor<1, dim, std::complex<double>>, std::complex<double>>
733 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
734 const unsigned int q,
736 const unsigned int waveguide_port_index) const
737{
738 static constexpr std::complex<double> imag{0., 1.};
739
740 Tensor<1, dim, std::complex<double>> g_inc;
741 std::complex<double> boundary_surface_admittance;
742
743 const Point<dim> &position = scratch_data.face_quadrature_points[q];
744 const types::boundary_id face_id = scratch_data.face_boundary_id;
745
746 if (bc_type ==
748 {
749 boundary_surface_admittance =
750 std::sqrt(scratch_data.face_effective_electric_permittivities[q] /
752 g_inc = 0.;
753 }
754 if (bc_type ==
756 {
757 boundary_surface_admittance =
758 boundary_conditions.surface_admittance_real.at(face_id)->value(
759 position) +
760 imag * boundary_conditions.surface_admittance_imag.at(face_id)->value(
761 position);
762
763 // Get the incident electromagnetic field at this face. The excitation
764 // is only defined for 3D problems.
765 if constexpr (dim == 3)
766 {
767 g_inc[0] =
768 boundary_conditions.excitation_x_real.at(face_id)->value(position) +
769 imag * boundary_conditions.excitation_x_imag.at(face_id)->value(
770 position);
771
772 g_inc[1] =
773 boundary_conditions.excitation_y_real.at(face_id)->value(position) +
774 imag * boundary_conditions.excitation_y_imag.at(face_id)->value(
775 position);
776
777 g_inc[2] =
778 boundary_conditions.excitation_z_real.at(face_id)->value(position) +
779 imag * boundary_conditions.excitation_z_imag.at(face_id)->value(
780 position);
781 }
782 else
783 AssertThrow(false, TimeHarmonicMaxwellDimensionNotSupported(dim));
784 }
785 if (bc_type ==
787 {
788 std::tie(g_inc, boundary_surface_admittance) =
790 position,
791 scratch_data.face_normals[q],
794 waveguide_port_index);
795 }
796
797 return std::make_pair(g_inc, boundary_surface_admittance);
798}
799
800template <int dim>
801void
803 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
804 DPGCopyData &copy_data)
805{
806 if (!scratch_data.face_at_boundary)
807 return;
808
810 boundary_conditions.type.at(scratch_data.face_boundary_id);
811 if (!is_robin_boundary_type(bc_type))
812 return;
813
814 const unsigned int waveguide_port_index =
815 (bc_type ==
818 scratch_data.face_boundary_id) :
819 0;
820
821 using ScratchData = TimeHarmonicMaxwellScratchData<dim>;
822
823 const unsigned int n_face_q_points = scratch_data.n_face_q_points;
824
825 // Base functions of the test space associated with the face
826 const std::vector<unsigned int> &test_tangential_base_functions =
827 scratch_data.test_tangential_base_functions[scratch_data.face_no];
828 const unsigned int n_test_tangential_base_functions =
829 test_tangential_base_functions.size();
830
831 // Local dof indices of the real and imaginary parts of each base function:
832 // electric (F) and magnetic (I) test functions, and electric (E_hat)
833 // skeleton trial functions
834 const std::vector<unsigned int> &test_dofs_F_real =
835 scratch_data.test_local_dof_index_map[ScratchData::E_real];
836 const std::vector<unsigned int> &test_dofs_F_imag =
837 scratch_data.test_local_dof_index_map[ScratchData::E_imag];
838 const std::vector<unsigned int> &test_dofs_I_real =
839 scratch_data.test_local_dof_index_map[ScratchData::H_real];
840 const std::vector<unsigned int> &test_dofs_I_imag =
841 scratch_data.test_local_dof_index_map[ScratchData::H_imag];
842 const std::vector<unsigned int> &trial_dofs_E_hat_real =
843 scratch_data.trial_skeleton_local_dof_index_map[ScratchData::E_real];
844 const std::vector<unsigned int> &trial_dofs_E_hat_imag =
845 scratch_data.trial_skeleton_local_dof_index_map[ScratchData::E_imag];
846
847 const std::vector<double> &face_JxW = scratch_data.face_JxW;
848
849 LAPACKFullMatrix<double> &G_matrix = copy_data.G_matrix;
850 LAPACKFullMatrix<double> &B_hat_matrix = copy_data.B_hat_matrix;
851
852 // Surface admittance Y at the face quadrature points, multiplied by JxW:
853 // |Y|^2 JxW and Y JxW. It depends on the boundary condition, so it is
854 // computed here and not in the scratch data.
855 std::vector<double> YY_JxW_container(n_face_q_points);
856 std::vector<std::complex<double>> Y_JxW_container(n_face_q_points);
857 for (unsigned int q = 0; q < n_face_q_points; ++q)
858 {
859 const std::complex<double> boundary_surface_admittance =
860 compute_robin_boundary_data(scratch_data,
861 q,
862 bc_type,
863 waveguide_port_index)
864 .second;
865 YY_JxW_container[q] =
866 std::norm(boundary_surface_admittance) * face_JxW[q];
867 Y_JxW_container[q] = boundary_surface_admittance * face_JxW[q];
868 }
869
870 // Boundary terms of the Gram matrix G coming from the test norm on the Robin
871 // boundaries:
872 // (n x I + Y^* F_t, n x I + Y^* F_t)_{Gamma_R},
873 // where F_t = n x (F x n) is the tangential trace of F and the inner product
874 // is conjugated in its first argument. This term only involves the
875 // tangential traces of the test functions, which are in L^2(Gamma_R) for the
876 // test space. Since |n| = 1, F_t . F_t = (n x F) . (n x F), so for the test
877 // base functions i (rows) and j (columns), the blocks are:
878 // - FF: |Y|^2 <n x phi_i, n x phi_j>
879 // - II: <n x phi_i, n x phi_j>
880 // - FI: Y <phi_i, n x phi_j>
881 // - IF: since G is Hermitian, the block IF(j, i) is conj(FI(i, j)).
882 // As for the cell terms, we only loop over the pairs i <= j and add the
883 // blocks of the pair (j, i) at the same time.
884 for (unsigned int position_i = 0;
885 position_i < n_test_tangential_base_functions;
886 ++position_i)
887 {
888 const unsigned int i = test_tangential_base_functions[position_i];
889 const auto phi_i = scratch_data.phi_test_face[i];
890 const auto n_cross_phi_i = scratch_data.n_cross_phi_test_face[i];
891
892 for (unsigned int position_j = position_i;
893 position_j < n_test_tangential_base_functions;
894 ++position_j)
895 {
896 const unsigned int j = test_tangential_base_functions[position_j];
897 const auto phi_j = scratch_data.phi_test_face[j];
898 const auto n_cross_phi_j = scratch_data.n_cross_phi_test_face[j];
899
900 double z_FF = 0.;
901 double z_II = 0.;
902 std::complex<double> z_FI_ij(0.);
903 std::complex<double> z_FI_ji(0.);
904 for (unsigned int q = 0; q < n_face_q_points; ++q)
905 {
906 // The FF and II blocks share the dot product of the tangential
907 // traces
908 const double n_cross_i_n_cross_j =
909 n_cross_phi_i[q] * n_cross_phi_j[q];
910
911 z_FF += YY_JxW_container[q] * n_cross_i_n_cross_j;
912 z_II += face_JxW[q] * n_cross_i_n_cross_j;
913 z_FI_ij += Y_JxW_container[q] * (phi_i[q] * n_cross_phi_j[q]);
914 z_FI_ji += Y_JxW_container[q] * (phi_j[q] * n_cross_phi_i[q]);
915 }
916
917 // Blocks of the pair (i, j)
918 add_real_block(G_matrix,
919 test_dofs_F_real[i],
920 test_dofs_F_imag[i],
921 test_dofs_F_real[j],
922 test_dofs_F_imag[j],
923 z_FF);
924 add_real_block(G_matrix,
925 test_dofs_I_real[i],
926 test_dofs_I_imag[i],
927 test_dofs_I_real[j],
928 test_dofs_I_imag[j],
929 z_II);
930 add_complex_block(G_matrix,
931 test_dofs_F_real[i],
932 test_dofs_F_imag[i],
933 test_dofs_I_real[j],
934 test_dofs_I_imag[j],
935 z_FI_ij);
936 add_complex_block(G_matrix,
937 test_dofs_I_real[j],
938 test_dofs_I_imag[j],
939 test_dofs_F_real[i],
940 test_dofs_F_imag[i],
941 std::conj(z_FI_ij));
942
943 // Blocks of the pair (j, i), we skip the case i == j because the
944 // diagonal blocks are already filled by the pair (i, j)
945 if (j != i)
946 {
947 add_real_block(G_matrix,
948 test_dofs_F_real[j],
949 test_dofs_F_imag[j],
950 test_dofs_F_real[i],
951 test_dofs_F_imag[i],
952 z_FF);
953 add_real_block(G_matrix,
954 test_dofs_I_real[j],
955 test_dofs_I_imag[j],
956 test_dofs_I_real[i],
957 test_dofs_I_imag[i],
958 z_II);
959 add_complex_block(G_matrix,
960 test_dofs_F_real[j],
961 test_dofs_F_imag[j],
962 test_dofs_I_real[i],
963 test_dofs_I_imag[i],
964 z_FI_ji);
965 add_complex_block(G_matrix,
966 test_dofs_I_real[i],
967 test_dofs_I_imag[i],
968 test_dofs_F_real[j],
969 test_dofs_F_imag[j],
970 std::conj(z_FI_ji));
971 }
972 }
973 }
974
975 // Robin term of the skeleton bilinear form B_hat, which replaces the
976 // magnetic trace term. For the test base function i (rows) and the skeleton
977 // trial base function j (columns), the FE_hat block is
978 // -Y < phi_i, n x (e_hat_j x n) >. It only involves the tangential trace of
979 // the test functions, so only the base functions associated with the face
980 // contribute.
981 for (const unsigned int i : test_tangential_base_functions)
982 {
983 const auto phi_i = scratch_data.phi_test_face[i];
984
985 for (const unsigned int j :
986 scratch_data
987 .trial_skeleton_tangential_base_functions[scratch_data.face_no])
988 {
989 const auto tangential_phi_j =
990 scratch_data.tangential_phi_trial_skeleton[j];
991
992 std::complex<double> z_FE(0.);
993 for (unsigned int q = 0; q < n_face_q_points; ++q)
994 z_FE -= Y_JxW_container[q] * (phi_i[q] * tangential_phi_j[q]);
995
996 add_complex_block(B_hat_matrix,
997 test_dofs_F_real[i],
998 test_dofs_F_imag[i],
999 trial_dofs_E_hat_real[j],
1000 trial_dofs_E_hat_imag[j],
1001 z_FE);
1002 }
1003 }
1004}
1005
1006template <int dim>
1007void
1009 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
1010 DPGCopyData &copy_data)
1011{
1012 if (!scratch_data.face_at_boundary)
1013 return;
1014
1016 boundary_conditions.type.at(scratch_data.face_boundary_id);
1017 if (!is_robin_boundary_type(bc_type))
1018 return;
1019
1020 const unsigned int waveguide_port_index =
1021 (bc_type ==
1024 scratch_data.face_boundary_id) :
1025 0;
1026
1027 using ScratchData = TimeHarmonicMaxwellScratchData<dim>;
1028
1029 const unsigned int n_face_q_points = scratch_data.n_face_q_points;
1030
1031 // Local dof indices of the real and imaginary parts of each base function of
1032 // the electric test functions (F)
1033 const std::vector<unsigned int> &test_dofs_F_real =
1034 scratch_data.test_local_dof_index_map[ScratchData::E_real];
1035 const std::vector<unsigned int> &test_dofs_F_imag =
1036 scratch_data.test_local_dof_index_map[ScratchData::E_imag];
1037
1038 Vector<double> &l_vector = copy_data.l_vector;
1039
1040 // Tangential component of the excitation g at the face quadrature points,
1041 // multiplied by JxW. The left-hand side of the Robin boundary condition
1042 // n x H + Y n x (E x n) = g is tangential to the boundary, so only the
1043 // tangential component of g is meaningful. It is also the only component
1044 // for which -<F, g> is bounded on the test space, which only controls the
1045 // tangential trace of F on the Robin boundaries.
1046 std::vector<Tensor<1, dim, std::complex<double>>> g_inc_JxW_container(
1047 n_face_q_points);
1048 for (unsigned int q = 0; q < n_face_q_points; ++q)
1049 g_inc_JxW_container[q] =
1051 scratch_data, q, bc_type, waveguide_port_index)
1052 .first,
1053 scratch_data.face_normals[q]) *
1054 scratch_data.face_JxW[q];
1055
1056 // Excitation term -<F,g>. For the test base function i, the entries of the
1057 // real and imaginary parts of the electric test function are the real and
1058 // imaginary parts of w = <phi_i, g>, since Re(w conj(s)) is Re(w) for s = 1
1059 // and Im(w) for s equal to the imaginary unit.
1060 for (const unsigned int i :
1061 scratch_data.test_tangential_base_functions[scratch_data.face_no])
1062 {
1063 const auto phi_i = scratch_data.phi_test_face[i];
1064
1065 std::complex<double> w(0.);
1066 for (unsigned int q = 0; q < n_face_q_points; ++q)
1067 w += g_inc_JxW_container[q] * phi_i[q];
1068
1069 l_vector[test_dofs_F_real[i]] -= w.real();
1070 l_vector[test_dofs_F_imag[i]] -= w.imag();
1071 }
1072}
1073
1074
1075template std::pair<Tensor<1, 2, std::complex<double>>,
1076 Tensor<1, 2, std::complex<double>>>
1078 const Parameters::TimeHarmonicMaxwell<2> &time_harmonic_maxwell_parameters,
1079 const Point<2> &p,
1080 const Tensor<1, 2> &normal,
1081 const std::complex<double> &effective_electric_permittivity,
1082 const std::complex<double> &effective_magnetic_permeability,
1083 const unsigned int waveguide_port_index);
1084template std::pair<Tensor<1, 3, std::complex<double>>,
1085 Tensor<1, 3, std::complex<double>>>
1087 const Parameters::TimeHarmonicMaxwell<3> &time_harmonic_maxwell_parameters,
1088 const Point<3> &p,
1089 const Tensor<1, 3> &normal,
1090 const std::complex<double> &effective_electric_permittivity,
1091 const std::complex<double> &effective_magnetic_permeability,
1092 const unsigned int waveguide_port_index);
1093
1094template unsigned int
1096 const Parameters::TimeHarmonicMaxwell<2> &time_harmonic_maxwell_parameters,
1097 const types::boundary_id boundary_id);
1098template unsigned int
1100 const Parameters::TimeHarmonicMaxwell<3> &time_harmonic_maxwell_parameters,
1101 const types::boundary_id boundary_id);
1102
This class manages the boundary conditions for Time Harmonic Maxwell solver. It introduces the bounda...
Class responsible for storing the local system of an ultraweak Discontinuous Petrov-Galerkin (DPG) di...
Definition copy_data.h:232
Vector< double > l_vector
Definition copy_data.h:300
LAPACKFullMatrix< double > B_hat_matrix
Definition copy_data.h:298
LAPACKFullMatrix< double > G_matrix
Definition copy_data.h:294
LAPACKFullMatrix< double > B_matrix
Definition copy_data.h:296
Class that assembles the cell terms of the ultraweak DPG formulation of the time-harmonic Maxwell equ...
void assemble_matrix(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData &copy_data) override
Assemble the Gram matrix and the interior bilinear form.
void assemble_rhs(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData &copy_data) override
Assemble the interior load vector, which is zero since no volume source term is considered at the mom...
TimeHarmonicMaxwellAssemblerCore(const Parameters::TimeHarmonicMaxwell< dim > &time_harmonic_maxwell_parameters)
Constructor.
Class that assembles the Robin boundary conditions of the time-harmonic Maxwell equations (silver_mul...
void assemble_rhs(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData &copy_data) override
Assemble the excitation of the Robin boundary conditions in the load vector.
std::pair< Tensor< 1, dim, std::complex< double > >, std::complex< double > > compute_waveguide_port_excitation(const Point< dim > &p, const Tensor< 1, dim > &normal, const std::complex< double > &effective_electric_permittivity, const std::complex< double > &effective_magnetic_permeability, const unsigned int waveguide_port_index) const
Compute the excitation and the surface admittance of the Robin boundary condition of a rectangular wa...
TimeHarmonicMaxwellAssemblerRobinBC(const Parameters::TimeHarmonicMaxwell< dim > &time_harmonic_maxwell_parameters, const BoundaryConditions::TimeHarmonicMaxwellBoundaryConditions< dim > &boundary_conditions, const std::vector< double > &waveguide_ports_electric_amplitudes)
Constructor.
void assemble_matrix(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData &copy_data) override
Assemble the Robin boundary terms of the Gram matrix and of the skeleton bilinear form.
const Parameters::TimeHarmonicMaxwell< dim > & time_harmonic_maxwell_parameters
const BoundaryConditions::TimeHarmonicMaxwellBoundaryConditions< dim > & boundary_conditions
std::pair< Tensor< 1, dim, std::complex< double > >, std::complex< double > > compute_robin_boundary_data(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, const unsigned int q, const BoundaryConditions::TimeHarmonicMaxwellBoundaryType bc_type, const unsigned int waveguide_port_index) const
Compute the excitation and the surface admittance of the Robin boundary condition at a quadrature poi...
Class that assembles the skeleton terms of the ultraweak DPG formulation of the time-harmonic Maxwell...
void assemble_matrix(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData &copy_data) override
Assemble the skeleton terms of the bilinear form.
void assemble_rhs(const TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData &copy_data) override
There is no skeleton term in the load vector, since the boundary data is imposed through the constrai...
const BoundaryConditions::TimeHarmonicMaxwellBoundaryConditions< dim > & boundary_conditions
Class that stores the information required by the assembly of the Discontinuous Petrov-Galerkin (DPG)...
std::vector< std::complex< double > > face_effective_electric_permittivities
Table< 2, Tensor< 1, dim > > tangential_phi_trial_skeleton
std::array< std::vector< unsigned int >, n_electromagnetic_fields > trial_skeleton_local_dof_index_map
Table< 2, Tensor< 1, dim > > n_cross_tangential_phi_trial_skeleton
std::array< std::vector< unsigned int >, n_electromagnetic_fields > trial_interior_local_dof_index_map
std::vector< std::complex< double > > iwmu_JxW_container
std::array< std::vector< unsigned int >, n_electromagnetic_fields > test_local_dof_index_map
std::vector< std::complex< double > > face_effective_magnetic_permeabilities
std::vector< std::complex< double > > iweps_JxW_container
std::vector< std::vector< unsigned int > > test_tangential_base_functions
TimeHarmonicMaxwellBoundaryType
Boundary condition types of the time-harmonic Maxwell equations.
WaveguideMode
Types of waveguide port modes:
@ TE
Transverse Electric mode.
@ TM
Transverse Magnetic mode.
TimeHarmonicMaxwell - Defines the parameters for time-harmonic Maxwell simulations.
std::vector< unsigned int > mode_order_n
std::vector< std::array< Tensor< 1, dim >, Utilities::fixed_power< 2 >(dim - 1)> > waveguide_corners
std::vector< Parameters::WaveguideMode > waveguide_mode
std::vector< unsigned int > mode_order_m
DEAL_II_ALWAYS_INLINE Tensor< 1, dim, Number > tangential_component(const Tensor< 1, dim, Number > &tensor, const Tensor< 1, dim > &normal)
Compute the tangential component of a vector on a surface defined by its unit normal vector,...
std::pair< Tensor< 1, dim, std::complex< double > >, Tensor< 1, dim, std::complex< double > > > compute_waveguide_port_incident_fields(const Parameters::TimeHarmonicMaxwell< dim > &time_harmonic_maxwell_parameters, const Point< dim > &p, const Tensor< 1, dim > &normal, const std::complex< double > &effective_electric_permittivity, const std::complex< double > &effective_magnetic_permeability, const unsigned int waveguide_port_index)
Compute the incident electromagnetic fields of a rectangular waveguide port from the input parameters...
template unsigned int get_waveguide_port_index< 2 >(const Parameters::TimeHarmonicMaxwell< 2 > &time_harmonic_maxwell_parameters, const types::boundary_id boundary_id)
template unsigned int get_waveguide_port_index< 3 >(const Parameters::TimeHarmonicMaxwell< 3 > &time_harmonic_maxwell_parameters, const types::boundary_id boundary_id)
template std::pair< Tensor< 1, 2, std::complex< double > >, Tensor< 1, 2, std::complex< double > > > compute_waveguide_port_incident_fields< 2 >(const Parameters::TimeHarmonicMaxwell< 2 > &time_harmonic_maxwell_parameters, const Point< 2 > &p, const Tensor< 1, 2 > &normal, const std::complex< double > &effective_electric_permittivity, const std::complex< double > &effective_magnetic_permeability, const unsigned int waveguide_port_index)
template std::pair< Tensor< 1, 3, std::complex< double > >, Tensor< 1, 3, std::complex< double > > > compute_waveguide_port_incident_fields< 3 >(const Parameters::TimeHarmonicMaxwell< 3 > &time_harmonic_maxwell_parameters, const Point< 3 > &p, const Tensor< 1, 3 > &normal, const std::complex< double > &effective_electric_permittivity, const std::complex< double > &effective_magnetic_permeability, const unsigned int waveguide_port_index)
unsigned int get_waveguide_port_index(const Parameters::TimeHarmonicMaxwell< dim > &time_harmonic_maxwell_parameters, const types::boundary_id boundary_id)
Get the index of the waveguide port condition applied on a boundary, that is the index of the wavegui...
bool is_robin_boundary_type(const BoundaryConditions::TimeHarmonicMaxwellBoundaryType type)
Check if a boundary condition type of the time-harmonic Maxwell equations is a Robin boundary conditi...