Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
tracer.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#include <core/bdf.h>
7#include <core/utilities.h>
8
9#include <solvers/tracer.h>
12
13#include <deal.II/base/work_stream.h>
14
15#include <deal.II/dofs/dof_renumbering.h>
16#include <deal.II/dofs/dof_tools.h>
17
18#include <deal.II/grid/grid_tools.h>
19
20#include <deal.II/lac/affine_constraints.h>
21#include <deal.II/lac/dynamic_sparsity_pattern.h>
22#include <deal.II/lac/solver_control.h>
23#include <deal.II/lac/sparsity_tools.h>
24#include <deal.II/lac/trilinos_precondition.h>
25#include <deal.II/lac/trilinos_solver.h>
26
27#include <deal.II/meshworker/mesh_loop.h>
28
29#include <deal.II/numerics/error_estimator.h>
30#include <deal.II/numerics/vector_tools.h>
31
32#include <map>
33
34template <int dim>
35void
37{
38 AssertThrow(time_stepping_is_sdirk(
39 this->simulation_control->get_assembly_method()) == false,
40 ExcMessage(
41 "The SDIRK scheme is not yet supported for this physics"));
42
43 this->assemblers.clear();
44
45 // Time-stepping schemes
46 if (time_stepping_is_bdf(this->simulation_control->get_assembly_method()))
47 {
48 this->assemblers.emplace_back(
49 std::make_shared<TracerAssemblerBDF<dim>>(this->simulation_control));
50 }
51 // Core assemblers are different between DG and CG versions.
52 if (simulation_parameters.fem_parameters.tracer_uses_dg)
53 {
54 this->assemblers.emplace_back(
55 std::make_shared<TracerAssemblerDGCore<dim>>());
56 this->inner_face_assembler = std::make_shared<TracerAssemblerSIPG<dim>>();
58 std::make_shared<TracerAssemblerBoundaryNitsche<dim>>(
59 simulation_parameters.tracer_boundary_conditions);
60
61 // The mortar feature cannot be used with DG elements yet
62 if (simulation_parameters.mortar_parameters.enable)
63 AssertThrow(
64 false,
65 ExcMessage(
66 "Mortar coupling is not yet supported for the tracer physics when the DG formulation is used."));
67 }
68 else
69 {
70 this->assemblers.emplace_back(
71 std::make_shared<TracerAssemblerCore<dim>>(this->simulation_control));
72 }
73
74 auto reaction_constant_model =
75 simulation_parameters.physical_properties_manager
76 .get_tracer_reaction_prefactor();
77 if (!std::dynamic_pointer_cast<NoneTracerReactionPrefactor>(
78 reaction_constant_model))
79 this->assemblers.emplace_back(
80 std::make_shared<TracerAssemblerReaction<dim>>(this->simulation_control));
81}
82
83template <int dim>
84void
86{
87 TimerOutput::Scope t(this->computing_timer, "Assemble matrix");
88
89 this->system_matrix = 0;
91
92 // Update the source term time
93 simulation_parameters.source_term.tracer_source->set_time(
94 simulation_control->get_current_time());
95
96 if (simulation_parameters.fem_parameters.tracer_uses_dg)
98 else
100}
101
102template <int dim>
103void
105{
106 const DoFHandler<dim> &dof_handler_fluid =
107 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
108
109 auto scratch_data = TracerScratchData<dim>(
110 this->simulation_parameters.physical_properties_manager,
111 *this->fe,
112 *this->cell_quadrature,
113 *this->face_quadrature,
114 *this->get_mapping(),
115 dof_handler_fluid.get_fe(),
116 /*uses_dg = */ false);
117
118 WorkStream::run(this->dof_handler->begin_active(),
119 this->dof_handler->end(),
120 *this,
123 scratch_data,
124 StabilizedMethodsCopyData(this->fe->n_dofs_per_cell(),
125 this->cell_quadrature->size()));
126
127 // Add mortar entries
128 if (this->simulation_parameters.mortar_parameters.enable)
129 {
130 this->computing_timer.enter_subsection("Assemble matrix (mortar)");
131 this->mortar_coupling_operator->add_system_matrix_entries(
132 this->system_matrix);
133 this->computing_timer.leave_subsection("Assemble matrix (mortar)");
134 }
135
136 system_matrix.compress(VectorOperation::add);
137}
138
139
140template <int dim>
141void
143{
144 const DoFHandler<dim> &dof_handler_fluid =
145 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
146
147 auto scratch_data = TracerScratchData<dim>(
148 this->simulation_parameters.physical_properties_manager,
149 *this->fe,
150 *this->cell_quadrature,
151 *this->face_quadrature,
152 *this->get_mapping(),
153 dof_handler_fluid.get_fe(),
154 /*uses_dg = */ true);
155
156 StabilizedDGMethodsCopyData copy_data(this->fe->n_dofs_per_cell(),
157 this->cell_quadrature->size());
158
159 // We first wrap the assembly of the matrix within a cell_worker lambda
160 // function. This is only done for compatibility reasons with the MeshWorker
161 // paradigm and does not have any functional purpose.
162 const auto cell_worker =
163 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
164 TracerScratchData<dim> &scratch_data,
165 StabilizedDGMethodsCopyData &copy_data) {
166 this->assemble_local_system_matrix(cell, scratch_data, copy_data);
167 };
168
169 const auto boundary_worker =
170 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
171 const unsigned int &face_no,
172 TracerScratchData<dim> &scratch_data,
173 StabilizedDGMethodsCopyData &copy_data) {
174 const auto boundary_index = cell->face(face_no)->boundary_id();
175
176 scratch_data.reinit_boundary_face(cell,
177 face_no,
178 boundary_index,
179 this->evaluation_point);
180
181 scratch_data.reinit_signed_distance_at_face(
182 cell, face_no, this->multiphysics->get_immersed_solid_shape());
183
184 // Gather velocity information at the face to properly advect
185 const DoFHandler<dim> &dof_handler_fluid =
186 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
187 // Get the cell that corresponds to the fluid dynamics
188 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
189 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
190
191 // Reinit the internal face velocity within the scratch data
193 face_no,
194 scratch_data);
195
196 scratch_data.calculate_face_physical_properties();
197
198 this->boundary_face_assembler->assemble_matrix(scratch_data, copy_data);
199 };
200
201 const auto face_worker =
202 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
203 const unsigned int &face_no,
204 const unsigned int &sub_face_no,
205 const typename DoFHandler<dim>::active_cell_iterator &neigh_cell,
206 const unsigned int &neigh_face_no,
207 const unsigned int &neigh_sub_face_no,
208 TracerScratchData<dim> &scratch_data,
209 StabilizedDGMethodsCopyData &copy_data) {
210 scratch_data.reinit_internal_face(cell,
211 face_no,
212 sub_face_no,
213 neigh_cell,
214 neigh_face_no,
215 neigh_sub_face_no,
216 this->evaluation_point);
217
218 scratch_data.reinit_signed_distance_at_face(
219 cell, face_no, this->multiphysics->get_immersed_solid_shape());
220
221 // Pad copy_data memory for the internal faces elementary matrices
222 // BB note : Array could be pre-allocated
223 copy_data.face_data.emplace_back();
224 auto &copy_data_face = copy_data.face_data.back();
225 copy_data_face.face_matrix.reinit(scratch_data.n_interface_dofs,
226 scratch_data.n_interface_dofs);
227 copy_data_face.joint_dof_indices =
228 scratch_data.fe_interface_values_tracer.get_interface_dof_indices();
229
230 // Gather velocity information at the face to properly advect
231 const DoFHandler<dim> &dof_handler_fluid =
232 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
233 // Get the cell that corresponds to the fluid dynamics
234 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
235 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
236
237 // Reinit the internal face velocity within the scratch data
239 face_no,
240 scratch_data);
241
242 scratch_data.calculate_face_physical_properties();
243
244 this->inner_face_assembler->assemble_matrix(scratch_data, copy_data);
245 };
246
247 const auto copier = [&](const StabilizedDGMethodsCopyData &copy_data) {
248 this->copy_local_matrix_to_global_matrix(copy_data);
249
250 const AffineConstraints<double> &constraints_used = this->zero_constraints;
251
252 for (const auto &cdf : copy_data.face_data)
253 {
254 constraints_used.distribute_local_to_global(cdf.face_matrix,
255 cdf.joint_dof_indices,
257 }
258 };
259
260 MeshWorker::mesh_loop(this->dof_handler->begin_active(),
261 this->dof_handler->end(),
262 cell_worker,
263 copier,
264 scratch_data,
265 copy_data,
266 MeshWorker::assemble_own_cells |
267 MeshWorker::assemble_boundary_faces |
268 MeshWorker::assemble_own_interior_faces_once |
269 MeshWorker::assemble_ghost_faces_both,
270 boundary_worker,
271 face_worker);
272}
273
274
275
276template <int dim>
277void
279 const typename DoFHandler<dim>::active_cell_iterator &cell,
280 TracerScratchData<dim> &scratch_data,
281 StabilizedMethodsCopyData &copy_data)
282{
283 copy_data.cell_is_local = cell->is_locally_owned();
284 if (!cell->is_locally_owned())
285 return;
286
287 scratch_data.reinit(cell,
288 this->evaluation_point,
289 *this->previous_solutions,
290 &(*simulation_parameters.source_term.tracer_source));
291
292 scratch_data.reinit_signed_distance(
293 cell, this->multiphysics->get_immersed_solid_shape());
294
295 const DoFHandler<dim> &dof_handler_fluid =
296 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
297
298 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
299 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
300
301 if (multiphysics->fluid_dynamics_is_block())
302 {
303 // Check if the post processed variable needs to be calculated with the
304 // average velocity profile or the fluid solution.
305 if (this->simulation_parameters.initial_condition->type ==
307 average_velocity_profile &&
308 !this->simulation_parameters.multiphysics.fluid_dynamics &&
309 simulation_control->get_current_time() >
310 this->simulation_parameters.post_processing
311 .initial_time_for_average_velocities)
312 {
313 scratch_data.reinit_velocity(
314 velocity_cell,
315 multiphysics->get_block_time_average_solution(
317 this->simulation_parameters.ale,
318 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
319 }
320 else
321 {
322 scratch_data.reinit_velocity(
323 velocity_cell,
324 multiphysics->get_block_solution(PhysicsID::fluid_dynamics),
325 this->simulation_parameters.ale,
326 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
327 }
328 }
329 else
330 {
331 // Check if the post processed variable needs to be calculated with the
332 // average velocity profile or the fluid solution.
333 if (this->simulation_parameters.initial_condition->type ==
335 average_velocity_profile &&
336 !this->simulation_parameters.multiphysics.fluid_dynamics &&
337 simulation_control->get_current_time() >
338 this->simulation_parameters.post_processing
339 .initial_time_for_average_velocities)
340 {
341 scratch_data.reinit_velocity(
342 velocity_cell,
343 multiphysics->get_time_average_solution(PhysicsID::fluid_dynamics),
344 this->simulation_parameters.ale,
345 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
346 }
347 else
348 {
349 scratch_data.reinit_velocity(
350 velocity_cell,
352 this->simulation_parameters.ale,
353 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
354 }
355 }
356
357 if (this->simulation_parameters.mortar_parameters.enable)
358 scratch_data.reinit_mortar(cell,
359 this->simulation_parameters.mortar_parameters,
360 this->simulation_control->get_current_time());
361
362 scratch_data.calculate_physical_properties();
363 copy_data.reset();
364
365 for (auto &assembler : this->assemblers)
366 {
367 assembler->assemble_matrix(scratch_data, copy_data);
368 }
369
370
371 cell->get_dof_indices(copy_data.local_dof_indices);
372}
373
374template <int dim>
375void
377 const StabilizedMethodsCopyData &copy_data)
378{
379 if (!copy_data.cell_is_local)
380 return;
381
382 const AffineConstraints<double> &constraints_used = this->zero_constraints;
383 constraints_used.distribute_local_to_global(copy_data.local_matrix,
384 copy_data.local_dof_indices,
386}
387
388template <int dim>
389void
391{
392 TimerOutput::Scope t(this->computing_timer, "Assemble RHS");
393
394 // TimerOutput::Scope t(this->computing_timer, "Assemble RHS");
395 this->system_rhs = 0;
397
398 // Update the source term time
399 simulation_parameters.source_term.tracer_source->set_time(
400 simulation_control->get_current_time());
401
402
403 if (simulation_parameters.fem_parameters.tracer_uses_dg)
405
406 else
408}
409
410
411template <int dim>
412void
414{
415 const DoFHandler<dim> &dof_handler_fluid =
416 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
417
418 auto scratch_data = TracerScratchData<dim>(
419 this->simulation_parameters.physical_properties_manager,
420 *this->fe,
421 *this->cell_quadrature,
422 *this->face_quadrature,
423 *this->get_mapping(),
424 dof_handler_fluid.get_fe(),
425 /*uses_dg = */ false);
426
427 WorkStream::run(this->dof_handler->begin_active(),
428 this->dof_handler->end(),
429 *this,
432 scratch_data,
433 StabilizedMethodsCopyData(this->fe->n_dofs_per_cell(),
434 this->cell_quadrature->size()));
435
436 // Add mortar entries
437 if (this->simulation_parameters.mortar_parameters.enable)
438 {
439 this->computing_timer.enter_subsection("Assemble RHS (mortar)");
440 // Change sign of RHS to be compatible with mortar coupling terms
441 this->system_rhs.compress(VectorOperation::add);
442 this->system_rhs *= -1.0;
443 this->mortar_coupling_operator->vmult_add(this->system_rhs,
444 this->evaluation_point);
445 // Return RHS to original sign
446 this->system_rhs *= -1.0;
447
448 this->computing_timer.leave_subsection("Assemble RHS (mortar)");
449 }
450
451 this->system_rhs.compress(VectorOperation::add);
452}
453
454template <int dim>
455void
457{
458 const DoFHandler<dim> &dof_handler_fluid =
459 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
460
461 auto scratch_data = TracerScratchData<dim>(
462 this->simulation_parameters.physical_properties_manager,
463 *this->fe,
464 *this->cell_quadrature,
465 *this->face_quadrature,
466 *this->get_mapping(),
467 dof_handler_fluid.get_fe(),
468 /*uses_dg = */ true);
469
470 StabilizedDGMethodsCopyData copy_data(this->fe->n_dofs_per_cell(),
471 this->cell_quadrature->size());
472
473 const auto cell_worker =
474 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
475 TracerScratchData<dim> &scratch_data,
476 StabilizedDGMethodsCopyData &copy_data) {
477 this->assemble_local_system_rhs(cell, scratch_data, copy_data);
478 };
479
480 const auto boundary_worker =
481 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
482 const unsigned int &face_no,
483 TracerScratchData<dim> &scratch_data,
484 StabilizedDGMethodsCopyData &copy_data) {
485 // Identify which boundary condition corresponds to the boundary id.
486 const auto boundary_index = cell->face(face_no)->boundary_id();
487
488 scratch_data.reinit_boundary_face(cell,
489 face_no,
490 boundary_index,
491 this->evaluation_point);
492
493 scratch_data.reinit_signed_distance_at_face(
494 cell, face_no, this->multiphysics->get_immersed_solid_shape());
495
496 // Gather velocity information at the face to properly advect
497 // First gather the dof handler for the fluid dynamics
498 const DoFHandler<dim> &dof_handler_fluid =
499 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
500 // Get the cell that corresponds to the fluid dynamics
501 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
502 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
503
505 face_no,
506 scratch_data);
507
508 scratch_data.calculate_face_physical_properties();
509
510 this->boundary_face_assembler->assemble_rhs(scratch_data, copy_data);
511 };
512
513 const auto face_worker =
514 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
515 const unsigned int &face_no,
516 const unsigned int &sub_face_no,
517 const typename DoFHandler<dim>::active_cell_iterator &neigh_cell,
518 const unsigned int &neigh_face_no,
519 const unsigned int &neigh_sub_face_no,
520 TracerScratchData<dim> &scratch_data,
522
523 {
524 scratch_data.reinit_internal_face(cell,
525 face_no,
526 sub_face_no,
527 neigh_cell,
528 neigh_face_no,
529 neigh_sub_face_no,
530 this->evaluation_point);
531
532 scratch_data.reinit_signed_distance_at_face(
533 cell, face_no, this->multiphysics->get_immersed_solid_shape());
534
535 copy_data.face_data.emplace_back();
536 auto &copy_data_face = copy_data.face_data.back();
537 copy_data_face.joint_dof_indices =
538 scratch_data.fe_interface_values_tracer.get_interface_dof_indices();
539 copy_data_face.face_rhs.reinit(scratch_data.n_interface_dofs);
540
541 // Gather velocity information at the face to properly advect
542 // First gather the dof handler for the fluid dynamics
543 const DoFHandler<dim> &dof_handler_fluid =
544 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
545 // Get the cell that corresponds to the fluid dynamics
546 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
547 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
548
550 face_no,
551 scratch_data);
552
553 scratch_data.calculate_face_physical_properties();
554
555 this->inner_face_assembler->assemble_rhs(scratch_data, copy_data);
556 };
557
558
559 const auto copier = [&](const StabilizedDGMethodsCopyData &c) {
561 const AffineConstraints<double> &constraints_used = this->zero_constraints;
562 for (const auto &cdf : c.face_data)
563 {
564 constraints_used.distribute_local_to_global(cdf.face_rhs,
565 cdf.joint_dof_indices,
566 system_rhs);
567 }
568 };
569
570 MeshWorker::mesh_loop(this->dof_handler->begin_active(),
571 this->dof_handler->end(),
572 cell_worker,
573 copier,
574 scratch_data,
575 copy_data,
576 MeshWorker::assemble_own_cells |
577 MeshWorker::assemble_boundary_faces |
578 MeshWorker::assemble_own_interior_faces_once |
579 MeshWorker::assemble_ghost_faces_both,
580 boundary_worker,
581 face_worker);
582}
583
584template <int dim>
585void
587 const typename DoFHandler<dim>::active_cell_iterator &cell,
588 TracerScratchData<dim> &scratch_data,
589 StabilizedMethodsCopyData &copy_data)
590{
591 copy_data.cell_is_local = cell->is_locally_owned();
592 if (!cell->is_locally_owned())
593 return;
594
595 // The time of the source term is set in assemble_system_rhs
596 scratch_data.reinit(cell,
597 this->evaluation_point,
598 *this->previous_solutions,
599 &(*simulation_parameters.source_term.tracer_source));
600
601 scratch_data.reinit_signed_distance(
602 cell, this->multiphysics->get_immersed_solid_shape());
603
604 const DoFHandler<dim> &dof_handler_fluid =
605 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
606
607 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
608 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
609
610 if (multiphysics->fluid_dynamics_is_block())
611 {
612 // Check if the post processed variable needs to be calculated with the
613 // average velocity profile or the fluid solution.
614 if (this->simulation_parameters.initial_condition->type ==
616 average_velocity_profile &&
617 !this->simulation_parameters.multiphysics.fluid_dynamics &&
618 simulation_control->get_current_time() >
619 this->simulation_parameters.post_processing
620 .initial_time_for_average_velocities)
621 {
622 scratch_data.reinit_velocity(
623 velocity_cell,
624 multiphysics->get_block_time_average_solution(
626 this->simulation_parameters.ale,
627 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
628 }
629 else
630 {
631 scratch_data.reinit_velocity(
632 velocity_cell,
633 multiphysics->get_block_solution(PhysicsID::fluid_dynamics),
634 this->simulation_parameters.ale,
635 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
636 }
637 }
638 else
639 {
640 // Check if the post processed variable needs to be calculated with the
641 // average velocity profile or the fluid solution.
642 if (this->simulation_parameters.initial_condition->type ==
644 average_velocity_profile &&
645 !this->simulation_parameters.multiphysics.fluid_dynamics &&
646 simulation_control->get_current_time() >
647 this->simulation_parameters.post_processing
648 .initial_time_for_average_velocities)
649 {
650 scratch_data.reinit_velocity(
651 velocity_cell,
652 multiphysics->get_time_average_solution(PhysicsID::fluid_dynamics),
653 this->simulation_parameters.ale,
654 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
655 }
656 else
657 {
658 scratch_data.reinit_velocity(
659 velocity_cell,
661 this->simulation_parameters.ale,
662 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
663 }
664 }
665
666 if (this->simulation_parameters.mortar_parameters.enable)
667 scratch_data.reinit_mortar(cell,
668 this->simulation_parameters.mortar_parameters,
669 this->simulation_control->get_current_time());
670
671 scratch_data.calculate_physical_properties();
672 copy_data.reset();
673
674 for (auto &assembler : this->assemblers)
675 {
676 assembler->assemble_rhs(scratch_data, copy_data);
677 }
678
679 cell->get_dof_indices(copy_data.local_dof_indices);
680}
681
682template <int dim>
683void
685 const StabilizedMethodsCopyData &copy_data)
686{
687 if (!copy_data.cell_is_local)
688 return;
689
690 const AffineConstraints<double> &constraints_used = this->zero_constraints;
691 constraints_used.distribute_local_to_global(copy_data.local_rhs,
692 copy_data.local_dof_indices,
693 system_rhs);
694}
695
696template <int dim>
697std::vector<OutputStruct<dim, GlobalVectorType>>
699{
700 std::vector<OutputStruct<dim, GlobalVectorType>> solution_output_structs;
701 std::vector<std::string> solution_names(1, "tracer");
702 std::vector<DataComponentInterpretation::DataComponentInterpretation>
703 component_interpretation(1,
704 DataComponentInterpretation::component_is_scalar);
705 solution_output_structs.emplace_back(
709 solution_names,
710 component_interpretation);
711 return solution_output_structs;
712}
713
714template <int dim>
715double
717{
718 auto mpi_communicator = triangulation->get_mpi_communicator();
719
720 FEValues<dim> fe_values(*this->get_mapping(),
721 *fe,
723 update_values | update_gradients |
724 update_quadrature_points | update_JxW_values);
725
726 const unsigned int n_q_points = cell_quadrature->size();
727
728 std::vector<double> q_exact_solution(n_q_points);
729 std::vector<double> q_scalar_values(n_q_points);
730
731 auto &exact_solution = simulation_parameters.analytical_solution->tracer;
732 exact_solution.set_time(simulation_control->get_current_time());
733
734 double l2error = 0.;
735
736 for (const auto &cell : dof_handler->active_cell_iterators())
737 {
738 if (cell->is_locally_owned())
739 {
740 fe_values.reinit(cell);
741 fe_values.get_function_values(*present_solution, q_scalar_values);
742
743 // Get the exact solution at all gauss points
744 exact_solution.value_list(fe_values.get_quadrature_points(),
745 q_exact_solution);
746
747 for (unsigned int q = 0; q < n_q_points; q++)
748 {
749 double sim = q_scalar_values[q];
750 double exact = q_exact_solution[q];
751 l2error += (sim - exact) * (sim - exact) * fe_values.JxW(q);
752 }
753 }
754 }
755 l2error = Utilities::MPI::sum(l2error, mpi_communicator);
756 return l2error;
757}
758
759template <int dim>
760void
762{
763 auto mpi_communicator = triangulation->get_mpi_communicator();
764 unsigned int this_mpi_process(
765 Utilities::MPI::this_mpi_process(mpi_communicator));
766
767 if (this_mpi_process == 0 &&
768 simulation_parameters.analytical_solution->verbosity ==
770 {
771 error_table.omit_column_from_convergence_rate_evaluation("cells");
772
773 if (simulation_parameters.simulation_control.method ==
775 {
776 error_table.evaluate_all_convergence_rates(
777 ConvergenceTable::reduction_rate_log2);
778 }
779 error_table.set_scientific("error_tracer", true);
780 error_table.set_precision("error_tracer",
781 simulation_control->get_log_precision());
782 error_table.write_text(std::cout);
783 }
784
786 {
787 announce_string(this->pcout, "Tracer");
788 this->pcout << std::defaultfloat;
789 this->computing_timer.print_summary();
790 this->pcout << std::scientific;
791 }
792}
793
794template <int dim>
795void
797{
798 for (unsigned int i = previous_solutions->size() - 1; i > 0; --i)
799 {
800 (*previous_solutions)[i] = (*previous_solutions)[i - 1];
801 }
802 (*previous_solutions)[0] = *this->present_solution;
803}
804
805template <int dim>
806void
807Tracer<dim>::postprocess(bool first_iteration)
808{
809 if (simulation_parameters.analytical_solution->calculate_error() == true &&
810 !first_iteration)
811 {
812 double tracer_error = calculate_L2_error();
813
814 error_table.add_value("cells",
815 this->triangulation->n_global_active_cells());
816 error_table.add_value("error_tracer", tracer_error);
817 error_table.set_scientific("error_tracer", true);
818
819 if (Utilities::MPI::this_mpi_process(
820 triangulation->get_mpi_communicator()) == 0)
821 {
822 const std::string filename =
823 simulation_parameters.simulation_control.output_folder +
824 simulation_parameters.analytical_solution->get_filename() +
825 "_tracer.dat";
826 std::ofstream output(filename.c_str());
827 error_table.write_text(output);
828 }
829
830 if (simulation_parameters.analytical_solution->verbosity ==
832 {
833 this->pcout << "L2 error tracer: " << tracer_error << std::endl;
834 }
835 }
836
837 if (simulation_parameters.post_processing.calculate_tracer_statistics)
838 {
840 if (simulation_control->get_iteration_number() %
841 this->simulation_parameters.post_processing.output_frequency ==
842 0)
844 }
845
846 // Calculate tracer flow rate at every boundary
847 if (this->simulation_parameters.post_processing.calculate_tracer_flow_rate)
848 {
849 TimerOutput::Scope t(this->computing_timer, "Calculate tracer flow rate");
850
851 if (this->simulation_parameters.post_processing.verbosity ==
853 {
854 announce_string(this->pcout, "Tracer flow rates");
855 }
856
857 std::map<types::boundary_id, double> tracer_flow_rates;
858 if (multiphysics->fluid_dynamics_is_block())
859 {
860 tracer_flow_rates = postprocess_tracer_flow_rate(
861 multiphysics->get_block_solution(PhysicsID::fluid_dynamics));
862 }
863 else
864 {
865 tracer_flow_rates = postprocess_tracer_flow_rate(
867 }
868 this->write_tracer_flow_rates(tracer_flow_rates);
869 }
870}
871
872template <int dim>
873void
875{
876 announce_string(this->pcout, "Tracer");
877 this->pcout << std::defaultfloat;
878 this->computing_timer.print_summary();
879 this->pcout << std::scientific;
880 this->computing_timer.reset();
881}
882
883template <int dim>
884void
886{
887 auto mpi_communicator = triangulation->get_mpi_communicator();
888
889 FEValues<dim> fe_values(*this->get_mapping(),
890 *fe,
892 update_values | update_gradients |
893 update_quadrature_points | update_JxW_values);
894
895 const unsigned int n_q_points = cell_quadrature->size();
896 std::vector<double> q_tracer_values(n_q_points);
897
898 double volume_integral = 0;
899 double max_tracer_value = DBL_MIN;
900 double min_tracer_value = DBL_MAX;
901
902 for (const auto &cell : dof_handler->active_cell_iterators())
903 {
904 if (cell->is_locally_owned())
905 {
906 fe_values.reinit(cell);
907 fe_values.get_function_values(*present_solution, q_tracer_values);
908
909 for (unsigned int q = 0; q < n_q_points; q++)
910 {
911 volume_integral += q_tracer_values[q] * fe_values.JxW(q);
912 max_tracer_value = std::max(q_tracer_values[q], max_tracer_value);
913 min_tracer_value = std::min(q_tracer_values[q], min_tracer_value);
914 }
915 }
916 }
917 volume_integral = Utilities::MPI::sum(volume_integral, mpi_communicator);
918 double global_volume =
919 GridTools::volume(*triangulation, *this->get_mapping());
920 double tracer_average = volume_integral / global_volume;
921
922 double variance_integral = 0;
923
924 for (const auto &cell : dof_handler->active_cell_iterators())
925 {
926 if (cell->is_locally_owned())
927 {
928 fe_values.reinit(cell);
929 fe_values.get_function_values(*present_solution, q_tracer_values);
930
931 for (unsigned int q = 0; q < n_q_points; q++)
932 {
933 variance_integral += (q_tracer_values[q] - tracer_average) *
934 (q_tracer_values[q] - tracer_average) *
935 fe_values.JxW(q);
936 }
937 }
938 }
939
940 variance_integral = Utilities::MPI::sum(variance_integral, mpi_communicator);
941 double tracer_variance = variance_integral / global_volume;
942 double tracer_std_deviation = std::sqrt(tracer_variance);
943
944 // Console output
945 if (simulation_parameters.post_processing.verbosity ==
947 {
948 this->pcout << "Tracer statistics: " << std::endl;
949 this->pcout << "\t Min: " << min_tracer_value << std::endl;
950 this->pcout << "\t Max: " << max_tracer_value << std::endl;
951 this->pcout << "\t Average: " << tracer_average << std::endl;
952 this->pcout << "\t Std-Dev: " << tracer_std_deviation << std::endl;
953 }
954
955 statistics_table.add_value("time", simulation_control->get_current_time());
956 statistics_table.set_scientific("time", true);
957 statistics_table.set_precision("time", 12);
958
959 statistics_table.add_value("min", min_tracer_value);
960 statistics_table.set_scientific("min", true);
961 statistics_table.set_precision("min", 12);
962
963 statistics_table.add_value("max", max_tracer_value);
964 statistics_table.set_scientific("max", true);
965 statistics_table.set_precision("max", 12);
966
967 statistics_table.add_value("average", tracer_average);
968 statistics_table.set_scientific("average", true);
969 statistics_table.set_precision("average", 12);
970
971 statistics_table.add_value("std-dev", tracer_std_deviation);
972 statistics_table.set_scientific("std-dev", true);
973 statistics_table.set_precision("std-dev", 12);
974}
975
976
977template <int dim>
978template <typename VectorType>
979std::map<types::boundary_id, double>
981{
982 const unsigned int n_q_points_face = this->face_quadrature->size();
983 const MPI_Comm mpi_communicator = this->dof_handler->get_mpi_communicator();
984
985 // Initialize tracer information
986 std::vector<double> tracer_values(n_q_points_face);
987 std::vector<Tensor<1, dim>> tracer_gradient(n_q_points_face);
988 FEFaceValues<dim> fe_face_values_tracer(*this->get_mapping(),
989 this->dof_handler->get_fe(),
990 *this->face_quadrature,
991 update_values | update_gradients |
992 update_JxW_values |
993 update_normal_vectors |
994 update_quadrature_points);
995
996 // Initialize fluid dynamics information
997 const DoFHandler<dim> &dof_handler_fd =
998 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
999 const FEValuesExtractors::Vector velocities(0);
1000 std::vector<Tensor<1, dim>> velocity_values(n_q_points_face);
1001 FEFaceValues<dim> fe_face_values_fd(*this->get_mapping(),
1002 dof_handler_fd.get_fe(),
1003 *this->face_quadrature,
1004 update_values);
1005
1006 // Initialize fluid properties
1007 auto &properties_manager =
1008 this->simulation_parameters.physical_properties_manager;
1009 std::map<field, std::vector<double>> fields;
1010
1011 const auto diffusivity_model = properties_manager.get_tracer_diffusivity();
1012
1013 std::vector<double> tracer_diffusivity(n_q_points_face);
1014 std::vector<Point<dim>> face_quadrature_points;
1015
1016 std::map<types::boundary_id, double> tracer_flow_rate;
1017
1018 // Get vector of all boundary conditions
1019 for (const auto &cell : this->dof_handler->active_cell_iterators())
1020 {
1021 if (cell->is_locally_owned() && cell->at_boundary())
1022 {
1023 for (const auto face : cell->face_indices())
1024 {
1025 if (cell->face(face)->at_boundary())
1026 {
1027 const auto boundary_id = cell->face(face)->boundary_id();
1028
1029 // Gather tracer information
1030 fe_face_values_tracer.reinit(cell, face);
1031 fe_face_values_tracer.get_function_values(
1032 *this->present_solution, tracer_values);
1033 fe_face_values_tracer.get_function_gradients(
1034 *this->present_solution, tracer_gradient);
1035
1036 // We update the fields required by the diffusivity
1037 // model
1038 fields.clear();
1039 if (diffusivity_model->depends_on(field::levelset))
1040 {
1041 std::vector<double> levelset_values(n_q_points_face);
1042 fields.insert(
1043 std::pair<field, std::vector<double>>(field::levelset,
1044 n_q_points_face));
1045 face_quadrature_points =
1046 fe_face_values_tracer.get_quadrature_points();
1047 this->multiphysics->get_immersed_solid_shape()
1048 ->value_list(face_quadrature_points, levelset_values);
1050 levelset_values,
1051 fields);
1052 }
1053
1054 diffusivity_model->vector_value(fields, tracer_diffusivity);
1055
1056 // Get fluid dynamics active cell iterator
1057 typename DoFHandler<dim>::active_cell_iterator cell_fd(
1058 &(*(this->triangulation)),
1059 cell->level(),
1060 cell->index(),
1061 &dof_handler_fd);
1062
1063 // Gather fluid dynamics information
1064 fe_face_values_fd.reinit(cell_fd, face);
1065 fe_face_values_fd[velocities].get_function_values(
1066 current_solution_fd, velocity_values);
1067
1068 // Loop on the quadrature points
1069 for (unsigned int q = 0; q < n_q_points_face; q++)
1070 {
1071 Tensor<1, dim> normal_vector_tracer =
1072 -fe_face_values_tracer.normal_vector(q);
1073
1074 tracer_flow_rate[boundary_id] +=
1075 (-tracer_diffusivity[q] * tracer_gradient[q] *
1076 normal_vector_tracer +
1077 tracer_values[q] * velocity_values[q] *
1078 normal_vector_tracer) *
1079 fe_face_values_tracer.JxW(q);
1080 } // end loop on quadrature points
1081 } // end face is a boundary face
1082 } // end loop on faces
1083 } // end condition cell at boundary
1084 } // end loop on cells
1085
1086
1087 // Sum across all cores
1088 for (auto const &[id, type] :
1089 this->simulation_parameters.boundary_conditions.type)
1090 tracer_flow_rate[id] =
1091 Utilities::MPI::sum(tracer_flow_rate[id], mpi_communicator);
1092
1093 return tracer_flow_rate;
1094}
1095
1096template <int dim>
1097void
1099 const std::map<types::boundary_id, double> &tracer_flow_rate_map)
1100{
1101 // Fill table
1102 this->tracer_flow_rate_table.add_value(
1103 "time", this->simulation_control->get_current_time());
1104 this->tracer_flow_rate_table.set_precision("time", 12);
1105 for (auto const &[id, value] : tracer_flow_rate_map)
1106 {
1107 this->tracer_flow_rate_table.add_value("flow-rate-" +
1108 Utilities::int_to_string(id, 2),
1109 value);
1110 this->tracer_flow_rate_table.set_scientific(
1111 "flow-rate-" + Utilities::int_to_string(id, 2), true);
1112 }
1113
1114 // Console output
1115 if (simulation_parameters.post_processing.verbosity ==
1117 {
1118 this->pcout << "Tracer flow rate at the boundaries: " << std::endl;
1119 for (auto const &[id, value] : tracer_flow_rate_map)
1120 this->pcout << "\t boundary " << id << ": " << value << std::endl;
1121 }
1122
1123 auto mpi_communicator = triangulation->get_mpi_communicator();
1124 if ((simulation_control->get_iteration_number() %
1125 this->simulation_parameters.post_processing.output_frequency ==
1126 0) &&
1127 Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
1128 {
1129 std::string filename =
1130 simulation_parameters.simulation_control.output_folder +
1131 simulation_parameters.post_processing.tracer_flow_rate_output_name +
1132 ".dat";
1133 std::ofstream output(filename.c_str());
1134 this->tracer_flow_rate_table.write_text(output);
1135 }
1136}
1137
1138template <int dim>
1139void
1141{
1142 auto mpi_communicator = triangulation->get_mpi_communicator();
1143
1144 if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
1145 {
1146 std::string filename =
1147 simulation_parameters.simulation_control.output_folder +
1148 simulation_parameters.post_processing.tracer_output_name + ".dat";
1149 std::ofstream output(filename.c_str());
1150
1151
1152 statistics_table.write_text(output);
1153 }
1154}
1155
1156template <int dim>
1157void
1159{
1160 solution_transfer->prepare_for_coarsening_and_refinement(*present_solution);
1161
1162 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
1163 {
1164 previous_solutions_transfer[i].prepare_for_coarsening_and_refinement(
1165 (*previous_solutions)[i]);
1166 }
1167}
1168
1169template <int dim>
1170void
1172{
1173 auto mpi_communicator = triangulation->get_mpi_communicator();
1174
1175 // Set up the vectors for the transfer
1176 GlobalVectorType tmp(locally_owned_dofs, mpi_communicator);
1177
1178 // Interpolate the solution at time and previous time
1179 solution_transfer->interpolate(tmp);
1180
1181 // Distribute constraints
1182 nonzero_constraints.distribute(tmp);
1183
1184 // Fix on the new mesh
1185 *present_solution = tmp;
1186
1187 // Transfer previous solutions
1188 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
1189 {
1190 GlobalVectorType tmp_previous_solution(locally_owned_dofs,
1191 mpi_communicator);
1192 previous_solutions_transfer[i].interpolate(tmp_previous_solution);
1193 nonzero_constraints.distribute(tmp_previous_solution);
1194 (*previous_solutions)[i] = tmp_previous_solution;
1195 }
1196}
1197
1198template <int dim>
1199std::vector<OutputStructTableHandler>
1201{
1202 std::vector<OutputStructTableHandler> table_output_structs;
1203
1204 std::string prefix =
1205 this->simulation_parameters.simulation_control.output_folder;
1206 std::string suffix = ".checkpoint";
1207
1208 if (this->simulation_parameters.analytical_solution->calculate_error())
1209 table_output_structs.emplace_back(
1210 this->error_table,
1211 prefix + this->simulation_parameters.analytical_solution->get_filename() +
1212 "_tracer" + suffix);
1213
1214 if (this->simulation_parameters.post_processing.calculate_tracer_statistics)
1215 table_output_structs.emplace_back(
1216 this->statistics_table,
1217 prefix + this->simulation_parameters.post_processing.tracer_output_name +
1218 suffix);
1219
1220 if (this->simulation_parameters.post_processing.calculate_tracer_flow_rate)
1221 table_output_structs.emplace_back(
1223 prefix +
1224 this->simulation_parameters.post_processing
1225 .tracer_flow_rate_output_name +
1226 suffix);
1227
1228 return table_output_structs;
1229}
1230
1231template <int dim>
1232void
1234{
1235 auto mpi_communicator = this->triangulation->get_mpi_communicator();
1236 std::vector<const GlobalVectorType *> sol_set_transfer;
1237
1239 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
1240
1241 sol_set_transfer.emplace_back(&(*present_solution));
1242 for (const auto &previous_solution : *previous_solutions)
1243 {
1244 sol_set_transfer.emplace_back(&previous_solution);
1245 }
1246 solution_transfer->prepare_for_serialization(sol_set_transfer);
1247
1248 // Serialize all post-processing tables that are currently used with the
1249 // Tracer solver
1250 const std::vector<OutputStructTableHandler> &table_output_structs =
1251 this->gather_tables();
1252 serialize_tables_vector(table_output_structs, mpi_communicator);
1253}
1254
1255template <int dim>
1256void
1258{
1259 auto mpi_communicator = triangulation->get_mpi_communicator();
1260 this->pcout << "Reading tracer checkpoint" << std::endl;
1261
1262 std::vector<GlobalVectorType *> input_vectors(1 + previous_solutions->size());
1263 GlobalVectorType distributed_system(locally_owned_dofs, mpi_communicator);
1264 input_vectors[0] = &distributed_system;
1265
1266
1267 std::vector<GlobalVectorType> distributed_previous_solutions;
1268 distributed_previous_solutions.reserve(previous_solutions->size());
1269 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
1270 {
1271 distributed_previous_solutions.emplace_back(
1272 GlobalVectorType(locally_owned_dofs, mpi_communicator));
1273 input_vectors[i + 1] = &distributed_previous_solutions[i];
1274 }
1275
1276 solution_transfer->deserialize(input_vectors);
1277
1278 *present_solution = distributed_system;
1279 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
1280 {
1281 (*previous_solutions)[i] = distributed_previous_solutions[i];
1282 }
1283
1284 // Deserialize all post-processing tables that are currently used with the
1285 // Tracer solver
1286 std::vector<OutputStructTableHandler> table_output_structs =
1287 this->gather_tables();
1288 deserialize_tables_vector(table_output_structs, mpi_communicator);
1289}
1290
1291
1292template <int dim>
1293void
1295{
1297
1298 dof_handler->distribute_dofs(*fe);
1299 DoFRenumbering::Cuthill_McKee(*this->dof_handler);
1300
1301 auto mpi_communicator = triangulation->get_mpi_communicator();
1302
1303
1304 locally_owned_dofs = dof_handler->locally_owned_dofs();
1305 locally_relevant_dofs = DoFTools::extract_locally_relevant_dofs(*dof_handler);
1306
1307 // If enabled, rotate rotor mapping
1308 this->rotate_rotor_mapping();
1309
1312 mpi_communicator);
1313
1314 // Previous solutions for transient schemes
1315 for (auto &solution : *this->previous_solutions)
1316 {
1317 solution.reinit(locally_owned_dofs,
1319 mpi_communicator);
1320 }
1321
1322 system_rhs.reinit(locally_owned_dofs, mpi_communicator);
1323
1324 newton_update.reinit(locally_owned_dofs, mpi_communicator);
1325
1326 local_evaluation_point.reinit(this->locally_owned_dofs, mpi_communicator);
1327
1329
1330 // Boundary conditions for Newton correction
1332
1333 // If enabled, create mortar operators
1335
1336 // Sparse matrices initialization
1337 DynamicSparsityPattern dsp(locally_relevant_dofs);
1338
1339
1340 if (simulation_parameters.fem_parameters.tracer_uses_dg)
1341 {
1342 DoFTools::make_flux_sparsity_pattern(*this->dof_handler,
1343 dsp,
1345 /*keep_constrained_dofs = */ true);
1346 }
1347 else
1348 {
1349 DoFTools::make_sparsity_pattern(*this->dof_handler,
1350 dsp,
1352 /*keep_constrained_dofs = */ true);
1353 }
1354
1355
1356 // Add sparsity pattern entries
1357 if (this->simulation_parameters.mortar_parameters.enable)
1358 this->mortar_coupling_operator->add_sparsity_pattern_entries(dsp);
1359
1360 SparsityTools::distribute_sparsity_pattern(dsp,
1362 mpi_communicator,
1366 dsp,
1367 mpi_communicator);
1368
1369 this->pcout << " Number of tracer degrees of freedom: "
1370 << dof_handler->n_dofs() << std::endl;
1371
1372 // Provide the tracer dof_handler and present solution pointers to the
1373 // multiphysics interface
1374 multiphysics->set_dof_handler(PhysicsID::tracer, this->dof_handler);
1375 multiphysics->set_mapping(PhysicsID::tracer, this->mapping);
1376 multiphysics->set_solution(PhysicsID::tracer, this->present_solution);
1377 multiphysics->set_previous_solutions(PhysicsID::tracer,
1378 this->previous_solutions);
1379}
1380
1381template <int dim>
1382void
1384{
1386
1387 if (!this->simulation_parameters.tracer_boundary_conditions.time_dependent)
1388 return;
1389
1390 double time = this->simulation_control->get_current_time();
1391 nonzero_constraints.clear();
1393 this->locally_relevant_dofs);
1394 DoFTools::make_hanging_node_constraints(*this->dof_handler,
1396
1397 for (auto const &[id, type] :
1398 this->simulation_parameters.tracer_boundary_conditions.type)
1399 {
1400 // Dirichlet condition : imposed temperature at i_bc
1402 {
1403 this->simulation_parameters.tracer_boundary_conditions.tracer.at(id)
1404 ->set_time(time);
1405 VectorTools::interpolate_boundary_values(
1406 *this->dof_handler,
1407 id,
1408 *this->simulation_parameters.tracer_boundary_conditions.tracer.at(
1409 id),
1411 }
1413 {
1414 const auto &periodic_boundary =
1415 this->simulation_parameters.tracer_boundary_conditions
1416 .periodic_boundaries.at(id);
1417 DoFTools::make_periodicity_constraints(*this->dof_handler,
1418 id,
1419 periodic_boundary.neighbor_id,
1420 periodic_boundary.direction,
1422 }
1424 {
1425 /* Do nothing */
1426 }
1427 }
1428 nonzero_constraints.close();
1431}
1432
1433template <int dim>
1434void
1436{
1437 zero_constraints.clear();
1439 this->locally_relevant_dofs);
1440 DoFTools::make_hanging_node_constraints(*this->dof_handler, zero_constraints);
1441
1442 for (auto const &[id, type] :
1443 this->simulation_parameters.tracer_boundary_conditions.type)
1444 {
1446 {
1447 VectorTools::interpolate_boundary_values(
1448 *this->dof_handler,
1449 id,
1450 Functions::ZeroFunction<dim>(),
1452 }
1454 {
1455 const auto &periodic_boundary =
1456 this->simulation_parameters.tracer_boundary_conditions
1457 .periodic_boundaries.at(id);
1458 DoFTools::make_periodicity_constraints(*this->dof_handler,
1459 id,
1460 periodic_boundary.neighbor_id,
1461 periodic_boundary.direction,
1463 }
1465 {
1466 /* Do nothing */
1467 }
1468 }
1469 zero_constraints.close();
1470}
1471
1472template <int dim>
1473void
1475{
1476 nonzero_constraints.clear();
1478 DoFTools::make_hanging_node_constraints(*this->dof_handler,
1480
1481 for (auto const &[id, type] :
1482 this->simulation_parameters.tracer_boundary_conditions.type)
1483 {
1484 // Dirichlet condition : imposed temperature at i_bc
1486 {
1487 VectorTools::interpolate_boundary_values(
1488 *this->dof_handler,
1489 id,
1490 *this->simulation_parameters.tracer_boundary_conditions.tracer.at(
1491 id),
1493 }
1495 {
1496 const auto &periodic_boundary =
1497 this->simulation_parameters.tracer_boundary_conditions
1498 .periodic_boundaries.at(id);
1499 DoFTools::make_periodicity_constraints(*this->dof_handler,
1500 id,
1501 periodic_boundary.neighbor_id,
1502 periodic_boundary.direction,
1504 }
1506 {
1507 /* Do nothing */
1508 }
1509 }
1510 nonzero_constraints.close();
1511}
1512
1513template <int dim>
1514void
1516{
1517 VectorTools::interpolate(*this->get_mapping(),
1518 *dof_handler,
1519 simulation_parameters.initial_condition->tracer,
1524}
1525
1526template <int dim>
1527void
1529 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
1530 &ivar,
1531 dealii::Vector<float> &estimated_error_per_cell)
1532{
1533 if (ivar.first == Variable::tracer)
1534 {
1535 AssertThrow(
1536 ivar.second.error_estimator ==
1538 ExcMessage(
1539 "Only the Kelly error estimator is currently implemented for the "
1540 "<tracer> field."));
1541
1542
1543 ComponentMask tracer_mask =
1544 fe->component_mask(FEValuesExtractors::Scalar(0));
1545 compute_kelly(estimated_error_per_cell, tracer_mask);
1546 }
1547}
1548
1549template <int dim>
1550void
1551Tracer<dim>::compute_kelly(dealii::Vector<float> &estimated_error_per_cell,
1552 const ComponentMask &component_mask)
1553{
1554 KellyErrorEstimator<dim>::estimate(
1555 *this->get_mapping(),
1556 *this->dof_handler,
1557 *this->face_quadrature,
1558 typename std::map<types::boundary_id, const Function<dim, double> *>(),
1559 *this->present_solution,
1560 estimated_error_per_cell,
1561 component_mask);
1562}
1563
1564template <int dim>
1565void
1567{
1568 TimerOutput::Scope t(this->computing_timer, "Setup ILU");
1569
1570 const unsigned int ilu_fill =
1571 simulation_parameters.linear_solver.at(PhysicsID::tracer).ilu_precond_fill;
1572 const double ilu_atol =
1573 simulation_parameters.linear_solver.at(PhysicsID::tracer).ilu_precond_atol;
1574 const double ilu_rtol =
1575 simulation_parameters.linear_solver.at(PhysicsID::tracer).ilu_precond_rtol;
1576 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
1577 ilu_fill, ilu_atol, ilu_rtol, 0);
1578
1579 ilu_preconditioner = std::make_shared<TrilinosWrappers::PreconditionILU>();
1580
1581 ilu_preconditioner->initialize(system_matrix, preconditionerOptions);
1582}
1583
1584template <int dim>
1585void
1587{
1588 TimerOutput::Scope t(this->computing_timer, "Setup AMG");
1589
1590 // Constant modes for the tracer scalar field
1591 std::vector<std::vector<bool>> constant_modes;
1592
1593 ComponentMask components(1, true);
1594 constant_modes =
1595 DoFTools::extract_constant_modes(*this->dof_handler, components);
1596
1597 // The tracer operator is non-symmetric since the tracer is advected by the
1598 // fluid velocity
1599 const bool elliptic = false;
1600 bool higher_order_elements = false;
1601 if (this->fe->degree > 1)
1602 higher_order_elements = true;
1603 const unsigned int n_cycles =
1604 simulation_parameters.linear_solver.at(PhysicsID::tracer).amg_n_cycles;
1605 const bool w_cycle =
1606 simulation_parameters.linear_solver.at(PhysicsID::tracer).amg_w_cycles;
1607 const double aggregation_threshold =
1609 .amg_aggregation_threshold;
1610 const unsigned int smoother_sweeps =
1612 .amg_smoother_sweeps;
1613 const unsigned int smoother_overlap =
1615 .amg_smoother_overlap;
1616 const bool output_details = false;
1617 const char *smoother_type = "ILU";
1618 const char *coarse_type = "ILU";
1619 TrilinosWrappers::PreconditionAMG::AdditionalData preconditionerOptions(
1620 elliptic,
1621 higher_order_elements,
1622 n_cycles,
1623 w_cycle,
1624 aggregation_threshold,
1625 constant_modes,
1626 smoother_sweeps,
1627 smoother_overlap,
1628 output_details,
1629 smoother_type,
1630 coarse_type);
1631
1632 Teuchos::ParameterList parameter_ml;
1633 std::unique_ptr<Epetra_MultiVector> distributed_constant_modes;
1634 preconditionerOptions.set_parameters(parameter_ml,
1635 distributed_constant_modes,
1637 const double ilu_fill =
1639 .amg_precond_ilu_fill;
1640 const double ilu_atol =
1642 .amg_precond_ilu_atol;
1643 const double ilu_rtol =
1645 .amg_precond_ilu_rtol;
1646 parameter_ml.set("smoother: ifpack level-of-fill", ilu_fill);
1647 parameter_ml.set("smoother: ifpack absolute threshold", ilu_atol);
1648 parameter_ml.set("smoother: ifpack relative threshold", ilu_rtol);
1649
1650 parameter_ml.set("coarse: ifpack level-of-fill", ilu_fill);
1651 parameter_ml.set("coarse: ifpack absolute threshold", ilu_atol);
1652 parameter_ml.set("coarse: ifpack relative threshold", ilu_rtol);
1653
1654 amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionAMG>();
1655 amg_preconditioner->initialize(system_matrix, parameter_ml);
1656}
1657
1658template <int dim>
1659void
1661{
1662 TimerOutput::Scope t(this->computing_timer, "Solve linear system");
1663
1664 auto mpi_communicator = triangulation->get_mpi_communicator();
1665
1666 const AffineConstraints<double> &constraints_used = this->zero_constraints;
1667
1668 const double absolute_residual =
1669 simulation_parameters.linear_solver.at(PhysicsID::tracer).minimum_residual;
1670 const double relative_residual =
1671 simulation_parameters.linear_solver.at(PhysicsID::tracer).relative_residual;
1672
1673 const double rescale_metric = this->get_residual_rescale_metric();
1674 const double current_residual = system_rhs.l2_norm() / rescale_metric;
1675 const double linear_solver_tolerance =
1676 std::max(relative_residual * current_residual, absolute_residual);
1677 if (this->simulation_parameters.linear_solver.at(PhysicsID::tracer)
1678 .verbosity != Parameters::Verbosity::quiet)
1679 {
1680 this->pcout << " -Tolerance of iterative solver is : "
1681 << linear_solver_tolerance << std::endl;
1682 }
1683 const double non_rescaled_linear_solver_tolerance =
1684 linear_solver_tolerance * rescale_metric;
1685
1686 GlobalVectorType completely_distributed_solution(locally_owned_dofs,
1687 mpi_communicator);
1688
1689 SolverControl solver_control(
1690 simulation_parameters.linear_solver.at(PhysicsID::tracer).max_iterations,
1691 non_rescaled_linear_solver_tolerance,
1692 true,
1693 true);
1694
1695 TrilinosWrappers::SolverGMRES::AdditionalData solver_parameters(
1696 false,
1698 .max_krylov_vectors);
1699
1700
1701 TrilinosWrappers::SolverGMRES solver(solver_control, solver_parameters);
1702
1703 const auto preconditioner_type =
1704 simulation_parameters.linear_solver.at(PhysicsID::tracer).preconditioner;
1705
1706 if (preconditioner_type == Parameters::LinearSolver::PreconditionerType::ilu)
1707 {
1708 setup_ilu();
1709 solver.solve(system_matrix,
1710 completely_distributed_solution,
1711 system_rhs,
1713 }
1714 else if (preconditioner_type ==
1716 {
1717 setup_amg();
1718 solver.solve(system_matrix,
1719 completely_distributed_solution,
1720 system_rhs,
1722 }
1723 else
1724 AssertThrow(
1725 false,
1726 ExcMessage(
1727 "This linear solver does not support this preconditioner. Only <ilu> and <amg> preconditioners are supported."));
1728
1729 if (simulation_parameters.linear_solver.at(PhysicsID::tracer).verbosity !=
1731 {
1732 this->pcout << " -Iterative solver took : " << solver_control.last_step()
1733 << " steps to reach a residual norm of "
1734 << solver_control.last_value() / rescale_metric << std::endl;
1735 }
1736
1737 constraints_used.distribute(completely_distributed_solution);
1738 newton_update = completely_distributed_solution;
1739}
1740
1741template <int dim>
1742void
1744{
1745 if (!simulation_parameters.mortar_parameters.enable)
1746 return;
1747
1748 TimerOutput::Scope t(this->computing_timer, "Reinit mortar operators");
1749
1750 // Create mortar manager
1751 if (simulation_parameters.mortar_parameters.interface_type ==
1753 this->mortar_manager = std::make_shared<MortarManagerCircle<dim>>(
1754 *this->cell_quadrature,
1755 *this->get_mapping(),
1756 *this->dof_handler,
1757 simulation_parameters.mortar_parameters);
1758 else if (simulation_parameters.mortar_parameters.interface_type ==
1760 this->mortar_manager = std::make_shared<MortarManagerLinear<dim>>(
1761 *this->cell_quadrature,
1762 *this->get_mapping(),
1763 *this->dof_handler,
1764 simulation_parameters.mortar_parameters);
1765 else
1766 AssertThrow(false, ExcMessage("Invalid mortar interface type."));
1767
1768
1769 // Create mortar coupling evaluator
1771 std::make_shared<ScalarCouplingEvaluationSIPG<dim, 1, double>>(
1772 *this->get_mapping(), *this->dof_handler);
1773
1775 std::make_shared<CouplingOperator<dim, double>>(
1776 *this->get_mapping(),
1777 *this->dof_handler,
1778 this->zero_constraints,
1780 this->mortar_manager,
1781 simulation_parameters.mortar_parameters.rotor_boundary_id,
1782 simulation_parameters.mortar_parameters.stator_boundary_id,
1783 simulation_parameters.mortar_parameters.sip_factor);
1784}
1785
1786template <int dim>
1787void
1789{
1790 if (!this->simulation_parameters.mortar_parameters.enable)
1791 return;
1792
1793 TimerOutput::Scope t(this->computing_timer, "Rotate rotor mapping");
1794
1795 // Get updated rotation angle (radians)
1796 simulation_parameters.mortar_parameters.rotor_rotation_angle->set_time(
1797 this->simulation_control->get_current_time());
1798 const double rotation_angle =
1799 simulation_parameters.mortar_parameters.rotor_rotation_angle->value(
1800 Point<dim>());
1801
1802 // Rotate mapping only in the case of a circular mortar interface
1803 if (this->simulation_parameters.mortar_parameters.interface_type ==
1806 *this->dof_handler,
1807 *this->mapping_cache,
1808 *this->mapping,
1809 rotation_angle,
1810 this->simulation_parameters.mortar_parameters.center_of_rotation,
1811 this->simulation_parameters.mortar_parameters.rotation_axis_direction);
1812 else if (this->simulation_parameters.mortar_parameters.interface_type ==
1814 this->mapping_cache->initialize(*this->mapping,
1815 this->dof_handler->get_triangulation());
1816 else
1817 AssertThrow(false, ExcMessage("Invalid mortar interface type."));
1818}
1819
1820template <int dim>
1821void
1823{
1824 if (!this->simulation_parameters.mortar_parameters.enable)
1825 return;
1826
1827 TimerOutput::Scope t(this->computing_timer, "Update mortar configuration");
1828
1829 auto mpi_communicator = triangulation->get_mpi_communicator();
1830
1831 // We need to update the mortar operator/evaluator, as well as the sparsity
1832 // pattern, at every iteration. Since this is already done within
1833 // setup_dofs(), which is called in refine_mesh(), here we make sure that,
1834 // when there is no mesh refinement, the mortar information is still updated
1835 if (this->simulation_control->is_at_start() ||
1836 !this->simulation_control->is_refinement_step(
1837 this->simulation_parameters.mesh_adaptation) ||
1838 this->simulation_parameters.mesh_adaptation.type ==
1840 {
1841 // Now reset system matrix
1842 this->system_matrix.clear();
1843
1844 // Rotate mapping
1845 this->rotate_rotor_mapping();
1846
1848
1849 // Boundary conditions for Newton correction
1851
1852 // Create mortar manager, operator, and evaluator
1854
1855 // Sparse matrices initialization
1856 DynamicSparsityPattern dsp(locally_relevant_dofs);
1857
1858
1859 if (simulation_parameters.fem_parameters.tracer_uses_dg)
1860 {
1861 DoFTools::make_flux_sparsity_pattern(
1862 *this->dof_handler,
1863 dsp,
1865 /*keep_constrained_dofs = */ true);
1866 }
1867 else
1868 {
1869 DoFTools::make_sparsity_pattern(*this->dof_handler,
1870 dsp,
1872 /*keep_constrained_dofs = */ true);
1873 }
1874
1875
1876 // Add sparsity pattern entries
1877 if (this->simulation_parameters.mortar_parameters.enable)
1878 this->mortar_coupling_operator->add_sparsity_pattern_entries(dsp);
1879
1880 SparsityTools::distribute_sparsity_pattern(dsp,
1882 mpi_communicator,
1886 dsp,
1887 mpi_communicator);
1888 }
1889}
1890
1891template class Tracer<2>;
1892template class Tracer<3>;
Responsible for storing the information calculated using the discontinuous galerkin (DG) assembly of ...
Definition copy_data.h:127
std::vector< CopyDataFace > face_data
Definition copy_data.h:149
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Definition copy_data.h:67
Vector< double > local_rhs
Definition copy_data.h:105
FullMatrix< double > local_matrix
Definition copy_data.h:104
void reset()
Resets the cell_matrix, cell_rhs, strong_residual and strong_jacobian to zero.
Definition copy_data.h:92
std::vector< types::global_dof_index > local_dof_indices
Definition copy_data.h:106
Class that assembles the transient time arising from BDF time integration for the Tracer equations....
Class that assembles the core of the Tracer equation. This class assembles the weak form of: with an...
Class that assembles the core (cells) of the Tracer equation for DG elements. This class assembles th...
Class that assembles the reaction source term of the Tracer equation. It assembles the term: Where C...
Class that stores the information required by the assembly procedure for a Tracer advection-diffusion...
void reinit_signed_distance(const typename DoFHandler< dim >::active_cell_iterator &cell, const std::shared_ptr< Shape< dim > > &immersed_solid_shape)
Reinitializes the signed distance vector of the scratch.
void calculate_physical_properties()
Calculates the physical properties. This function calculates the physical properties that may be requ...
void reinit_mortar(const typename DoFHandler< dim >::active_cell_iterator &cell, const Parameters::Mortar< dim > &mortar_parameters, const double &time)
Renitialize the content of the scratch data for mortar.
void reinit_velocity(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType &velocity_solution, const Parameters::ALE< dim > &ale, const std::shared_ptr< Functions::ParsedFunction< dim > > &drift_velocity)
Reinitialize the velocity, calculated by the fluid dynamics while also taking into account ALE.
void reinit(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType &current_solution, const std::vector< VectorType > &previous_solutions, const Function< dim > *source_function)
Reinitializes the content of the scratch.
void solve_linear_system() override
Call for the solution of the linear system of equation using a strategy appropriate to the auxiliary ...
Definition tracer.cc:1660
void assemble_system_rhs_cg()
Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream p...
Definition tracer.cc:413
std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for t...
Definition tracer.cc:1200
TimerOutput computing_timer
Definition tracer.h:674
std::shared_ptr< MappingQCache< dim > > mapping_cache
Definition tracer.h:698
void update_mortar_configuration()
Update mortar configuration.
Definition tracer.cc:1822
void assemble_system_matrix_dg()
Assembles the matrix associated with the solver when DG elements are used. This uses the MeshWorker p...
Definition tracer.cc:142
ConvergenceTable error_table
Definition tracer.h:700
std::shared_ptr< Quadrature< dim > > cell_quadrature
Definition tracer.h:689
GlobalVectorType newton_update
Definition tracer.h:708
GlobalVectorType system_rhs
Definition tracer.h:710
void write_checkpoint() override
Prepares Tracer physics to write checkpoint.
Definition tracer.cc:1233
void write_tracer_flow_rates(const std::map< types::boundary_id, double > &tracer_flow_rate_vector)
Writes the tracer flow rates to an output file.
Definition tracer.cc:1098
MultiphysicsInterface< dim > * multiphysics
Definition tracer.h:672
void compute_kelly(dealii::Vector< float > &estimated_error_per_cell, const ComponentMask &component_mask)
Compute the Kelly error estimator on the tracer variable for mesh refinement. See : https://www....
Definition tracer.cc:1551
void assemble_system_rhs_dg()
Assembles the rhs associated with the solver when DG elements are used. This uses the MeshWorker para...
Definition tracer.cc:456
void define_non_zero_constraints()
Define the non-zero constraints used to solve the problem.
Definition tracer.cc:1474
virtual void copy_local_rhs_to_global_rhs(const StabilizedMethodsCopyData &copy_data)
Copy local cell rhs information to global rhs.
Definition tracer.cc:684
virtual void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, TracerScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data)
Assemble the local matrix for a given cell.
Definition tracer.cc:278
double calculate_L2_error()
Calculates the L2 error of the solution.
Definition tracer.cc:716
TrilinosWrappers::SparseMatrix system_matrix
Definition tracer.h:713
void assemble_system_matrix_cg()
Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream p...
Definition tracer.cc:104
AffineConstraints< double > zero_constraints
Definition tracer.h:712
void reinit_face_velocity_with_adequate_solution(const typename DoFHandler< dim >::active_cell_iterator &velocity_cell, const unsigned int &face_no, TracerScratchData< dim > &scratch_data)
Helper function to reinit the face velocity with the adequate solution. This prevents code duplicatio...
Definition tracer.h:571
void pre_mesh_adaptation() override
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
Definition tracer.cc:1158
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
Definition tracer.h:680
IndexSet locally_owned_dofs
Definition tracer.h:703
TableHandler statistics_table
Definition tracer.h:740
void rotate_rotor_mapping()
Rotate rotor mapping in mortar method.
Definition tracer.cc:1788
void assemble_system_matrix() override
Assembles the matrix associated with the solver.
Definition tracer.cc:85
std::shared_ptr< DoFHandler< dim > > dof_handler
Definition tracer.h:682
std::shared_ptr< CouplingOperator< dim, double > > mortar_coupling_operator
Definition tracer.h:694
double get_residual_rescale_metric() const override
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_vol...
Definition tracer.h:360
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
ILU preconditioner used by the iterative linear solver.
Definition tracer.h:718
void post_mesh_adaptation() override
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
Definition tracer.cc:1171
std::vector< std::shared_ptr< TracerAssemblerBase< dim > > > assemblers
Definition tracer.h:734
TableHandler tracer_flow_rate_table
Definition tracer.h:741
virtual void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, TracerScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data)
Assemble the local rhs for a given cell.
Definition tracer.cc:586
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
Definition tracer.h:729
void write_tracer_statistics()
Writes the tracer statistics to an output file.
Definition tracer.cc:1140
virtual void setup_assemblers()
sets up the vector of assembler functions
Definition tracer.cc:36
void update_boundary_conditions() override
Update non zero constraints if the boundary is time-dependent.
Definition tracer.cc:1383
void reinit_mortar_operators()
Initialize mortar coupling manager, operator, and evaluator.
Definition tracer.cc:1743
void output_per_iteration_timer() override
Output the per iteration wallclock times.
Definition tracer.cc:874
std::shared_ptr< MortarManagerBase< dim > > mortar_manager
Definition tracer.h:693
GlobalVectorType local_evaluation_point
Definition tracer.h:707
void set_initial_conditions() override
Sets-up the initial conditions associated with the physics. Generally, physics only support imposing ...
Definition tracer.cc:1515
GlobalVectorType evaluation_point
Definition tracer.h:706
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
Definition tracer.h:726
std::shared_ptr< TracerAssemblerSIPG< dim > > inner_face_assembler
Definition tracer.h:736
void percolate_time_vectors() override
Rearrange vector solution correctly for transient simulations.
Definition tracer.cc:796
void compute_error_estimate(const std::pair< const Variable, Parameters::MultipleAdaptationParameters > &ivar, dealii::Vector< float > &estimated_error_per_cell) override
Compute the error estimator for mesh refinement.
Definition tracer.cc:1528
void postprocess(bool first_iteration) override
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
Definition tracer.cc:807
std::shared_ptr< SimulationControl > simulation_control
Definition tracer.h:681
IndexSet locally_relevant_dofs
Definition tracer.h:704
std::shared_ptr< Mapping< dim > > get_mapping()
Returns the mapping shared pointer. A MappingQCache is necessary for prescribed rotation in rotor-sta...
Definition tracer.h:643
virtual void copy_local_matrix_to_global_matrix(const StabilizedMethodsCopyData &copy_data)
Copy local cell information to global matrix.
Definition tracer.cc:376
std::shared_ptr< FiniteElement< dim > > fe
Definition tracer.h:685
std::shared_ptr< Mapping< dim > > mapping
Definition tracer.h:688
void assemble_system_rhs() override
Assemble the rhs associated with the solver.
Definition tracer.cc:390
void calculate_tracer_statistics()
Calculate tracer statistics : Max, min, average and standard-deviation.
Definition tracer.cc:885
std::shared_ptr< GlobalVectorType > present_solution
Definition tracer.h:709
std::shared_ptr< ScalarCouplingEvaluationSIPG< dim, 1, double > > mortar_coupling_evaluator
Definition tracer.h:696
void setup_ilu()
Set up the ILU preconditioner stored in ilu_preconditioner.
Definition tracer.cc:1566
void finish_simulation() override
Carry out the operations required to finish a simulation correctly.
Definition tracer.cc:761
const SimulationParameters< dim > & simulation_parameters
Definition tracer.h:676
void read_checkpoint() override
Allows tracer physics to set up solution vector from checkpoint file;.
Definition tracer.cc:1257
virtual std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Gather and return vector of output structs that are particular to some applications.
Definition tracer.cc:698
std::shared_ptr< TrilinosWrappers::PreconditionAMG > amg_preconditioner
AMG preconditioner used by the iterative linear solver.
Definition tracer.h:723
std::shared_ptr< TracerAssemblerBoundaryNitsche< dim > > boundary_face_assembler
Definition tracer.h:737
void define_zero_constraints()
Define the zero constraints used to solve the problem.
Definition tracer.cc:1435
std::vector< SolutionTransfer< dim, GlobalVectorType > > previous_solutions_transfer
Definition tracer.h:731
void setup_amg()
Set up the AMG preconditioner stored in amg_preconditioner.
Definition tracer.cc:1586
void setup_dofs() override
Sets-up the DofHandler and the degree of freedom associated with the physics.
Definition tracer.cc:1294
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
Definition tracer.h:690
std::map< types::boundary_id, double > postprocess_tracer_flow_rate(const GlobalVectorType &current_solution_fd)
Definition tracer.cc:980
AffineConstraints< double > nonzero_constraints
Definition tracer.h:711
void verify_consistency_of_boundary_conditions()
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary ...
Definition tracer.h:376
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.
Definition utilities.h:602
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...
Definition utilities.h:500
void deserialize_tables_vector(std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Deserializes all the TableHandler objects in table_output_structs.
Definition utilities.h:624
@ tracer
Tracer scalar field.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ tracer
Passive scalar tracer (Tracer).
void rotate_mapping(const DoFHandler< dim > &dof_handler, MappingQCache< dim > &mapping_cache, const Mapping< dim > &mapping, const double rotation_angle, const Point< dim > &center_of_rotation=Point< dim >(), const unsigned int rotation_axis_direction=2)
Rotate the mapping according to the rotation angle in a rotor-stator configuration.
void set_field_vector(const field &id, const std::vector< double > &data, std::map< field, std::vector< double > > &fields)
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...
@ ilu
Incomplete LU Factorization.
GlobalVectorType VectorType
bool time_stepping_is_bdf(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the bdf family.
bool time_stepping_is_sdirk(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the sdirk family.
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17