Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
tracer.h
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#ifndef lethe_tracer_h
4#define lethe_tracer_h
5
6#include <core/bdf.h>
9#include <core/vector.h>
10
16
17#include <deal.II/base/convergence_table.h>
18#include <deal.II/base/quadrature_lib.h>
19#include <deal.II/base/timer.h>
20
21#include <deal.II/distributed/tria_base.h>
22
23#include <deal.II/fe/fe_q.h>
24#include <deal.II/fe/fe_simplex_p.h>
25#include <deal.II/fe/mapping_fe.h>
26#include <deal.II/fe/mapping_q.h>
27
28#include <deal.II/grid/grid_tools.h>
29
30#include <deal.II/lac/trilinos_precondition.h>
31#include <deal.II/lac/trilinos_sparse_matrix.h>
32#include <deal.II/lac/trilinos_vector.h>
33
34#include <deal.II/numerics/solution_transfer.h>
35
36#include <map>
37#include <utility>
38
39/*
40 * Implementation of tracer as an auxiliary physics.
41 * Equation solved:
42 * dC/dt + u * gradC = D * div(grad C) + f
43 * where C is the tracer concentration, D the diffusivity and f the forcing
44 */
45
47 TracerBoundaryConditionMissing,
48 types::boundary_id,
49 << "The boundary id: " << arg1
50 << " is defined in the triangulation, but not as a boundary condition for the tracer physics. Lethe does not assign a default boundary condition to boundary ids. Every boundary id defined within the triangulation must have a corresponding boundary condition defined in the input file.");
51
52
53template <int dim>
54class Tracer : public AuxiliaryPhysics<dim, GlobalVectorType>
55{
56public:
57 Tracer(MultiphysicsInterface<dim> *multiphysics_interface,
58 const SimulationParameters<dim> &p_simulation_parameters,
59 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
60 &p_triangulation,
61 std::shared_ptr<SimulationControl> p_simulation_control)
63 p_simulation_parameters.physics_solving_strategy.at(PhysicsID::tracer))
64 , multiphysics(multiphysics_interface)
65 , computing_timer(p_triangulation->get_mpi_communicator(),
66 this->pcout,
67 TimerOutput::never,
68 TimerOutput::wall_times)
69 , simulation_parameters(p_simulation_parameters)
70 , triangulation(p_triangulation)
71 , simulation_control(std::move(p_simulation_control))
72 , dof_handler(std::make_shared<DoFHandler<dim>>(*triangulation))
73 {
74 this->pcout << std::setprecision(simulation_control->get_log_precision())
75 << std::scientific;
76
77 if (simulation_parameters.mesh.simplex)
78 {
79 // for simplex meshes
80 fe = std::make_shared<FE_SimplexP<dim>>(
81 simulation_parameters.fem_parameters.tracer_degree);
82 mapping = std::make_shared<MappingFE<dim>>(*fe);
83 cell_quadrature = std::make_shared<QGaussSimplex<dim>>(fe->degree + 1);
85 std::make_shared<QGaussSimplex<dim - 1>>(fe->degree + 1);
86 if (simulation_parameters.fem_parameters.tracer_uses_dg)
87 AssertThrow(
88 false,
89 ExcMessage(
90 "Discontinuous Galerkin elements cannot be simplex in the tracer physics."));
91 }
92 else
93 {
94 // Usual case, for quad/hex meshes
95 if (simulation_parameters.fem_parameters.tracer_uses_dg)
96 fe = std::make_shared<FE_DGQ<dim>>(
97 simulation_parameters.fem_parameters.tracer_degree);
98 else
99 fe = std::make_shared<FE_Q<dim>>(
100 simulation_parameters.fem_parameters.tracer_degree);
101 // The mapping must be a minimum of degree 1. This is necessary in the
102 // DG method since DG_Q(0) elements are adequate but a mapping of degree
103 // 0 does not make sense.
104 mapping = std::make_shared<MappingQ<dim>>(std::max(int(fe->degree), 1));
105 cell_quadrature = std::make_shared<QGauss<dim>>(fe->degree + 1);
106 face_quadrature = std::make_shared<QGauss<dim - 1>>(fe->degree + 1);
107 }
108
109 // Create and initialize mapping cache
110 if (this->simulation_parameters.mortar_parameters.enable)
111 this->mapping_cache = std::make_shared<MappingQCache<dim>>(fe->degree);
112
113 // Initialize solution shared_ptr
114 present_solution = std::make_shared<GlobalVectorType>();
115
116 // Allocate solution transfer
118 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
119
120 // Initialize and set size of previous solutions using BDF schemes
121 // information
122 previous_solutions = std::make_shared<std::vector<GlobalVectorType>>(
124
125 // Prepare previous solutions transfer
127 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
128 {
129 previous_solutions_transfer.emplace_back(
130 SolutionTransfer<dim, GlobalVectorType>(*this->dof_handler));
131 }
132 }
133
134 /**
135 * @brief Gather and return vector of output structs that are particular to some applications.
136 *
137 * @return Vector of OutputStructs that will be used to write the output results as VTU files.
138 */
139 virtual std::vector<OutputStruct<dim, GlobalVectorType>>
140 gather_output_hook() override;
141
142 /**
143 * @brief Calculates the L2 error of the solution
144 */
145 double
147
148 /**
149 * @brief Carry out the operations required to finish a simulation correctly.
150 */
151 void
152 finish_simulation() override;
153
154 /**
155 * @brief Rearrange vector solution correctly for transient simulations
156 */
157 void
158 percolate_time_vectors() override;
159
160 /**
161 * @brief Postprocess the auxiliary physics results. Post-processing this case implies
162 * the calculation of all derived quantities using the solution vector of the
163 * physics. It does not concern the output of the solution using the
164 * DataOutObject, which is accomplished through the attach_solution_to_output
165 * function
166 */
167 void
168 postprocess(bool first_iteration) override;
169
170 /**
171 * @brief Output the per iteration wallclock times.
172 */
173 void
175
176 /**
177 * @brief pre_mesh_adaption Prepares the auxiliary physics variables for a
178 * mesh refinement/coarsening
179 */
180 void
181 pre_mesh_adaptation() override;
182
183 /**
184 * @brief post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
185 */
186 void
187 post_mesh_adaptation() override;
188
189 /**
190 * @brief Compute the error estimator for mesh refinement.
191 *
192 * @param[in] ivar The current element of the map
193 * simulation_parameters.mesh_adaptation.variables
194 *
195 * @param[in,out] estimated_error_per_cell The deal.II vector of
196 * estimated_error_per_cell
197 */
198 void
200 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
201 &ivar,
202 dealii::Vector<float> &estimated_error_per_cell) override;
203
204 /**
205 * @brief Compute the Kelly error estimator on the tracer variable for mesh refinement.
206 * See :
207 * https://www.dealii.org/current/doxygen/deal.II/classKellyErrorEstimator.html
208 * for more information on the Kelly error estimator.
209 *
210 * @param[in,out] estimated_error_per_cell The deal.II vector of
211 * estimated_error_per_cell
212 * @param[in] component_mask The component mask corresponding to the tracer
213 * variable
214 */
215 void
216 compute_kelly(dealii::Vector<float> &estimated_error_per_cell,
217 const ComponentMask &component_mask);
218
219
220 /**
221 * @brief Prepares Tracer physics to write checkpoint
222 */
223 void
224 write_checkpoint() override;
225
226 /**
227 * @brief Allows tracer physics to set up solution vector from checkpoint file;
228 */
229 void
230 read_checkpoint() override;
231
232 /**
233 * @brief Returns a vector of references to TableHandler objects that needs to
234 * be serialized/deserialized for the Tracer solver.
235 *
236 * @return Structure containing a vector of references to TableHandler objects
237 * that needs to be serialized/deserialized for the Tracer solver, and their
238 * corresponding file names.
239 */
240 std::vector<OutputStructTableHandler>
241 gather_tables() override;
242
243 /**
244 * @brief Returns the dof_handler of the tracer physics
245 */
246 const DoFHandler<dim> &
248 {
249 return *dof_handler;
250 }
251
252 /**
253 * @brief Sets-up the DofHandler and the degree of freedom associated with the physics.
254 */
255 void
256 setup_dofs() override;
257
258 /**
259 * @brief Define the zero constraints used to solve the problem.
260 */
261 void
263
264 /**
265 * @brief Define the non-zero constraints used to solve the problem.
266 */
267 void
269
270 /**
271 * @brief Sets-up the initial conditions associated with the physics. Generally, physics
272 * only support imposing nodal values, but some physics additionnaly support
273 * the use of L2 projection or steady-state solutions.
274 */
275 void
276 set_initial_conditions() override;
277
278 /**
279 * @brief Update non zero constraints if the boundary is time-dependent
280 */
281 void
283
284 /**
285 * @brief Call for the solution of the linear system of equation using a strategy appropriate
286 * to the auxiliary physics
287 */
288 void
289 solve_linear_system() override;
290
291 /**
292 * @brief Set up the ILU preconditioner stored in ilu_preconditioner.
293 */
294 void
295 setup_ilu();
296
297 /**
298 * @brief Set up the AMG preconditioner stored in amg_preconditioner.
299 */
300 void
301 setup_amg();
302
303 /**
304 * @brief Getter methods to get the private attributes for the physic currently solved
305 * NB : dof_handler and present_solution are passed to the multiphysics
306 * interface at the end of the setup_dofs method
307 */
310 {
311 return evaluation_point;
312 }
315 {
317 }
320 {
321 return newton_update;
322 }
325 {
326 return *present_solution;
327 }
329 get_system_rhs() override
330 {
331 return system_rhs;
332 }
333 AffineConstraints<double> &
335 {
336 return nonzero_constraints;
337 }
338
339
340 /**
341 * @brief Output the L2 and Linfty norms of the correction vector.
342 */
343 void
345 {
346 this->pcout << "\t ||dx||_L2 = " << std::setw(6) << newton_update.l2_norm()
347 << std::setw(6)
348 << "\t ||dx||_Linfty = " << newton_update.linfty_norm()
349 << std::endl;
350 }
351
352 /**
353 * @brief Return the metric for residual rescaling. By default, should return 1.
354 * If the rescale_residual_by_volume is set to true, the method
355 * returns the square root of the global volume of the triangulation.
356 *
357 * @return Rescale metric.
358 */
359 double
361 {
362 return simulation_parameters.linear_solver.at(PhysicsID::tracer)
363 .rescale_residual_by_volume ?
364 std::sqrt(
365 GridTools::volume(*this->triangulation, *this->mapping)) :
366 1.;
367 }
368
369private:
370 /**
371 * @brief Verify consistency of the input parameters for boundary
372 * conditions to ensure that for every boundary condition within the
373 * triangulation, a boundary condition has been specified in the input file.
374 */
375 void
377 {
378 // Sanity check all the boundary conditions of the triangulation to
379 // ensure that they have a type.
380 std::vector<types::boundary_id> boundary_ids_in_triangulation =
381 this->triangulation->get_boundary_ids();
382 for (auto const &boundary_id_in_tria : boundary_ids_in_triangulation)
383 {
384 AssertThrow(
385 simulation_parameters.tracer_boundary_conditions.type.find(
386 boundary_id_in_tria) !=
387 simulation_parameters.tracer_boundary_conditions.type.end(),
388 TracerBoundaryConditionMissing(boundary_id_in_tria));
389 }
390 }
391
392 /**
393 * @brief Assembles the matrix associated with the solver
394 */
395 void
396 assemble_system_matrix() override;
397
398 /**
399 * @brief Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream paradigm.
400 */
401 void
403
404 /**
405 * @brief Assembles the matrix associated with the solver when DG elements are used.
406 * This uses the MeshWorker paradigm instead of the WorkStream paradigm.
407 * This is because the DG system matrix is assembled in a different way and
408 * requires face and boundary integrals.
409 */
410 void
412
413 /**
414 * @brief Assemble the rhs associated with the solver
415 */
416 void
417 assemble_system_rhs() override;
418
419
420 /**
421 * @brief Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream paradigm.
422 */
423 void
425
426 /**
427 * @brief Assembles the rhs associated with the solver when DG elements are used.
428 * This uses the MeshWorker paradigm instead of the WorkStream paradigm
429 * This is because the DG system matrix is assembled in a different way and
430 * requires face and boundary integrals.
431 */
432 void
434
435
436 /**
437 * @brief Assemble the local matrix for a given cell.
438 *
439 * This function is used by the WorkStream class to assemble
440 * the system matrix. It is a thread safe function.
441 *
442 * @param cell The cell for which the local matrix is assembled.
443 *
444 * @param scratch_data The scratch data which is used to store
445 * the calculated finite element information at the gauss point.
446 * See the documentation for TracerScratchData for more
447 * information
448 *
449 * @param copy_data The copy data which is used to store
450 * the results of the assembly over a cell
451 */
452 virtual void
454 const typename DoFHandler<dim>::active_cell_iterator &cell,
455 TracerScratchData<dim> &scratch_data,
456 StabilizedMethodsCopyData &copy_data);
457
458 /**
459 * @brief Assemble the local rhs for a given cell
460 *
461 * @param cell The cell for which the local matrix is assembled.
462 *
463 * @param scratch_data The scratch data which is used to store
464 * the calculated finite element information at the gauss point.
465 * See the documentation for TracerScratchData for more
466 * information
467 *
468 * @param copy_data The copy data which is used to store
469 * the results of the assembly over a cell
470 */
471 virtual void
473 const typename DoFHandler<dim>::active_cell_iterator &cell,
474 TracerScratchData<dim> &scratch_data,
475 StabilizedMethodsCopyData &copy_data);
476
477 /**
478 * @brief sets up the vector of assembler functions
479 */
480 virtual void
482
483
484 /**
485 * @brief Copy local cell information to global matrix
486 */
487
488 virtual void
490 const StabilizedMethodsCopyData &copy_data);
491
492 /**
493 * @brief Copy local cell rhs information to global rhs
494 */
495
496 virtual void
498
499 /**
500 * @brief Calculate tracer statistics : Max, min, average and standard-deviation
501 */
502 void
504
505
506 /**
507 * Post-processing. Calculate the tracer flow rate at every boundary.
508 *
509 * @param current_solution_fd current solution for the fluid dynamics, parsed
510 * by postprocess
511 *
512 * @return values of the tracer flow rate at each boundary
513 *
514 * @tparam GlobalVectorType The type of the global vector used for the tracer physic
515 */
516 template <typename GlobalVectorType>
517 std::map<types::boundary_id, double>
518 postprocess_tracer_flow_rate(const GlobalVectorType &current_solution_fd);
519
520 /**
521 * @brief Writes the tracer flow rates to an output file
522 */
523 void
525 const std::map<types::boundary_id, double> &tracer_flow_rate_vector);
526
527 /**
528 * @brief Writes the tracer statistics to an output file
529 */
530 void
532
533 /**
534 * @brief Modify the tracer solution by applying a limiter;
535 */
536 virtual void
538 {
539 if (simulation_parameters.fem_parameters.tracer_uses_dg)
540 {
541 if (simulation_parameters.stabilization.scalar_limiter ==
543 {
545 this->evaluation_point,
547
549 }
550 }
551 };
552
553
554 /**
555 * @brief Helper function to reinit the face velocity with the adequate solution.
556 * This prevents code duplication throughout the tracer. The function looks at
557 * the multiphysics interface to decide if the velocity is a block velocity or
558 * a regular velocity. Furthermore, it also checks if a time-averaged solution
559 * is required. Otherwise the code here would be copied four times.
560 *
561 * @param[in] velocity_cell the iterator to the cell where the velocity is to
562 * be reinitialized.
563 *
564 * @param[in] face_no the number of the face where the velocity is to be
565 * reinitialized.
566 *
567 * @param[in,out] scratch_data the scratch data to be used for the
568 * reinitialization.
569 */
570 inline void
572 const typename DoFHandler<dim>::active_cell_iterator &velocity_cell,
573 const unsigned int &face_no,
574 TracerScratchData<dim> &scratch_data)
575 {
576 if (multiphysics->fluid_dynamics_is_block())
577 {
578 // Check if the post processed variable needs to be calculated with the
579 // average velocity profile or the fluid solution.
580 if (this->simulation_parameters.initial_condition->type ==
582 average_velocity_profile &&
583 !this->simulation_parameters.multiphysics.fluid_dynamics &&
584 simulation_control->get_current_time() >
585 this->simulation_parameters.post_processing
586 .initial_time_for_average_velocities)
587 {
588 scratch_data.reinit_face_velocity(
589 velocity_cell,
590 face_no,
591 multiphysics->get_block_time_average_solution(
593 this->simulation_parameters.ale,
594 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
595 }
596 else
597 {
598 scratch_data.reinit_face_velocity(
599 velocity_cell,
600 face_no,
601 multiphysics->get_block_solution(PhysicsID::fluid_dynamics),
602 this->simulation_parameters.ale,
603 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
604 }
605 }
606 else
607 {
608 // Check if the post processed variable needs to be calculated with the
609 // average velocity profile or the fluid solution.
610 if (this->simulation_parameters.initial_condition->type ==
612 average_velocity_profile &&
613 !this->simulation_parameters.multiphysics.fluid_dynamics &&
614 simulation_control->get_current_time() >
615 this->simulation_parameters.post_processing
616 .initial_time_for_average_velocities)
617 {
618 scratch_data.reinit_face_velocity(
619 velocity_cell,
620 face_no,
621 multiphysics->get_time_average_solution(
623 this->simulation_parameters.ale,
624 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
625 }
626 else
627 {
628 scratch_data.reinit_face_velocity(
629 velocity_cell,
630 face_no,
632 this->simulation_parameters.ale,
633 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
634 }
635 }
636 }
637
638 /**
639 * @brief Returns the mapping shared pointer. A MappingQCache is
640 * necessary for prescribed rotation in rotor-stator configurations
641 */
642 inline std::shared_ptr<Mapping<dim>>
644 {
645 if (!this->simulation_parameters.mortar_parameters.enable)
646 return this->mapping;
647 else
648 return this->mapping_cache;
649 }
650
651 /**
652 * @brief Initialize mortar coupling manager, operator, and evaluator
653 */
654 void
656
657 /**
658 * @brief Rotate rotor mapping in mortar method
659 */
660 void
662
663 /**
664 * @brief Update mortar configuration.
665 *
666 * When the rotor domain is rotated, the mortar cells need to be reinitialized
667 * according to the new rotor-stator interface configuration.
668 */
669 void
671
673
674 TimerOutput computing_timer;
675
677
678
679 // Core elements for the tracer
680 std::shared_ptr<parallel::DistributedTriangulationBase<dim>> triangulation;
681 std::shared_ptr<SimulationControl> simulation_control;
682 std::shared_ptr<DoFHandler<dim>> dof_handler;
683
684 // Finite element space
685 std::shared_ptr<FiniteElement<dim>> fe;
686
687 // Mapping and Quadrature
688 std::shared_ptr<Mapping<dim>> mapping;
689 std::shared_ptr<Quadrature<dim>> cell_quadrature;
690 std::shared_ptr<Quadrature<dim - 1>> face_quadrature;
691
692 // Mortar coupling manager and operator
693 std::shared_ptr<MortarManagerBase<dim>> mortar_manager;
694 std::shared_ptr<CouplingOperator<dim, double>> mortar_coupling_operator;
695 std::shared_ptr<ScalarCouplingEvaluationSIPG<dim, 1, double>>
697 // Mapping cache used in rotor mesh rotation in mortar method
698 std::shared_ptr<MappingQCache<dim>> mapping_cache;
699
700 ConvergenceTable error_table;
701
702 // Solution storage:
705
709 std::shared_ptr<GlobalVectorType> present_solution;
711 AffineConstraints<double> nonzero_constraints;
712 AffineConstraints<double> zero_constraints;
713 TrilinosWrappers::SparseMatrix system_matrix;
714
715 /**
716 * @brief ILU preconditioner used by the iterative linear solver.
717 */
718 std::shared_ptr<TrilinosWrappers::PreconditionILU> ilu_preconditioner;
719
720 /**
721 * @brief AMG preconditioner used by the iterative linear solver.
722 */
723 std::shared_ptr<TrilinosWrappers::PreconditionAMG> amg_preconditioner;
724
725 // Previous solutions vectors
726 std::shared_ptr<std::vector<GlobalVectorType>> previous_solutions;
727
728 // Solution transfer classes
729 std::shared_ptr<SolutionTransfer<dim, GlobalVectorType>> solution_transfer;
730 std::vector<SolutionTransfer<dim, GlobalVectorType>>
732
733 // Assemblers for the matrix and rhs
734 std::vector<std::shared_ptr<TracerAssemblerBase<dim>>> assemblers;
735 // Face assemblers, used only for DG methods
736 std::shared_ptr<TracerAssemblerSIPG<dim>> inner_face_assembler;
737 std::shared_ptr<TracerAssemblerBoundaryNitsche<dim>> boundary_face_assembler;
738
739 // Tracer post-processing tables
740 TableHandler statistics_table;
742};
743
744
745#endif
unsigned int maximum_number_of_previous_solutions()
Get the maximum number of previous time steps supposed by the BDF schemes implemented in Lethe.
Definition bdf.h:84
AuxiliaryPhysics(const Parameters::NonLinearSolver non_linear_solver_parameters)
PhysicsSolverStrategy< GlobalVectorType > * physics_solving_strategy
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Definition copy_data.h:67
Class that stores the information required by the assembly procedure for a Tracer advection-diffusion...
void reinit_face_velocity(const typename DoFHandler< dim >::active_cell_iterator &velocity_cell, const unsigned int &face_no, const VectorType &velocity_solution, const Parameters::ALE< dim > &ale, const std::shared_ptr< Functions::ParsedFunction< dim > > &drift_velocity)
Reinitializes the content of the scratch regarding the velocity for internal/boundary faces....
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
GlobalVectorType & get_present_solution() override
Definition tracer.h:324
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
GlobalVectorType & get_local_evaluation_point() override
Definition tracer.h:314
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
Tracer(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)
Definition tracer.h:57
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
GlobalVectorType & get_system_rhs() override
Definition tracer.h:329
GlobalVectorType & get_evaluation_point() override
Getter methods to get the private attributes for the physic currently solved NB : dof_handler and pre...
Definition tracer.h:309
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
const DoFHandler< dim > & get_dof_handler() override
Returns the dof_handler of the tracer physics.
Definition tracer.h:247
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
virtual void modify_solution() override
Modify the tracer solution by applying a limiter;.
Definition tracer.h:537
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
void output_newton_update_norms() override
Output the L2 and Linfty norms of the correction vector.
Definition tracer.h:344
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
AffineConstraints< double > & get_nonzero_constraints() override
Definition tracer.h:334
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
GlobalVectorType & get_newton_update() override
Definition tracer.h:319
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
PhysicsID
Unique identifiers for each physics module in Lethe.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ tracer
Passive scalar tracer (Tracer).
Simulation control classes for managing time-stepping and iteration control in Lethe.
void moe_scalar_limiter(const DoFHandler< dim > &dof_handler, GlobalVectorType &locally_relevant_vector, GlobalVectorType &locally_owned_vector)
Implements a Moe a posteriori shock capturing method to keep the field bounded. This limiter is only ...
DeclException1(TracerBoundaryConditionMissing, types::boundary_id,<< "The boundary id: "<< arg1<< " is defined in the triangulation, but not as a boundary condition for the tracer physics. Lethe does not assign a default boundary condition to boundary ids. Every boundary id defined within the triangulation must have a corresponding boundary condition defined in the input file.")
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17