Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
time_harmonic_maxwell_assemblers.h
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
4#ifndef lethe_time_harmonic_maxwell_assemblers_h
5#define lethe_time_harmonic_maxwell_assemblers_h
6
9
10#include <solvers/copy_data.h>
13
14#include <deal.II/base/point.h>
15#include <deal.II/base/tensor.h>
16#include <deal.II/base/types.h>
17
18#include <complex>
19#include <utility>
20#include <vector>
21
22/**
23 * @brief A pure virtual class that serves as an interface for all the cell
24 * assemblers of the time-harmonic Maxwell equations.
25 *
26 * @tparam dim An integer that denotes the number of spatial dimensions
27 *
28 * @ingroup assemblers
29 */
30template <int dim>
33
34/**
35 * @brief A pure virtual class that serves as an interface for all the face
36 * assemblers of the time-harmonic Maxwell equations.
37 *
38 * @tparam dim An integer that denotes the number of spatial dimensions
39 *
40 * @ingroup assemblers
41 */
42template <int dim>
45
46/**
47 * @brief Check if a boundary condition type of the time-harmonic Maxwell
48 * equations is a Robin boundary condition, which is applied weakly through the
49 * assembly.
50 *
51 * @param[in] type Boundary condition type.
52 *
53 * @return True for the silver_muller, impedance_boundary and waveguide_port
54 * boundary conditions.
55 */
56inline bool
59{
60 return (type ==
62 (type == BoundaryConditions::TimeHarmonicMaxwellBoundaryType::
63 impedance_boundary) ||
64 (type ==
66}
67
68/**
69 * @brief Compute the incident electromagnetic fields of a rectangular
70 * waveguide port from the input parameters. It is only implemented for 3D
71 * problems.
72 *
73 * @tparam dim Spatial dimension.
74 *
75 * @param[in] time_harmonic_maxwell_parameters Parameters of the time-harmonic
76 * Maxwell physics, which contain the waveguide port definitions.
77 *
78 * @param[in] p Position where the incident fields are computed.
79 *
80 * @param[in] normal Unit normal vector of the waveguide port face.
81 *
82 * @param[in] effective_electric_permittivity Effective electric permittivity
83 * at the point p.
84 *
85 * @param[in] effective_magnetic_permeability Effective magnetic permeability
86 * at the point p.
87 *
88 * @param[in] waveguide_port_index Index of the waveguide port condition within
89 * the waveguide port parameters.
90 *
91 * @return This function returns a std::pair containing the electric field
92 * Tensor<1, dim, std::complex<double>> and the magnetic field Tensor<1, dim,
93 * std::complex<double>> computed at the given position.
94 */
95template <int dim>
96std::pair<Tensor<1, dim, std::complex<double>>,
97 Tensor<1, dim, std::complex<double>>>
99 const Parameters::TimeHarmonicMaxwell<dim> &time_harmonic_maxwell_parameters,
100 const Point<dim> &p,
101 const Tensor<1, dim> &normal,
102 const std::complex<double> &effective_electric_permittivity,
103 const std::complex<double> &effective_magnetic_permeability,
104 const unsigned int waveguide_port_index);
105
106/**
107 * @brief Get the index of the waveguide port condition applied on a boundary,
108 * that is the index of the waveguide inlet whose port boundary id is this
109 * boundary id.
110 *
111 * @tparam dim Spatial dimension.
112 *
113 * @param[in] time_harmonic_maxwell_parameters Parameters of the time-harmonic
114 * Maxwell physics, which contain the waveguide port definitions.
115 *
116 * @param[in] boundary_id Boundary id of a boundary with a waveguide port
117 * condition.
118 *
119 * @return Index of the waveguide port condition.
120 */
121template <int dim>
122unsigned int
124 const Parameters::TimeHarmonicMaxwell<dim> &time_harmonic_maxwell_parameters,
125 const types::boundary_id boundary_id);
126
127/**
128 * @brief Class that assembles the cell terms of the ultraweak DPG formulation
129 * of the time-harmonic Maxwell equations. With the test functions
130 * \f$\mathbf{F}\f$ (electric) and \f$\mathbf{I}\f$ (magnetic), it assembles:
131 *
132 * - the graph norm of the test space in the Gram matrix \f$G\f$:
133 * \f$(\mathbf{F}, \mathbf{F}) + (\nabla \times \mathbf{F}, \nabla \times
134 * \mathbf{F}) + (i\omega\varepsilon \mathbf{F}, i\omega\varepsilon
135 * \mathbf{F})\f$ and the equivalent terms coupling \f$\mathbf{F}\f$ and
136 * \f$\mathbf{I}\f$ and for \f$\mathbf{I}\f$ alone;
137 *
138 * - the interior bilinear form in the matrix \f$B\f$:
139 * \f$(i\omega\varepsilon \mathbf{E}, \mathbf{F}) + (\mathbf{H}, \nabla
140 * \times \mathbf{F}) + (\mathbf{E}, \nabla \times \mathbf{I}) -
141 * (i\omega\mu \mathbf{H}, \mathbf{I})\f$;
142 *
143 * - the interior load vector \f$l\f$, which is zero since no volume source
144 * term is considered at the moment.
145 *
146 * @tparam dim An integer that denotes the number of spatial dimensions
147 *
148 * @ingroup assemblers
149 */
150template <int dim>
153{
154public:
155 /**
156 * @brief Constructor.
157 *
158 * @param[in] time_harmonic_maxwell_parameters Parameters of the
159 * time-harmonic Maxwell physics. They are not used for now, but they will be
160 * needed by the volume source terms.
161 */
163 &time_harmonic_maxwell_parameters);
164
165 /**
166 * @brief Assemble the Gram matrix and the interior bilinear form.
167 *
168 * @param[in] scratch_data (see base class)
169 *
170 * @param[in,out] copy_data (see base class)
171 */
172 void
174 DPGCopyData &copy_data) override;
175
176 /**
177 * @brief Assemble the interior load vector, which is zero since no volume
178 * source term is considered at the moment.
179 *
180 * @param[in] scratch_data (see base class)
181 *
182 * @param[in,out] copy_data (see base class)
183 */
184 void
186 DPGCopyData &copy_data) override;
187};
188
189
190/**
191 * @brief Class that assembles the skeleton terms of the ultraweak DPG
192 * formulation of the time-harmonic Maxwell equations. On every face, it
193 * assembles \f$\langle \mathbf{n} \times \hat{\mathbf{E}}, \mathbf{I}
194 * \rangle\f$ in the matrix \f$\hat{B}\f$ and, except on the faces where a
195 * Robin boundary condition is applied, it assembles
196 * \f$\langle \mathbf{n} \times \hat{\mathbf{H}}, \mathbf{F} \rangle\f$. On
197 * Robin faces, the latter term is replaced by the Robin boundary condition
198 * (see TimeHarmonicMaxwellAssemblerRobinBC).
199 *
200 * @tparam dim An integer that denotes the number of spatial dimensions
201 *
202 * @ingroup assemblers
203 */
204template <int dim>
207{
208public:
209 /**
210 * @brief Constructor.
211 *
212 * @param[in] boundary_conditions Boundary conditions of the time-harmonic
213 * Maxwell physics, used to identify the Robin faces.
214 */
220
221 /**
222 * @brief Assemble the skeleton terms of the bilinear form.
223 *
224 * @param[in] scratch_data (see base class)
225 *
226 * @param[in,out] copy_data (see base class)
227 */
228 void
230 DPGCopyData &copy_data) override;
231
232 /**
233 * @brief There is no skeleton term in the load vector, since the boundary
234 * data is imposed through the constraints or by
235 * TimeHarmonicMaxwellAssemblerRobinBC.
236 *
237 * @param[in] scratch_data (see base class)
238 *
239 * @param[in,out] copy_data (see base class)
240 */
241 void
243 DPGCopyData &copy_data) override;
244
245private:
246 /**
247 * Boundary conditions of the time-harmonic Maxwell physics.
248 */
251};
252
253
254/**
255 * @brief Class that assembles the Robin boundary conditions of the
256 * time-harmonic Maxwell equations (silver_muller, impedance_boundary and
257 * waveguide_port). On these faces, the magnetic trace is expressed from the
258 * electric trace with the surface admittance \f$Y\f$ and the excitation
259 * \f$\mathbf{g}\f$, which gives the terms
260 * \f$-\langle Y \hat{\mathbf{E}}, \mathbf{F} \rangle\f$ in \f$\hat{B}\f$ and
261 * \f$-\langle \mathbf{g}, \mathbf{F} \rangle\f$ in \f$l\f$, where only the
262 * tangential component of \f$\mathbf{g}\f$ is used since the left-hand side
263 * of the Robin boundary condition is tangential. Since the energy
264 * norm that is minimized is also modified on these faces, it also assembles
265 * the boundary terms of the Gram matrix
266 * \f$G\f$:
267 * \f[\left(\mathbf{n}\times\mathbf{I}+Y^*\mathbf{n}\times(\mathbf{F}\times\mathbf{n}),
268\mathbf{n}\times\tilde{\mathbf{I}}+Y^*\mathbf{n}\times(\tilde{\mathbf{F}}\times\mathbf{n})\right)_{\Gamma_R},\f]
269 * where \f$Y^*\f$ is the complex conjugate of \f$Y\f$ and the inner product
270 * is conjugated in its first argument. Again, this term only involves the
271 * tangential traces of the test functions.
272 *
273 * @tparam dim An integer that denotes the number of spatial dimensions
274 *
275 * @ingroup assemblers
276 */
277template <int dim>
280{
281public:
282 /**
283 * @brief Constructor.
284 *
285 * @param[in] time_harmonic_maxwell_parameters Parameters of the
286 * time-harmonic Maxwell physics, which contain the waveguide port
287 * definitions.
288 *
289 * @param[in] boundary_conditions Boundary conditions of the time-harmonic
290 * Maxwell physics.
291 *
292 * @param[in] waveguide_ports_electric_amplitudes Electric field amplitudes of
293 * all the waveguide ports. They are normalized by their maximum
294 * to get the relative amplitudes of the ports during initialization.
295 */
301 const std::vector<double> &waveguide_ports_electric_amplitudes);
302
303 /**
304 * @brief Assemble the Robin boundary terms of the Gram matrix and of the
305 * skeleton bilinear form.
306 *
307 * @param[in] scratch_data (see base class)
308 *
309 * @param[in,out] copy_data (see base class)
310 */
311 void
313 DPGCopyData &copy_data) override;
314
315 /**
316 * @brief Assemble the excitation of the Robin boundary conditions in the
317 * load vector.
318 *
319 * @param[in] scratch_data (see base class)
320 *
321 * @param[in,out] copy_data (see base class)
322 */
323 void
325 DPGCopyData &copy_data) override;
326
327private:
328 /**
329 * @brief Compute the excitation and the surface admittance of the Robin
330 * boundary condition at a quadrature point of the current face.
331 *
332 * @param[in] scratch_data Scratch data reinitialized on the current face.
333 *
334 * @param[in] q Index of the face quadrature point.
335 *
336 * @param[in] bc_type Type of the Robin boundary condition of the face.
337 *
338 * @param[in] waveguide_port_index Index of the waveguide port condition of
339 * the face. Only used if bc_type is waveguide_port.
340 *
341 * @return A pair containing the excitation and the surface admittance.
342 */
343 std::pair<Tensor<1, dim, std::complex<double>>, std::complex<double>>
345 const TimeHarmonicMaxwellScratchData<dim> &scratch_data,
346 const unsigned int q,
348 const unsigned int waveguide_port_index) const;
349
350 /**
351 * @brief Compute the excitation and the surface admittance of the Robin
352 * boundary condition of a rectangular waveguide port from the input
353 * parameters. The excitation used is the normalized one across all the
354 * waveguide ports. This function is only implemented for 3D problems.
355 *
356 * @param[in] p Position where the excitation is computed.
357 *
358 * @param[in] normal Unit normal vector of the waveguide port face.
359 *
360 * @param[in] effective_electric_permittivity Effective electric permittivity
361 * at the point p.
362 *
363 * @param[in] effective_magnetic_permeability Effective magnetic permeability
364 * at the point p.
365 *
366 * @param[in] waveguide_port_index Index of the waveguide port condition
367 * within the waveguide port parameters.
368 *
369 * @return A pair containing the excitation of the Robin boundary condition
370 * and the surface admittance at the point p. The excitation is scaled by the
371 * ratio of the port amplitude to the maximum amplitude of all the ports.
372 */
373 std::pair<Tensor<1, dim, std::complex<double>>, std::complex<double>>
375 const Point<dim> &p,
376 const Tensor<1, dim> &normal,
377 const std::complex<double> &effective_electric_permittivity,
378 const std::complex<double> &effective_magnetic_permeability,
379 const unsigned int waveguide_port_index) const;
380
381 /**
382 * Parameters of the time-harmonic Maxwell physics.
383 */
385
386 /**
387 * Boundary conditions of the time-harmonic Maxwell physics.
388 */
391
392 /**
393 * Relative amplitudes of all the waveguide ports, that is the electric field
394 * amplitude of each port divided by the maximum amplitude of all the ports.
395 */
397};
398
399#endif
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
Base class for assembler objects of physics and subequations.
Base class for assembler objects of physics and subequations that require a face assembly....
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.
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...
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...
TimeHarmonicMaxwellAssemblerSkeleton(const BoundaryConditions::TimeHarmonicMaxwellBoundaryConditions< dim > &boundary_conditions)
Constructor.
const BoundaryConditions::TimeHarmonicMaxwellBoundaryConditions< dim > & boundary_conditions
Class that stores the information required by the assembly of the Discontinuous Petrov-Galerkin (DPG)...
TimeHarmonicMaxwellBoundaryType
Boundary condition types of the time-harmonic Maxwell equations.
TimeHarmonicMaxwell - Defines the parameters for time-harmonic Maxwell simulations.
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...
PhysicsAssemblerBase< TimeHarmonicMaxwellScratchData< dim >, DPGCopyData > TimeHarmonicMaxwellAssemblerBase
A pure virtual class that serves as an interface for all the cell assemblers of the time-harmonic Max...
PhysicsFaceAssemblerBase< TimeHarmonicMaxwellScratchData< dim >, DPGCopyData > TimeHarmonicMaxwellFaceAssemblerBase
A pure virtual class that serves as an interface for all the face assemblers of the time-harmonic Max...
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...
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...