9#include <deal.II/base/exceptions.h>
17 const std::map<
field, std::vector<double>> &field_values_vectors,
18 const unsigned int material_id,
19 std::vector<std::complex<double>> &effective_electric_permittivities,
20 std::vector<std::complex<double>> &effective_magnetic_permeabilities)
22 const unsigned int n_q_points =
27 std::vector<double> permittivity_real(n_q_points);
28 std::vector<double> permittivity_imag(n_q_points);
29 std::vector<double> conductivity(n_q_points);
30 std::vector<double> permeability_real(n_q_points);
31 std::vector<double> permeability_imag(n_q_points);
41 const unsigned int material_interaction_id =
45 physical_properties_manager
47 ->vector_value(field_values_vectors, permittivity_real);
48 physical_properties_manager
50 ->vector_value(field_values_vectors, permittivity_imag);
51 physical_properties_manager
53 ->vector_value(field_values_vectors, permeability_real);
54 physical_properties_manager
56 ->vector_value(field_values_vectors, permeability_imag);
64 physical_properties_manager
66 ->vector_value(field_values_vectors, permittivity_real);
67 physical_properties_manager
69 ->vector_value(field_values_vectors, permittivity_imag);
71 ->vector_value(field_values_vectors, conductivity);
72 physical_properties_manager
74 ->vector_value(field_values_vectors, permeability_real);
75 physical_properties_manager
77 ->vector_value(field_values_vectors, permeability_imag);
83 effective_electric_permittivities.resize(n_q_points);
84 effective_magnetic_permeabilities.resize(n_q_points);
86 for (
unsigned int q = 0; q < n_q_points; ++q)
88 effective_electric_permittivities[q] = {permittivity_real[q],
89 permittivity_imag[q] +
91 effective_magnetic_permeabilities[q] = {permeability_real[q],
92 permeability_imag[q]};
99 const unsigned int material_id,
100 const field field_id)
108 const unsigned int material_interaction_id =
112 return physical_properties_manager
114 material_interaction_id)
115 ->depends_on(field_id) ||
116 physical_properties_manager
118 material_interaction_id)
119 ->depends_on(field_id) ||
120 physical_properties_manager
122 material_interaction_id)
123 ->depends_on(field_id) ||
124 physical_properties_manager
126 material_interaction_id)
127 ->depends_on(field_id);
131 ->depends_on(field_id) ||
132 physical_properties_manager
134 ->depends_on(field_id) ||
135 physical_properties_manager
137 ->depends_on(field_id) ||
138 physical_properties_manager
140 ->depends_on(field_id) ||
141 physical_properties_manager
143 ->depends_on(field_id);
150 const FiniteElement<dim> &fe_test = this->
fe_values_test.get_fe();
151 const FiniteElement<dim> &fe_trial_interior =
153 const FiniteElement<dim> &fe_trial_skeleton =
198 std::vector<std::complex<double>>(
n_q_points);
200 std::vector<std::complex<double>>(
n_q_points);
249 const FiniteElement<dim> &fe,
251 &local_dof_index_map)
const
257 const unsigned int n_base_functions =
262 const std::array<FEValuesExtractors::Vector, n_electromagnetic_fields>
269 for (
auto &field_local_dof_indices : local_dof_index_map)
270 field_local_dof_indices.assign(n_base_functions,
271 numbers::invalid_unsigned_int);
277 for (
unsigned int k = 0; k < fe.n_dofs_per_cell(); ++k)
281 unsigned int field_index = numbers::invalid_unsigned_int;
282 unsigned int n_owner_fields = 0;
283 for (
unsigned int candidate_field = 0;
286 if (fe.shape_function_belongs_to(k, field_extractors[candidate_field]))
288 field_index = candidate_field;
291 Assert(n_owner_fields == 1,
292 ExcMessage(
"The shape function " + std::to_string(k) +
293 " of the finite element " + fe.get_name() +
294 " does not belong to exactly one of the E_real, "
295 "E_imag, H_real and H_imag fields."));
309 const auto &base_index = fe.system_to_base_index(k);
310 const unsigned int base_element = base_index.first.first;
311 const unsigned int field_component = base_index.first.second;
312 const unsigned int index_in_base_element = base_index.second;
313 const unsigned int n_dofs_base_element =
314 fe.base_element(base_element).n_dofs_per_cell();
315 const unsigned int base_function =
316 field_component * n_dofs_base_element + index_in_base_element;
322 AssertThrow(base_function < n_base_functions &&
323 local_dof_index_map[field_index][base_function] ==
324 numbers::invalid_unsigned_int,
326 "The four fields of the finite element " + fe.get_name() +
327 " do not use the same base element. The time-harmonic "
328 "Maxwell solver requires the E_real, E_imag, H_real and "
329 "H_imag fields to be discretized with the same finite "
332 local_dof_index_map[field_index][base_function] = k;
339 const FiniteElement<dim> &fe,
341 &local_dof_index_map,
342 std::vector<std::vector<unsigned int>> &tangential_base_functions)
const
346 std::vector<unsigned int> base_function_of_dof(fe.n_dofs_per_cell(),
347 numbers::invalid_unsigned_int);
348 for (
const auto &field_local_dof_indices : local_dof_index_map)
349 for (
unsigned int i = 0; i < field_local_dof_indices.size(); ++i)
350 base_function_of_dof[field_local_dof_indices[i]] = i;
352 const unsigned int n_faces = fe.reference_cell().n_faces();
353 tangential_base_functions.assign(n_faces, std::vector<unsigned int>());
355 for (
unsigned int face = 0; face < n_faces; ++face)
361 tangential_base_functions[face].reserve(fe.n_dofs_per_face(face));
362 for (
unsigned int i = 0; i < fe.n_dofs_per_face(face); ++i)
363 tangential_base_functions[face].emplace_back(
364 base_function_of_dof[fe.face_to_cell_index(i, face)]);
366 std::ranges::sort(tangential_base_functions[face]);
367 const auto duplicates =
368 std::ranges::unique(tangential_base_functions[face]);
369 tangential_base_functions[face].erase(duplicates.begin(),
377 const FiniteElement<dim> &fe_temperature,
378 const Quadrature<dim> &cell_quadrature,
379 const Quadrature<dim - 1> &face_quadrature,
380 const Mapping<dim> &mapping)
384 std::make_shared<FEValues<dim>>(mapping,
387 update_values | update_quadrature_points);
389 std::make_shared<FEFaceValues<dim>>(mapping,
393 update_quadrature_points);
399 const FiniteElement<dim> &fe_void_fraction,
400 const Quadrature<dim> &cell_quadrature,
401 const Quadrature<dim - 1> &face_quadrature,
402 const Mapping<dim> &mapping)
406 std::make_shared<FEValues<dim>>(mapping,
409 update_values | update_quadrature_points);
411 std::make_shared<FEFaceValues<dim>>(mapping,
415 update_quadrature_points);
421 const typename DoFHandler<dim>::active_cell_iterator &cell,
422 const typename DoFHandler<dim>::active_cell_iterator &cell_test)
427 if constexpr (dim != 3)
431 AssertThrow(
false, TimeHarmonicMaxwellDimensionNotSupported(dim));
475 const unsigned int k =
487 const typename DoFHandler<dim>::active_cell_iterator &cell_skeleton,
488 const typename DoFHandler<dim>::active_cell_iterator &cell_test,
491 if constexpr (dim != 3)
496 AssertThrow(
false, TimeHarmonicMaxwellDimensionNotSupported(dim));
500 const auto face = cell_skeleton->face(
face_no);
504 face->boundary_id() :
505 numbers::invalid_boundary_id;
540 for (
const unsigned int j :
543 const unsigned int k =
578 static constexpr std::complex<double> imag{0., 1.};
582 const std::complex<double> iweps =
584 const std::complex<double> iwmu =
Class that manages the physical properties model which are required to calculate the various physical...
std::shared_ptr< ElectricPermittivityModel > get_electric_permittivity_real(const unsigned int fluid_id=0, const unsigned int material_id=0) const
Returns the electric permittivity model of the real part for a given fluid_id and material_id.
std::shared_ptr< ElectricConductivityModel > get_electric_conductivity(const unsigned int fluid_id=0, const unsigned int material_id=0) const
Returns the electric conductivity model for a given fluid_id and material_id.
std::shared_ptr< MagneticPermeabilityModel > get_magnetic_permeability_real(const unsigned int fluid_id=0, const unsigned int material_id=0) const
Returns the magnetic permeability model of the real part for a given fluid_id and material_id.
bool is_effective_medium(const unsigned int fluid_id, const unsigned int material_id) const
Returns true if the material with the given fluid_id and material_id is defined by an effective mediu...
std::shared_ptr< EffectiveMediumModel > get_effective_electric_permittivity_imag(const unsigned int material_interaction_id) const
Returns the effective medium model of the imaginary part of the electric permittivity of the mixture ...
std::shared_ptr< EffectiveMediumModel > get_effective_magnetic_permeability_imag(const unsigned int material_interaction_id) const
Returns the effective medium model of the imaginary part of the magnetic permeability of the mixture ...
std::shared_ptr< EffectiveMediumModel > get_effective_magnetic_permeability_real(const unsigned int material_interaction_id) const
Returns the effective medium model of the real part of the magnetic permeability of the mixture defin...
std::shared_ptr< EffectiveMediumModel > get_effective_electric_permittivity_real(const unsigned int material_interaction_id) const
Returns the effective medium model of the real part of the electric permittivity of the mixture defin...
std::shared_ptr< ElectricPermittivityModel > get_electric_permittivity_imag(const unsigned int fluid_id=0, const unsigned int material_id=0) const
Returns the electric permittivity model of the imaginary part for a given fluid_id and material_id.
unsigned int get_material_interaction_id(const material_interactions_type material_interaction_type, const unsigned int material_0_id, const unsigned int material_1_id) const
std::shared_ptr< MagneticPermeabilityModel > get_magnetic_permeability_imag(const unsigned int fluid_id=0, const unsigned int material_id=0) const
Returns the magnetic permeability model of the imaginary part for a given fluid_id and material_id.
Class that stores the information required by the assembly of the Discontinuous Petrov-Galerkin (DPG)...
std::shared_ptr< FEFaceValues< dim > > fe_face_values_void_fraction
unsigned int n_base_functions_trial_interior
Table< 2, Tensor< 1, dim > > phi_test_face
types::boundary_id face_boundary_id
FEFaceValues< dim > fe_face_values_test
unsigned int n_base_functions_test
void allocate() override
Allocate the memory of all the members of the scratch. It builds the lists of the local dof index of ...
std::vector< std::complex< double > > face_effective_electric_permittivities
std::vector< double > void_fraction_values
void calculate_face_physical_properties()
Compute the effective electromagnetic properties at the face quadrature points from the fields gather...
FEFaceValues< dim > fe_face_values_trial_skeleton
void build_local_dof_index_map(const FiniteElement< dim > &fe, std::array< std::vector< unsigned int >, n_electromagnetic_fields > &local_dof_index_map) const
Build the local dof index list of each base function for each field of a finite element space of the ...
const FEValuesExtractors::Vector extractor_H_imag
std::vector< double > JxW
std::vector< double > face_temperature_values
std::vector< Point< dim > > quadrature_points
Table< 2, Tensor< 1, dim > > n_cross_phi_test_face
FEValues< dim > fe_values_trial_interior
void enable_void_fraction(const FiniteElement< dim > &fe_void_fraction, const Quadrature< dim > &cell_quadrature, const Quadrature< dim - 1 > &face_quadrature, const Mapping< dim > &mapping)
Enable the evaluation of the void fraction field, on which the electromagnetic properties of an effec...
FEValues< dim > fe_values_test
std::vector< Point< dim > > face_quadrature_points
std::vector< double > face_void_fraction_values
std::vector< std::complex< double > > effective_magnetic_permeabilities
Table< 2, Tensor< 1, dim > > tangential_phi_trial_skeleton
void reinit_face(const typename DoFHandler< dim >::active_cell_iterator &cell_skeleton, const typename DoFHandler< dim >::active_cell_iterator &cell_test, const unsigned int face_no)
Reinitialize the content of the scratch for a face of the current cell. It evaluates the test functio...
std::array< std::vector< unsigned int >, n_electromagnetic_fields > trial_skeleton_local_dof_index_map
std::vector< Tensor< 1, dim > > face_normals
Table< 2, Tensor< 1, dim > > n_cross_tangential_phi_trial_skeleton
bool cell_material_needs_temperature
std::vector< std::vector< unsigned int > > trial_skeleton_tangential_base_functions
std::array< std::vector< unsigned int >, n_electromagnetic_fields > trial_interior_local_dof_index_map
unsigned int n_face_q_points
std::shared_ptr< FEValues< dim > > fe_values_temperature
void calculate_physical_properties()
Compute the effective electromagnetic properties at the cell quadrature points from the fields gather...
void calculate_cell_coefficients()
Compute the coefficients of the time-harmonic Maxwell equations of the cell at the quadrature points.
Table< 2, Tensor< 1, dim > > phi_trial_interior
std::vector< std::complex< double > > iwmu_JxW_container
const FEValuesExtractors::Vector extractor_H_real
std::vector< double > JxW_II_container
void enable_temperature(const FiniteElement< dim > &fe_temperature, const Quadrature< dim > &cell_quadrature, const Quadrature< dim - 1 > &face_quadrature, const Mapping< dim > &mapping)
Enable the evaluation of the temperature field, on which the electromagnetic properties may depend.
std::array< std::vector< unsigned int >, n_electromagnetic_fields > test_local_dof_index_map
std::shared_ptr< FEValues< dim > > fe_values_void_fraction
Table< 2, Tensor< 1, dim > > curl_phi_test
void identify_tangential_base_functions(const FiniteElement< dim > &fe, const std::array< std::vector< unsigned int >, n_electromagnetic_fields > &local_dof_index_map, std::vector< std::vector< unsigned int > > &tangential_base_functions) const
Identify, for each face of the reference cell, the base functions of a finite element space whose tan...
std::shared_ptr< FEFaceValues< dim > > fe_face_values_temperature
const PhysicalPropertiesManager properties_manager
std::vector< std::complex< double > > face_effective_magnetic_permeabilities
const FEValuesExtractors::Vector extractor_E_imag
std::vector< double > face_JxW
bool gather_void_fraction
unsigned int n_base_functions_trial_skeleton
const FEValuesExtractors::Vector extractor_E_real
static constexpr unsigned int n_electromagnetic_fields
std::vector< std::complex< double > > iweps_JxW_container
std::vector< std::vector< unsigned int > > test_tangential_base_functions
bool cell_material_needs_void_fraction
std::vector< std::complex< double > > effective_electric_permittivities
Table< 2, Tensor< 1, dim > > phi_test
std::vector< double > temperature_values
std::vector< double > JxW_FF_container
std::map< field, std::vector< double > > face_fields
std::map< field, std::vector< double > > fields
void reinit(const typename DoFHandler< dim >::active_cell_iterator &cell, const typename DoFHandler< dim >::active_cell_iterator &cell_test)
Reinitialize the content of the scratch for a cell. It evaluates the shape functions of the test and ...
void set_field_vector(const field &id, const std::vector< double > &data, std::map< field, std::vector< double > > &fields)
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,...
bool electromagnetic_properties_depend_on(const PhysicalPropertiesManager &physical_properties_manager, const unsigned int material_id, const field field_id)
Check if at least one electromagnetic property of a material depends on a field. If the material is a...
void compute_effective_electromagnetic_properties(const PhysicalPropertiesManager &physical_properties_manager, const std::map< field, std::vector< double > > &field_values_vectors, const unsigned int material_id, std::vector< std::complex< double > > &effective_electric_permittivities, std::vector< std::complex< double > > &effective_magnetic_permeabilities)
Compute the effective electromagnetic properties of a material at a set of points....