8#include <deal.II/base/work_stream.h>
10#include <deal.II/dofs/dof_renumbering.h>
12#include <deal.II/fe/fe_system.h>
14#include <deal.II/lac/lapack_support.h>
15#include <deal.II/lac/sparsity_tools.h>
16#include <deal.II/lac/trilinos_solver.h>
18#include <deal.II/numerics/vector_tools.h>
24 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
26 std::shared_ptr<SimulationControl> p_simulation_control)
32 TimerOutput::wall_times)
55 "TimeHarmonicMaxwell solver not yet implemented for simplex meshes."));
59 AssertThrow(dim == 3, TimeHarmonicMaxwellDimensionNotSupported(dim));
65 "The DPG method requires the test space to be of higher order than the trial space."));
90 fe_test = std::make_shared<FESystem<dim>>(
117 unsigned int number_of_material_ids =
118 physical_properties_manager.get_number_of_fluids() +
119 physical_properties_manager.get_number_of_solids() - 1;
123 const auto &adaptation_variables =
125 const auto electromagnetic_adaptation =
128 (electromagnetic_adaptation != adaptation_variables.end()) &&
129 (electromagnetic_adaptation->second.error_estimator ==
134 for (
unsigned int material_id = 0; material_id <= number_of_material_ids;
137 const bool material_needs_temperature =
146 !(material_needs_temperature &&
147 physical_properties_manager.is_effective_medium(0, material_id)),
149 "Temperature-dependent electromagnetic properties are not supported yet for an effective medium (fluid-dispersed phase interaction). Use temperature-independent electromagnetic property models for the fluid and the unresolved dispersed phase."));
163 const std::vector<PhysicsID> active_physics_ids =
167 active_physics_ids.end(),
169 "User-defined temperature-dependent electromagnetic properties requested without heat transfer physics. Enable heat transfer in the multiphysics subsection."));
182 "Void fraction-dependent electromagnetic properties (fluid-dispersed phase interaction) require the volume-averaged Navier-Stokes (VANS) formulation, which provides the void fraction."));
189 .time_coupling_strategy !=
192 "The threshold time coupling strategy of the time-harmonic Maxwell solver is not supported with void fraction-dependent electromagnetic properties at the moment."));
199 const TrilinosWrappers::SparsityPattern &sparsity_pattern)
201 auto mpi_communicator =
triangulation->get_mpi_communicator();
202 const auto this_mpi_process =
203 Utilities::MPI::this_mpi_process(mpi_communicator);
204 constexpr double bytes_to_gb = 1.0 / (1024.0 * 1024.0 * 1024.0);
207 const auto present_solution_memory =
209 const auto present_solution_skeleton_memory =
211 const auto system_rhs_memory =
212 this->
system_rhs.memory_consumption() * bytes_to_gb;
213 const auto sparsity_pattern_memory =
214 sparsity_pattern.n_nonzero_elements() *
215 sizeof(TrilinosWrappers::types::int_type) *
222 const auto system_matrix_memory =
224 const auto dof_handler_trial_interior_memory =
226 const auto dof_handler_trial_skeleton_memory =
228 const auto dof_handler_test_memory =
232 const auto present_solution_memory_by_rank =
233 Utilities::MPI::gather(mpi_communicator, present_solution_memory, 0);
234 const auto present_solution_skeleton_memory_by_rank =
235 Utilities::MPI::gather(mpi_communicator,
236 present_solution_skeleton_memory,
238 const auto system_rhs_memory_by_rank =
239 Utilities::MPI::gather(mpi_communicator, system_rhs_memory, 0);
240 const auto sparsity_pattern_memory_by_rank =
241 Utilities::MPI::gather(mpi_communicator, sparsity_pattern_memory, 0);
242 const auto system_matrix_memory_by_rank =
243 Utilities::MPI::gather(mpi_communicator, system_matrix_memory, 0);
244 const auto dof_handler_trial_interior_memory_by_rank =
245 Utilities::MPI::gather(mpi_communicator,
246 dof_handler_trial_interior_memory,
248 const auto dof_handler_trial_skeleton_memory_by_rank =
249 Utilities::MPI::gather(mpi_communicator,
250 dof_handler_trial_skeleton_memory,
252 const auto dof_handler_test_memory_by_rank =
253 Utilities::MPI::gather(mpi_communicator, dof_handler_test_memory, 0);
256 const auto present_solution_memory_total =
257 Utilities::MPI::sum(present_solution_memory, mpi_communicator);
258 const auto present_solution_skeleton_memory_total =
259 Utilities::MPI::sum(present_solution_skeleton_memory, mpi_communicator);
260 const auto system_rhs_memory_total =
261 Utilities::MPI::sum(system_rhs_memory, mpi_communicator);
262 const auto sparsity_pattern_memory_total =
263 Utilities::MPI::sum(sparsity_pattern_memory, mpi_communicator);
264 const auto system_matrix_memory_total =
265 Utilities::MPI::sum(system_matrix_memory, mpi_communicator);
266 const auto dof_handler_trial_interior_memory_total =
267 Utilities::MPI::sum(dof_handler_trial_interior_memory, mpi_communicator);
268 const auto dof_handler_trial_skeleton_memory_total =
269 Utilities::MPI::sum(dof_handler_trial_skeleton_memory, mpi_communicator);
270 const auto dof_handler_test_memory_total =
271 Utilities::MPI::sum(dof_handler_test_memory, mpi_communicator);
274 if (this_mpi_process == 0)
276 const auto total_memory =
277 present_solution_memory_total + present_solution_skeleton_memory_total +
278 system_rhs_memory_total + sparsity_pattern_memory_total +
279 system_matrix_memory_total + dof_handler_trial_interior_memory_total +
280 dof_handler_trial_skeleton_memory_total + dof_handler_test_memory_total;
283 "Time-Harmonic Maxwell Memory Diagnostics",
291 bool print_memory_by_rank =
true;
292 if (print_memory_by_rank)
294 this->
pcout <<
" *** By rank memory *** " << std::endl;
298 present_solution_memory_by_rank.size(),
299 present_solution_memory_by_rank);
302 "present_solution_skeleton",
303 present_solution_skeleton_memory_by_rank.size(),
304 present_solution_skeleton_memory_by_rank);
307 system_rhs_memory_by_rank.size(),
308 system_rhs_memory_by_rank);
312 sparsity_pattern_memory_by_rank.size(),
313 sparsity_pattern_memory_by_rank);
316 system_matrix_memory_by_rank.size(),
317 system_matrix_memory_by_rank);
320 "dof_handler_trial_interior",
321 dof_handler_trial_interior_memory_by_rank.size(),
322 dof_handler_trial_interior_memory_by_rank);
325 "dof_handler_trial_skeleton",
326 dof_handler_trial_skeleton_memory_by_rank.size(),
327 dof_handler_trial_skeleton_memory_by_rank);
330 dof_handler_test_memory_by_rank.size(),
331 dof_handler_test_memory_by_rank);
334 <<
"=================================================================="
338 this->
pcout <<
" *** Total memory consumption (GB) *** " << std::endl;
339 this->
pcout <<
" present_solution : " << present_solution_memory_total
341 this->
pcout <<
" present_solution_skeleton : "
342 << present_solution_skeleton_memory_total << std::endl;
343 this->
pcout <<
" system_rhs : " << system_rhs_memory_total << std::endl;
344 this->
pcout <<
" sparsity_pattern : " << sparsity_pattern_memory_total
346 this->
pcout <<
" system_matrix : " << system_matrix_memory_total
348 this->
pcout <<
" dof_handler_trial_interior : "
349 << dof_handler_trial_interior_memory_total << std::endl;
350 this->
pcout <<
" dof_handler_trial_skeleton : "
351 << dof_handler_trial_skeleton_memory_total << std::endl;
352 this->
pcout <<
" dof_handler_test : " << dof_handler_test_memory_total
354 this->
pcout <<
" Total DPG solver memory consumption : " << total_memory
357 <<
" =================================================================="
368 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
369 const auto &electromagnetic_parameters =
371 constexpr double void_impedance =
383 double max_port_electric_amplitude = 0.0;
387 if (electromagnetic_parameters.number_of_waveguide_inlets > 0)
389 const auto &waveguide_powers = electromagnetic_parameters.waveguide_power;
394 std::vector<double> waveguide_modal_powers(
395 electromagnetic_parameters.number_of_waveguide_inlets, 0.);
403 electromagnetic_parameters.number_of_waveguide_inlets, 0.);
407 FEFaceValues<dim> fe_face_values_trial_skeleton(*this->
mapping,
410 update_quadrature_points |
411 update_normal_vectors |
413 const unsigned int n_face_q_points =
414 fe_face_values_trial_skeleton.n_quadrature_points;
418 Tensor<1, dim, std::complex<double>> E_inc;
419 Tensor<1, dim, std::complex<double>> H_inc;
420 std::vector<std::complex<double>> effective_electric_permittivities(
422 std::vector<std::complex<double>> effective_magnetic_permeabilities(
424 unsigned int material_id;
425 bool cell_material_needs_temperature =
false;
426 bool cell_material_needs_void_fraction =
false;
431 std::unique_ptr<FEFaceValues<dim>> fe_face_values_temperature;
432 const DoFHandler<dim> *dof_handler_temperature =
nullptr;
434 std::vector<double> temperature_face_values(n_face_q_points);
435 std::map<field, std::vector<double>> field_values_vector;
439 dof_handler_temperature =
441 fe_face_values_temperature = std::make_unique<FEFaceValues<dim>>(
443 dof_handler_temperature->get_fe(),
445 update_values | update_quadrature_points);
446 temperature_solution =
452 std::unique_ptr<FEFaceValues<dim>> fe_face_values_void_fraction;
453 const DoFHandler<dim> *dof_handler_void_fraction =
nullptr;
455 std::vector<double> void_fraction_face_values(n_face_q_points, 1.);
459 dof_handler_void_fraction =
461 fe_face_values_void_fraction = std::make_unique<FEFaceValues<dim>>(
463 dof_handler_void_fraction->get_fe(),
465 update_values | update_quadrature_points);
466 void_fraction_solution =
473 for (
const auto &cell :
triangulation->active_cell_iterators())
475 if (cell->is_locally_owned())
477 material_id = cell->material_id();
482 cell_material_needs_temperature =
485 cell_material_needs_void_fraction =
487 physical_properties_manager,
491 for (
const auto &face : cell->face_iterators())
493 if (!(face->at_boundary()))
496 fe_face_values_trial_skeleton.reinit(cell, face);
498 if (cell_material_needs_temperature)
500 const typename DoFHandler<dim>::active_cell_iterator
501 cell_temperature = cell->as_dof_handler_iterator(
502 *dof_handler_temperature);
503 fe_face_values_temperature->reinit(cell_temperature,
505 fe_face_values_temperature->get_function_values(
506 *temperature_solution, temperature_face_values);
510 std::ranges::fill(temperature_face_values, 0.);
513 if (cell_material_needs_void_fraction)
515 const typename DoFHandler<dim>::active_cell_iterator
516 cell_void_fraction = cell->as_dof_handler_iterator(
517 *dof_handler_void_fraction);
518 fe_face_values_void_fraction->reinit(cell_void_fraction,
520 fe_face_values_void_fraction->get_function_values(
521 *void_fraction_solution, void_fraction_face_values);
525 std::ranges::fill(void_fraction_face_values, 1.);
530 .boundary_conditions_time_harmonic_electromagnetics.type
531 .at(face->boundary_id());
541 const unsigned int waveguide_port_index =
543 face->boundary_id());
548 temperature_face_values;
550 void_fraction_face_values;
553 physical_properties_manager,
556 effective_electric_permittivities,
557 effective_magnetic_permeabilities);
560 for (
unsigned int q_point = 0; q_point < n_face_q_points;
564 const auto &position =
565 fe_face_values_trial_skeleton.quadrature_point(q_point);
567 fe_face_values_trial_skeleton.normal_vector(q_point);
568 const double JxW_face =
569 fe_face_values_trial_skeleton.JxW(q_point);
571 std::tie(E_inc, H_inc) =
573 electromagnetic_parameters,
576 effective_electric_permittivities[q_point],
577 effective_magnetic_permeabilities[q_point],
578 waveguide_port_index);
590 if constexpr (dim == 3)
592 waveguide_modal_powers[waveguide_port_index] -=
595 normal[0] * (E_inc[1] * std::conj(H_inc[2]) -
596 E_inc[2] * std::conj(H_inc[1])) +
597 normal[1] * (E_inc[2] * std::conj(H_inc[0]) -
598 E_inc[0] * std::conj(H_inc[2])) +
599 normal[2] * (E_inc[0] * std::conj(H_inc[1]) -
600 E_inc[1] * std::conj(H_inc[0]))) *
606 TimeHarmonicMaxwellDimensionNotSupported(
616 for (
unsigned int inlets = 0;
617 inlets < electromagnetic_parameters.number_of_waveguide_inlets;
627 std::sqrt(waveguide_powers[inlets] * void_impedance /
628 Utilities::MPI::sum(waveguide_modal_powers[inlets],
632 max_port_electric_amplitude =
638 if (electromagnetic_parameters.electromagnetic_scaling_type ==
644 electromagnetic_parameters.electric_field_amplitude;
646 else if (electromagnetic_parameters.electromagnetic_scaling_type ==
654 void_impedance * electromagnetic_parameters.magnetic_field_amplitude;
656 else if (electromagnetic_parameters.electromagnetic_scaling_type ==
663 max_port_electric_amplitude /
666 else if (electromagnetic_parameters.electromagnetic_scaling_type ==
678 AssertThrow(
false, ExcMessage(
"Unknown electromagnetic scaling type."));
685 const DoFHandler<dim> &dof_handler,
688 const auto &fe = dof_handler.get_fe();
691 .electromagnetic_scaling_type ==
695 constexpr double void_impedance = 4 * numbers::PI * 29.9792458;
698 const double electric_scale =
701 const double magnetic_scale =
705 const IndexSet &locally_owned_dofs = solution.locally_owned_elements();
706 std::vector<bool> dof_scaled(locally_owned_dofs.n_elements(),
false);
707 std::vector<types::global_dof_index> local_dof_indices(fe.n_dofs_per_cell());
718 for (
const auto &cell : dof_handler.active_cell_iterators())
720 if (cell->is_locally_owned())
723 cell->get_dof_indices(local_dof_indices);
726 for (
unsigned int local_dof = 0; local_dof < local_dof_indices.size();
730 const types::global_dof_index global_dof =
731 local_dof_indices[local_dof];
736 if (!locally_owned_dofs.is_element(global_dof))
739 const unsigned int locally_owned_position =
740 locally_owned_dofs.index_within_set(global_dof);
747 if (dof_scaled[locally_owned_position])
750 dof_scaled[locally_owned_position] =
true;
755 const unsigned int base_element =
756 fe.system_to_base_index(local_dof).first.first;
758 if (base_element == 0 || base_element == 1)
759 solution[global_dof] *= electric_scale;
760 else if (base_element == 2 || base_element == 3)
761 solution[global_dof] *= magnetic_scale;
768std::vector<OutputStruct<dim, GlobalVectorType>>
771 std::vector<OutputStruct<dim, GlobalVectorType>> solution_output_structs;
774 std::vector<std::string> solution_interior_names(dim,
"E_real");
775 for (
int i = 0; i < dim; ++i)
777 solution_interior_names.emplace_back(
"E_imag");
779 for (
int i = 0; i < dim; ++i)
781 solution_interior_names.emplace_back(
"H_real");
783 for (
int i = 0; i < dim; ++i)
785 solution_interior_names.emplace_back(
"H_imag");
788 std::vector<DataComponentInterpretation::DataComponentInterpretation>
789 solution_interior_data_component_interpretation(
790 4 * dim, DataComponentInterpretation::component_is_part_of_vector);
792 solution_output_structs.emplace_back(
796 solution_interior_names,
797 solution_interior_data_component_interpretation);
803 solution_output_structs.emplace_back(
804 std::in_place_type<OutputStructCellVector>,
806 std::string(
"dpg_error_norm"));
813 return solution_output_structs;
820 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
823 FEValues<dim> fe_values_trial_interior(*this->
mapping,
827 update_quadrature_points |
834 std::vector<Vector<double>> exact_solution_values(n_q_points,
835 Vector<double>(4 * dim));
836 auto &exact_solution_function =
842 std::vector<Tensor<1, dim>> local_E_values_real(n_q_points);
843 std::vector<Tensor<1, dim>> local_E_values_imag(n_q_points);
844 std::vector<Tensor<1, dim>> local_H_values_real(n_q_points);
845 std::vector<Tensor<1, dim>> local_H_values_imag(n_q_points);
849 double L2_error_E_real = 0;
850 double L2_error_E_imag = 0;
851 double L2_error_H_real = 0;
852 double L2_error_H_imag = 0;
856 if (cell->is_locally_owned())
858 fe_values_trial_interior.reinit(cell);
871 exact_solution_function.vector_value_list(
872 fe_values_trial_interior.get_quadrature_points(),
873 exact_solution_values);
876 for (
unsigned int q = 0; q < n_q_points; ++q)
878 const double JxW = fe_values_trial_interior.JxW(q);
881 for (
int d = 0; d < dim; ++d)
885 Utilities::fixed_power<2>(local_E_values_real[q][d] -
886 exact_solution_values[q][d]) *
890 L2_error_E_imag += Utilities::fixed_power<2>(
891 local_E_values_imag[q][d] -
892 exact_solution_values[q][d + dim]) *
896 L2_error_H_real += Utilities::fixed_power<2>(
897 local_H_values_real[q][d] -
898 exact_solution_values[q][d + 2 * dim]) *
902 L2_error_H_imag += Utilities::fixed_power<2>(
903 local_H_values_imag[q][d] -
904 exact_solution_values[q][d + 3 * dim]) *
913 L2_error_E_real = Utilities::MPI::sum(L2_error_E_real, mpi_communicator);
914 L2_error_E_imag = Utilities::MPI::sum(L2_error_E_imag, mpi_communicator);
915 L2_error_H_real = Utilities::MPI::sum(L2_error_H_real, mpi_communicator);
916 L2_error_H_imag = Utilities::MPI::sum(L2_error_H_imag, mpi_communicator);
918 return {std::sqrt(L2_error_E_real),
919 std::sqrt(L2_error_E_imag),
920 std::sqrt(L2_error_H_real),
921 std::sqrt(L2_error_H_imag)};
929 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
930 unsigned int this_mpi_process(
931 Utilities::MPI::this_mpi_process(mpi_communicator));
933 if (this_mpi_process == 0 &&
939 error_table.omit_column_from_convergence_rate_evaluation(
"cells");
942 ConvergenceTable::reduction_rate_log2);
962 this->
pcout << std::defaultfloat;
964 this->
pcout << std::scientific;
998 .boundary_conditions_time_harmonic_electromagnetics.time_dependent)
1004 "Time-dependent boundary conditions not yet implemented for TimeHarmonicMaxwell."));
1015 double E_real_error = errors[0];
1016 double E_imag_error = errors[1];
1017 double H_real_error = errors[2];
1018 double H_imag_error = errors[3];
1022 this->
error_table.add_value(
"error_E_real", E_real_error);
1023 this->
error_table.add_value(
"error_E_imag", E_imag_error);
1024 this->
error_table.add_value(
"error_H_real", H_real_error);
1025 this->
error_table.add_value(
"error_H_imag", H_imag_error);
1027 this->
error_table.set_scientific(
"error_E_real",
true);
1028 this->
error_table.set_scientific(
"error_E_imag",
true);
1029 this->
error_table.set_scientific(
"error_H_real",
true);
1030 this->
error_table.set_scientific(
"error_H_imag",
true);
1032 if (Utilities::MPI::this_mpi_process(
1035 const std::string filename =
1038 "_time_harmonic_maxwell.dat";
1039 std::ofstream output(filename.c_str());
1046 this->
pcout <<
"L2 error E real: " << E_real_error << std::endl;
1047 this->
pcout <<
"L2 error E imag: " << E_imag_error << std::endl;
1048 this->
pcout <<
"L2 error H real: " << H_real_error << std::endl;
1049 this->
pcout <<
"L2 error H imag: " << H_imag_error << std::endl;
1059 this->
pcout << std::defaultfloat;
1061 this->
pcout << std::scientific;
1077 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
1098 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
1101 std::vector<const GlobalVectorType *> sol_set_transfer;
1113 std::vector<const GlobalVectorType *> temperature_sol_set_transfer;
1116 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(
1119 temperature_sol_set_transfer.emplace_back(
1123 temperature_sol_set_transfer);
1128 const std::vector<OutputStructTableHandler> &table_output_structs =
1137 auto mpi_communicator =
triangulation->get_mpi_communicator();
1138 this->
pcout <<
"Reading time-harmonic Maxwell checkpoint" << std::endl;
1141 std::vector<GlobalVectorType *> input_vectors(1);
1144 input_vectors[0] = &distributed_system;
1155 const auto &temperature_dof_handler =
1158 const IndexSet locally_relevant_temperature_dofs =
1159 DoFTools::extract_locally_relevant_dofs(temperature_dof_handler);
1161 temperature_dof_handler.locally_owned_dofs(),
1162 locally_relevant_temperature_dofs,
1166 temperature_dof_handler.locally_owned_dofs(), mpi_communicator);
1169 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(
1170 temperature_dof_handler);
1172 std::vector<GlobalVectorType *> temperature_input_vectors(1);
1174 temperature_input_vectors[0] = &distributed_temperature_last_solved;
1177 temperature_input_vectors);
1184 std::vector<OutputStructTableHandler> table_output_structs =
1190std::vector<OutputStructTableHandler>
1193 std::vector<OutputStructTableHandler> table_output_structs;
1195 std::string prefix =
1197 std::string suffix =
".checkpoint";
1200 table_output_structs.emplace_back(
1206 return table_output_structs;
1212 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
1214 dealii::Vector<float> &estimated_error_per_cell)
1219 ivar.second.error_estimator ==
1222 "Only the Kelly error estimator is currently implemented for the "
1223 "<electric field> field."));
1225 ComponentMask electric_field_mask =
1228 compute_kelly(estimated_error_per_cell, electric_field_mask);
1233 ivar.second.error_estimator ==
1236 "Only the Kelly error estimator is currently implemented for the "
1237 "<magnetic field> field."));
1239 ComponentMask magnetic_field_mask =
1242 compute_kelly(estimated_error_per_cell, magnetic_field_mask);
1246 if (ivar.second.error_estimator ==
1249 ComponentMask electromagnetics_mask =
1254 compute_kelly(estimated_error_per_cell, electromagnetics_mask);
1257 else if (ivar.second.error_estimator ==
1267 "Unknown error estimator type for variable <electromagnetic fields>."));
1275 dealii::Vector<float> &estimated_error_per_cell,
1276 const ComponentMask &component_mask)
1278 KellyErrorEstimator<dim>::estimate(
1282 typename std::map<types::boundary_id,
const Function<dim, double> *>(),
1284 estimated_error_per_cell,
1291 dealii::Vector<float> &estimated_error_per_cell)
1299 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
1304 bool dpg_error_computed =
false;
1306 for (
const auto &cell :
1309 if (cell->is_locally_owned())
1313 dpg_error_computed =
true;
1315 const unsigned int cell_index = cell->active_cell_index();
1316 estimated_error_per_cell[cell_index] =
1323 const bool is_global_dpg_error_computed =
1324 Utilities::MPI::max(
static_cast<unsigned int>(dpg_error_computed),
1325 mpi_communicator) != 0;
1328 is_global_dpg_error_computed,
1330 "The DPG error estimator has not been computed before calling compute_dpg_error. Please make sure that the system assembly has been performed and the local_estimated_error_per_cell vector has been filled with the DPG error estimates for each cell before calling this function."));
1339 auto mpi_communicator =
triangulation->get_mpi_communicator();
1396 TrilinosWrappers::SparsityPattern
1407 SparsityTools::distribute_sparsity_pattern(
1417 sparsity_pattern.compress();
1427 this->
pcout <<
" DPG system for Time-Harmonic Maxwell Equations:"
1430 <<
" Number of skeleton degrees of freedom for Time-Harmonic Maxwell: "
1433 <<
" Number of interior degrees of freedom for Time-Harmonic Maxwell: "
1457 VectorTools::interpolate(
1464 VectorTools::interpolate(
1471 VectorTools::interpolate(
1478 VectorTools::interpolate(
1498 preconditioner = std::make_shared<TrilinosWrappers::PreconditionIdentity>();
1514 for (
const auto &[
id, type] :
1516 .boundary_conditions_time_harmonic_electromagnetics.type)
1522 VectorTools::project_boundary_values_curl_conforming_l2(
1525 Functions::ZeroFunction<dim>(4 * dim),
1530 VectorTools::project_boundary_values_curl_conforming_l2(
1533 Functions::ZeroFunction<dim>(4 * dim),
1541 VectorTools::project_boundary_values_curl_conforming_l2(
1544 Functions::ZeroFunction<dim>(4 * dim),
1549 VectorTools::project_boundary_values_curl_conforming_l2(
1552 Functions::ZeroFunction<dim>(4 * dim),
1562 VectorTools::project_boundary_values_curl_conforming_l2(
1566 &this->simulation_parameters
1567 .boundary_conditions_time_harmonic_electromagnetics
1568 .imposed_electromagnetic_fields.at(
id)
1570 &this->simulation_parameters
1571 .boundary_conditions_time_harmonic_electromagnetics
1572 .imposed_electromagnetic_fields.at(
id)
1574 &this->simulation_parameters
1575 .boundary_conditions_time_harmonic_electromagnetics
1576 .imposed_electromagnetic_fields.at(
id)
1578 &this->simulation_parameters
1579 .boundary_conditions_time_harmonic_electromagnetics
1580 .imposed_electromagnetic_fields.at(
id)
1582 &this->simulation_parameters
1583 .boundary_conditions_time_harmonic_electromagnetics
1584 .imposed_electromagnetic_fields.at(
id)
1586 &this->simulation_parameters
1587 .boundary_conditions_time_harmonic_electromagnetics
1588 .imposed_electromagnetic_fields.at(
id)
1591 this->nonzero_constraints);
1594 VectorTools::project_boundary_values_curl_conforming_l2(
1598 &this->simulation_parameters
1599 .boundary_conditions_time_harmonic_electromagnetics
1600 .imposed_electromagnetic_fields.at(
id)
1602 &this->simulation_parameters
1603 .boundary_conditions_time_harmonic_electromagnetics
1604 .imposed_electromagnetic_fields.at(
id)
1606 &this->simulation_parameters
1607 .boundary_conditions_time_harmonic_electromagnetics
1608 .imposed_electromagnetic_fields.at(
id)
1610 &this->simulation_parameters
1611 .boundary_conditions_time_harmonic_electromagnetics
1612 .imposed_electromagnetic_fields.at(
id)
1614 &this->simulation_parameters
1615 .boundary_conditions_time_harmonic_electromagnetics
1616 .imposed_electromagnetic_fields.at(
id)
1618 &this->simulation_parameters
1619 .boundary_conditions_time_harmonic_electromagnetics
1620 .imposed_electromagnetic_fields.at(
id)
1623 this->nonzero_constraints);
1632 VectorTools::project_boundary_values_curl_conforming_l2(
1636 &this->simulation_parameters
1637 .boundary_conditions_time_harmonic_electromagnetics
1638 .imposed_electromagnetic_fields.at(
id)
1640 &this->simulation_parameters
1641 .boundary_conditions_time_harmonic_electromagnetics
1642 .imposed_electromagnetic_fields.at(
id)
1644 &this->simulation_parameters
1645 .boundary_conditions_time_harmonic_electromagnetics
1646 .imposed_electromagnetic_fields.at(
id)
1648 &this->simulation_parameters
1649 .boundary_conditions_time_harmonic_electromagnetics
1650 .imposed_electromagnetic_fields.at(
id)
1652 &this->simulation_parameters
1653 .boundary_conditions_time_harmonic_electromagnetics
1654 .imposed_electromagnetic_fields.at(
id)
1656 &this->simulation_parameters
1657 .boundary_conditions_time_harmonic_electromagnetics
1658 .imposed_electromagnetic_fields.at(
id)
1661 this->nonzero_constraints);
1664 VectorTools::project_boundary_values_curl_conforming_l2(
1668 &this->simulation_parameters
1669 .boundary_conditions_time_harmonic_electromagnetics
1670 .imposed_electromagnetic_fields.at(
id)
1672 &this->simulation_parameters
1673 .boundary_conditions_time_harmonic_electromagnetics
1674 .imposed_electromagnetic_fields.at(
id)
1676 &this->simulation_parameters
1677 .boundary_conditions_time_harmonic_electromagnetics
1678 .imposed_electromagnetic_fields.at(
id)
1680 &this->simulation_parameters
1681 .boundary_conditions_time_harmonic_electromagnetics
1682 .imposed_electromagnetic_fields.at(
id)
1684 &this->simulation_parameters
1685 .boundary_conditions_time_harmonic_electromagnetics
1686 .imposed_electromagnetic_fields.at(
id)
1688 &this->simulation_parameters
1689 .boundary_conditions_time_harmonic_electromagnetics
1690 .imposed_electromagnetic_fields.at(
id)
1693 this->nonzero_constraints);
1706 std::vector<types::global_dof_index> cell_dof_indices(
1708 std::vector<types::global_dof_index> face_dof_indices(
1714 for (
const auto &cell :
1717 if (cell->is_locally_owned())
1720 cell->get_dof_indices(cell_dof_indices);
1723 for (
const auto &face : cell->face_iterators())
1725 face->get_dof_indices(face_dof_indices);
1728 for (
const auto &face_dof : face_dof_indices)
1733 const auto it = std::ranges::find(cell_dof_indices, face_dof);
1738 if (it != cell_dof_indices.end())
1740 is_dof_on_face[std::distance(cell_dof_indices.begin(),
1748 for (
unsigned int index = 0; index < cell_dof_indices.size(); ++index)
1751 if (!is_dof_on_face[index])
1754 cell_dof_indices[index]);
1775 "The time harmonic electromagnetism physics does not support a preconditioner. Please set: subsection linear solver -> subsection electromagnetics -> set preconditioner = none."));
1778 const double absolute_residual =
1781 const double relative_residual =
1786 const double rescaled_residual = this->
system_rhs.l2_norm() / rescale_metric;
1787 const double linear_solver_tolerance =
1788 std::max(relative_residual * rescaled_residual, absolute_residual);
1793 this->
pcout <<
" -Tolerance of iterative solver is : "
1794 << linear_solver_tolerance << std::endl;
1799 linear_solver_tolerance);
1802 TrilinosWrappers::SolverCG solver(solver_control);
1812 this->
pcout <<
" -CG iterative solver took : "
1813 << solver_control.last_step()
1814 <<
" steps to reach a residual norm of "
1815 << solver_control.last_value() / rescale_metric << std::endl;
1893 const int difference_in_time_steps =
static_cast<int>(
1898 if (difference_in_time_steps == 1)
1900 else if (difference_in_time_steps > 1)
1905 "The time coupling strategy for the time-harmonic Maxwell solver is set to 'time' with a coupling time of " +
1907 ", but the simulation time has advanced by " +
1909 this->simulation_control->get_current_time() -
1910 this->simulation_control->get_previous_time()) +
1911 " since the last time the electromagnetics were solved. Please either reduce the simulation time step or increase the coupling time to avoid missing coupling points."));
1919 auto mpi_communicator =
triangulation->get_mpi_communicator();
1923 unsigned int material_id;
1926 std::vector<std::complex<double>>
1927 effective_electric_permittivities_last_solved;
1928 std::vector<std::complex<double>>
1929 effective_magnetic_permeabilities_last_solved;
1930 std::map<field, std::vector<double>>
1931 field_values_vector_last_solved;
1932 std::vector<double> temperature_last_solved_values;
1933 std::vector<std::complex<double>>
1934 effective_electric_permittivities_current;
1935 std::vector<std::complex<double>>
1936 effective_magnetic_permeabilities_current;
1937 std::map<field, std::vector<double>> field_values_vector_current;
1938 std::vector<double> temperature_current_values;
1939 double max_relative_change = 0.0;
1940 unsigned int n_q_points = 0;
1944 std::unique_ptr<FEValues<dim>> fe_values_temperature;
1945 const DoFHandler<dim> *dof_handler_temperature =
nullptr;
1951 dof_handler_temperature =
1954 const QGauss<dim> temperature_quadrature(
1955 dof_handler_temperature->get_fe().degree + 1);
1956 n_q_points = temperature_quadrature.size();
1957 temperature_current_solution =
1960 fe_values_temperature = std::make_unique<FEValues<dim>>(
1962 dof_handler_temperature->get_fe(),
1963 temperature_quadrature,
1964 update_values | update_quadrature_points);
1966 temperature_last_solved_values.resize(n_q_points);
1967 temperature_current_values.resize(n_q_points);
1974 for (
const auto &cell :
1975 dof_handler_temperature->active_cell_iterators())
1977 if (cell->is_locally_owned())
1979 fe_values_temperature->reinit(cell);
1980 fe_values_temperature->get_function_values(
1981 *temperature_current_solution,
1982 temperature_current_values);
1984 fe_values_temperature->get_function_values(
1986 temperature_last_solved_values);
1989 temperature_last_solved_values;
1991 temperature_current_values;
1993 material_id = cell->material_id();
1996 physical_properties_manager,
1997 field_values_vector_last_solved,
1999 effective_electric_permittivities_last_solved,
2000 effective_magnetic_permeabilities_last_solved);
2003 physical_properties_manager,
2004 field_values_vector_current,
2006 effective_electric_permittivities_current,
2007 effective_magnetic_permeabilities_current);
2009 for (
unsigned int q = 0; q < n_q_points; ++q)
2018 double relative_change_electric_permittivity =
2020 effective_electric_permittivities_current[q] -
2021 effective_electric_permittivities_last_solved
2024 effective_electric_permittivities_last_solved
2026 double relative_change_magnetic_permeability =
2028 effective_magnetic_permeabilities_current[q] -
2029 effective_magnetic_permeabilities_last_solved
2032 effective_magnetic_permeabilities_last_solved
2034 max_relative_change =
2035 std::max({relative_change_electric_permittivity,
2036 relative_change_magnetic_permeability,
2037 max_relative_change});
2046 max_relative_change =
2047 Utilities::MPI::max(max_relative_change, mpi_communicator);
2054 <<
" - The maximum relative change in the electromagnetics physical properties since the last time the time-harmonic Maxwell equations were solved is "
2055 << std::sqrt(max_relative_change) << std::endl;
2063 if (max_relative_change >
2076 AssertThrow(
false, ExcMessage(
"Unknown time coupling strategy."));
2093 .boundary_conditions_time_harmonic_electromagnetics;
2099 time_harmonic_maxwell_parameters));
2104 boundary_conditions));
2109 bool has_robin_boundary =
false;
2110 for (
const auto &bc : boundary_conditions.
type)
2113 has_robin_boundary =
true;
2114 if (has_robin_boundary)
2117 time_harmonic_maxwell_parameters,
2118 boundary_conditions,
2132 TimerOutput::Scope t(this->
computing_timer,
"Assemble matrix and RHS");
2144 const double omega =
2147 .electromagnetic_frequency;
2152 *this->fe_trial_interior,
2153 *this->fe_trial_skeleton,
2155 *this->cell_quadrature,
2156 *this->face_quadrature,
2162 const DoFHandler<dim> &dof_handler_ht =
2164 scratch_data.enable_temperature(dof_handler_ht.get_fe(),
2165 *this->cell_quadrature,
2166 *this->face_quadrature,
2175 const DoFHandler<dim> &dof_handler_void_fraction =
2177 scratch_data.enable_void_fraction(dof_handler_void_fraction.get_fe(),
2178 *this->cell_quadrature,
2179 *this->face_quadrature,
2185 this->dof_handler_trial_interior->end(),
2191 this->fe_trial_interior->n_dofs_per_cell(),
2192 this->fe_trial_skeleton->n_dofs_per_cell()));
2197 this->
system_rhs.compress(VectorOperation::add);
2203 const typename DoFHandler<dim>::active_cell_iterator &cell,
2209 const typename DoFHandler<dim>::active_cell_iterator cell_test =
2211 const typename DoFHandler<dim>::active_cell_iterator cell_skeleton =
2214 scratch_data.
reinit(cell, cell_test);
2218 typename DoFHandler<dim>::active_cell_iterator cell_temperature;
2222 cell_temperature = cell->as_dof_handler_iterator(
2224 temperature_solution =
2231 typename DoFHandler<dim>::active_cell_iterator cell_void_fraction;
2235 cell_void_fraction = cell->as_dof_handler_iterator(
2237 void_fraction_solution =
2240 *void_fraction_solution);
2252 assembler->assemble_matrix(scratch_data, copy_data);
2253 assembler->assemble_rhs(scratch_data, copy_data);
2258 for (
const unsigned int face_no : cell->face_indices())
2260 scratch_data.
reinit_face(cell_skeleton, cell_test, face_no);
2269 *temperature_solution);
2273 *void_fraction_solution);
2279 assembler->assemble_matrix(scratch_data, copy_data);
2280 assembler->assemble_rhs(scratch_data, copy_data);
2294 copy_data.
G_matrix.set_property(LAPACKSupport::symmetric);
2295 copy_data.
G_matrix.compute_cholesky_factorization();
2306 copy_data.
M1_matrix.set_property(LAPACKSupport::symmetric);
2307 copy_data.
M1_matrix.compute_cholesky_factorization();
2313 const typename DoFHandler<dim>::active_cell_iterator &cell,
2318 if (!cell->is_locally_owned())
2383 this->system_matrix,
2399 const typename DoFHandler<dim>::active_cell_iterator &cell,
2404 if (!cell->is_locally_owned())
2495 MPI_Comm mpi_communicator = this->
triangulation->get_mpi_communicator();
2516 const double omega =
2519 .electromagnetic_frequency;
2524 *this->fe_trial_interior,
2525 *this->fe_trial_skeleton,
2527 *this->cell_quadrature,
2528 *this->face_quadrature,
2533 const DoFHandler<dim> &dof_handler_ht =
2535 scratch_data.enable_temperature(dof_handler_ht.get_fe(),
2536 *this->cell_quadrature,
2537 *this->face_quadrature,
2543 const DoFHandler<dim> &dof_handler_void_fraction =
2545 scratch_data.enable_void_fraction(dof_handler_void_fraction.get_fe(),
2546 *this->cell_quadrature,
2547 *this->face_quadrature,
2552 this->dof_handler_trial_interior->end(),
2558 this->fe_trial_interior->n_dofs_per_cell(),
2559 this->fe_trial_skeleton->n_dofs_per_cell()));
2582 this->
pcout <<
" Time-Harmonic Maxwell DPG residual: "
AuxiliaryPhysics(const Parameters::NonLinearSolver non_linear_solver_parameters)
AuxiliaryPhysics - Base constructor for Auxiliary physics. This constructor builds an auxiliary physi...
std::map< types::boundary_id, BoundaryType > type
Map containing the boundary id and the boundary type.
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...
LAPACKFullMatrix< double > M3_matrix
void reset()
Resets the uncondensed local system to zero. The matrix is also reset since LAPACKFullMatrix keeps t...
FullMatrix< double > local_matrix
LAPACKFullMatrix< double > G_inverse_B_hat
Vector< double > l_vector
Vector< double > local_residual
LAPACKFullMatrix< double > B_hat_matrix
LAPACKFullMatrix< double > M1_matrix
Vector< double > tmp_vector_reconstruction
LAPACKFullMatrix< double > M2_matrix
LAPACKFullMatrix< double > G_inverse_B
Vector< double > local_skeleton_solution
std::vector< types::global_dof_index > local_dof_indices
Vector< double > local_interior_rhs
std::vector< types::global_dof_index > local_dof_indices_trial_interior
Vector< double > local_interior_solution
double local_residual_norm_squared
LAPACKFullMatrix< double > M1_inverse_M2
LAPACKFullMatrix< double > G_matrix
LAPACKFullMatrix< double > B_matrix
unsigned int active_cell_index
LAPACKFullMatrix< double > tmp_matrix_M2M1M2
Vector< double > local_rhs
Class that manages the physical properties model which are required to calculate the various physical...
Class that assembles the cell terms of the ultraweak DPG formulation of the time-harmonic Maxwell equ...
Class that assembles the Robin boundary conditions of the time-harmonic Maxwell equations (silver_mul...
Class that assembles the skeleton terms of the ultraweak DPG formulation of the time-harmonic Maxwell...
This class implements a boundary condition type for the Time Harmonic Maxwell equation where the elec...
This class implements a boundary condition type for the Time Harmonic Maxwell equation where the magn...
Class that stores the information required by the assembly of the Discontinuous Petrov-Galerkin (DPG)...
void calculate_face_physical_properties()
Compute the effective electromagnetic properties at the face quadrature points from the fields gather...
void reinit_temperature(const typename DoFHandler< dim >::active_cell_iterator &cell_temperature, const VectorType &temperature_solution)
Evaluate the temperature field at the cell quadrature points.
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...
bool cell_material_needs_temperature
void reinit_face_temperature(const typename DoFHandler< dim >::active_cell_iterator &cell_temperature, const unsigned int face_no, const VectorType &temperature_solution)
Evaluate the temperature field at the quadrature points of a face of the current cell.
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.
void reinit_void_fraction(const typename DoFHandler< dim >::active_cell_iterator &cell_void_fraction, const VectorType &void_fraction_solution)
Evaluate the void fraction field at the cell quadrature points.
bool cell_material_needs_void_fraction
void reinit_face_void_fraction(const typename DoFHandler< dim >::active_cell_iterator &cell_void_fraction, const unsigned int face_no, const VectorType &void_fraction_solution)
Evaluate the void fraction field at the quadrature points of a face of the current cell.
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 ...
MultiphysicsInterface< dim > * multiphysics
std::shared_ptr< TrilinosWrappers::PreconditionIdentity > preconditioner
virtual void finish_simulation() override
Carry out the operations required to finish a simulation correctly.
void compute_electromagnetic_scaling(const PhysicalPropertiesManager &physical_properties_manager)
Compute the electromagnetic scaling factor used to non-dimensionalize the time-harmonic Maxwell syste...
std::shared_ptr< DoFHandler< dim > > dof_handler_test
TimerOutput computing_timer
IndexSet locally_relevant_dofs_trial_interior
void copy_local_matrix_to_global_matrix(const DPGCopyData ©_data)
Distribute the condensed skeleton system of a cell in the global system matrix and right-hand side.
double get_residual_rescale_metric() const override
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_vol...
void output_per_iteration_timer() override
Output the per iteration wallclock times.
virtual void pre_mesh_adaptation() override
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
virtual void compute_dpg_error(dealii::Vector< float > &estimated_error_per_cell)
Compute the DPG error estimator based on the energy norm residual used to refine mesh of the TimeHarm...
void scale_solution_components(const DoFHandler< dim > &dof_handler, GlobalVectorType &solution)
Scale the solution components by the electromagnetic scaling factor to recover the physical values of...
virtual void post_mesh_adaptation() override
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
void assemble_system_rhs() override
Assemble the rhs associated with the solver.
void setup_preconditioner() override
Sets up preconditioner of the system matrix.
void copy_local_interior_solution_to_global(const DPGCopyData ©_data)
WorkStream copier of the interior reconstruction. It adds the interior solution of a cell,...
void assemble_local_dpg_system(const typename DoFHandler< dim >::active_cell_iterator &cell, TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData ©_data)
Assemble the uncondensed local DPG system ( , , and ) of a cell with the cell and face assemblers,...
GlobalVectorType system_rhs
bool should_solve_auxiliary_physics() override
Manage if the auxiliary physics should be solved at the current iteration. By default,...
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
IndexSet locally_relevant_dofs_trial_skeleton
void assemble_system_matrix() override
Assemble the matrix associated with the solver.
const SimulationParameters< dim > & simulation_parameters
GlobalVectorType locally_owned_solution_interior
virtual void setup_dofs() override
Sets up the DofHandler and the degree of freedom associated with the physics.
virtual void update_boundary_conditions() override
Updates non zero constraints if the boundary is time-dependent.
IndexSet locally_owned_dofs_trial_skeleton
virtual void read_checkpoint() override
Set solution vector of Auxiliary Physics using checkpoint.
void compute_error_estimate(const std::pair< const Variable, Parameters::MultipleAdaptationParameters > &ivar, dealii::Vector< float > &estimated_error_per_cell) override
Compute the error estimator selected in the parameters for adaptive mesh refinement.
virtual std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for a...
bool needs_dpg_error_estimator
virtual void postprocess(bool first_iteration) override
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
void print_THM_setup_memory(const TrilinosWrappers::SparsityPattern &sparsity_pattern)
Print memory usage diagnostics after the THM setup.
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
std::shared_ptr< FiniteElement< dim > > fe_trial_skeleton
virtual std::vector< OutputStruct< dim, VectorType > > gather_output_hook() override
Gather and return vector of output structs that are particular to some applications.
double squared_residual_L2_norm
virtual void percolate_time_vectors() override
Carry out the operations required to rearrange the values of the previous solution at the end of a ti...
const FEValuesExtractors::Vector extractor_E_real
const FEValuesExtractors::Vector extractor_E_imag
std::vector< double > waveguide_ports_electric_amplitudes
std::shared_ptr< SimulationControl > simulation_control
std::shared_ptr< GlobalVectorType > present_solution_skeleton
IndexSet locally_owned_dofs_trial_interior
AffineConstraints< double > nonzero_constraints
double electromagnetic_scaling
GlobalVectorType initial_guess_iterative_solver
void update_material_properties_dependencies()
Updates the containers that store the properties from which the material properties of the time-harmo...
void define_constraints()
Define the constraints for the TimeHarmonicMaxwell solver. This is equivalent to the define_non_zero_...
void print_memory_consumption(const dealii::ConditionalOStream &pcout, const std::string &str, const unsigned int n_rank, const std::vector< double > &memory_object)
This helper function helps to compute the memory consumption of different objects on each rank and pr...
virtual void write_checkpoint() override
Prepares auxiliary physics to write checkpoint.
std::shared_ptr< DoFHandler< dim > > dof_handler_trial_interior
void reconstruct_local_interior_solution(const typename DoFHandler< dim >::active_cell_iterator &cell, TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData ©_data)
WorkStream worker of the interior reconstruction. It assembles the local DPG system of a cell with as...
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > temperature_last_solved_solution_transfer
TimeHarmonicMaxwell(MultiphysicsInterface< dim > *multiphysics_interface, const SimulationParameters< dim > &p_simulation_parameters, const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &p_triangulation, std::shared_ptr< SimulationControl > p_simulation_control)
Constructor.
virtual void set_initial_conditions() override
Sets up the initial conditions associated with the physics. Generally, most physics only support impo...
void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, TimeHarmonicMaxwellScratchData< dim > &scratch_data, DPGCopyData ©_data)
Assemble the local DPG system of a cell using the function assemble_local_dpg_system and condense it ...
std::shared_ptr< Quadrature< dim > > cell_quadrature
std::shared_ptr< FiniteElement< dim > > fe_test
void compute_kelly(dealii::Vector< float > &estimated_error_per_cell, const ComponentMask &component_mask)
Compute the Kelly error estimator on the electromagnetic variable for mesh refinement....
const FEValuesExtractors::Vector extractor_H_real
ConvergenceTable error_table
Vector< float > local_estimated_error_per_cell
const FEValuesExtractors::Vector extractor_H_imag
void solve_linear_system() override
Solve the linear system using the CG solver.
std::shared_ptr< FiniteElement< dim > > fe_trial_interior
std::vector< double > calculate_L2_error()
Calculates the L2 error of the solution. It returns a vector of doubles containing the L2 errors of t...
std::shared_ptr< DoFHandler< dim > > dof_handler_trial_skeleton
virtual void modify_solution() override
Carry out modifications on the auxiliary physics solution. To be defined for some physics only (eg....
TrilinosWrappers::SparseMatrix system_matrix
void setup_assemblers()
Set up the cell and face assemblers of the DPG system according to the simulation parameters.
std::shared_ptr< GlobalVectorType > present_solution
void verify_consistency_of_boundary_conditions()
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary ...
std::vector< std::shared_ptr< TimeHarmonicMaxwellFaceAssemblerBase< dim > > > face_assemblers
std::vector< std::shared_ptr< TimeHarmonicMaxwellAssemblerBase< dim > > > assemblers
void reconstruct_interior_solution()
Reconstruct the interior solution from the skeleton solution after solving the linear system on the s...
std::shared_ptr< Mapping< dim > > mapping
GlobalVectorType temperature_last_solved_solution
void serialize_tables_vector(const std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Serializes all the TableHandler objects in table_output_structs.
void announce_string(const ConditionalOStream &pcout, const std::string &expression, const char delimiter='-')
Prints a string and then adds a line above and below made with dashes containing as many dashes as th...
void deserialize_tables_vector(std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Deserializes all the TableHandler objects in table_output_structs.
Identifiers for multiphysics modules and their solution fields.
@ electromagnetic_fields
Combination of both electric and magnetic fields from electromagnetics.
@ magnetic_field
Magnetic field vector field from electromagnetics.
@ electric_field
Electric field vector field from electromagnetics.
@ VANS
Volume-averaged Navier-Stokes (VANS) equations.
@ electromagnetics
Time-harmonic electromagnetics (Electric field, Magnetic field).
@ heat_transfer
Heat transfer (Temperature).
TimeHarmonicMaxwellBoundaryType
Boundary condition types of the time-harmonic Maxwell equations.
std::pair< double, double > calculate_L2_error(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Function< dim > *exact_solution, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculates the L2 norm of the error on velocity and pressure.
Struct containing information about the solution output. It is used to pass all the information requi...
TimeHarmonicMaxwell - Defines the parameters for time-harmonic Maxwell simulations.
unsigned int coupling_iteration
Parameters::TimeHarmonicMaxwellCouplingStrategy time_coupling_strategy
double coupling_threshold
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...
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...
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....
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType