17#include <deal.II/base/convergence_table.h>
18#include <deal.II/base/quadrature_lib.h>
19#include <deal.II/base/timer.h>
21#include <deal.II/distributed/tria_base.h>
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>
28#include <deal.II/grid/grid_tools.h>
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>
34#include <deal.II/numerics/solution_transfer.h>
47 TracerBoundaryConditionMissing,
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.");
59 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
61 std::shared_ptr<SimulationControl> p_simulation_control)
68 TimerOutput::wall_times)
80 fe = std::make_shared<FE_SimplexP<dim>>(
82 mapping = std::make_shared<MappingFE<dim>>(*fe);
85 std::make_shared<QGaussSimplex<dim - 1>>(
fe->degree + 1);
90 "Discontinuous Galerkin elements cannot be simplex in the tracer physics."));
96 fe = std::make_shared<FE_DGQ<dim>>(
99 fe = std::make_shared<FE_Q<dim>>(
104 mapping = std::make_shared<MappingQ<dim>>(std::max(
int(
fe->degree), 1));
111 this->
mapping_cache = std::make_shared<MappingQCache<dim>>(
fe->degree);
118 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
130 SolutionTransfer<dim, GlobalVectorType>(*this->dof_handler));
139 virtual std::vector<OutputStruct<dim, GlobalVectorType>>
200 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
202 dealii::Vector<float> &estimated_error_per_cell)
override;
216 compute_kelly(dealii::Vector<float> &estimated_error_per_cell,
217 const ComponentMask &component_mask);
240 std::vector<OutputStructTableHandler>
246 const DoFHandler<dim> &
333 AffineConstraints<double> &
363 .rescale_residual_by_volume ?
380 std::vector<types::boundary_id> boundary_ids_in_triangulation =
382 for (
auto const &boundary_id_in_tria : boundary_ids_in_triangulation)
386 boundary_id_in_tria) !=
388 TracerBoundaryConditionMissing(boundary_id_in_tria));
454 const typename DoFHandler<dim>::active_cell_iterator &cell,
473 const typename DoFHandler<dim>::active_cell_iterator &cell,
516 template <
typename GlobalVectorType>
517 std::map<types::boundary_id, double>
525 const std::map<types::boundary_id, double> &tracer_flow_rate_vector);
572 const typename DoFHandler<dim>::active_cell_iterator &velocity_cell,
573 const unsigned int &face_no,
582 average_velocity_profile &&
583 !this->simulation_parameters.multiphysics.fluid_dynamics &&
585 this->simulation_parameters.post_processing
586 .initial_time_for_average_velocities)
593 this->simulation_parameters.ale,
594 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
602 this->simulation_parameters.ale,
603 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
612 average_velocity_profile &&
613 !this->simulation_parameters.multiphysics.fluid_dynamics &&
615 this->simulation_parameters.post_processing
616 .initial_time_for_average_velocities)
623 this->simulation_parameters.ale,
624 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
632 this->simulation_parameters.ale,
633 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
642 inline std::shared_ptr<Mapping<dim>>
685 std::shared_ptr<FiniteElement<dim>>
fe;
695 std::shared_ptr<ScalarCouplingEvaluationSIPG<dim, 1, double>>
730 std::vector<SolutionTransfer<dim, GlobalVectorType>>
734 std::vector<std::shared_ptr<TracerAssemblerBase<dim>>>
assemblers;
unsigned int maximum_number_of_previous_solutions()
Get the maximum number of previous time steps supposed by the BDF schemes implemented in Lethe.
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...
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 ...
void assemble_system_rhs_cg()
Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream p...
std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for t...
TimerOutput computing_timer
std::shared_ptr< MappingQCache< dim > > mapping_cache
void update_mortar_configuration()
Update mortar configuration.
GlobalVectorType & get_present_solution() override
void assemble_system_matrix_dg()
Assembles the matrix associated with the solver when DG elements are used. This uses the MeshWorker p...
ConvergenceTable error_table
std::shared_ptr< Quadrature< dim > > cell_quadrature
GlobalVectorType newton_update
GlobalVectorType system_rhs
void write_checkpoint() override
Prepares Tracer physics to write checkpoint.
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.
MultiphysicsInterface< dim > * multiphysics
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....
void assemble_system_rhs_dg()
Assembles the rhs associated with the solver when DG elements are used. This uses the MeshWorker para...
void define_non_zero_constraints()
Define the non-zero constraints used to solve the problem.
virtual void copy_local_rhs_to_global_rhs(const StabilizedMethodsCopyData ©_data)
Copy local cell rhs information to global rhs.
virtual void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, TracerScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data)
Assemble the local matrix for a given cell.
double calculate_L2_error()
Calculates the L2 error of the solution.
TrilinosWrappers::SparseMatrix system_matrix
void assemble_system_matrix_cg()
Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream p...
GlobalVectorType & get_local_evaluation_point() override
AffineConstraints< double > zero_constraints
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...
void pre_mesh_adaptation() override
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
IndexSet locally_owned_dofs
TableHandler statistics_table
void rotate_rotor_mapping()
Rotate rotor mapping in mortar method.
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)
void assemble_system_matrix() override
Assembles the matrix associated with the solver.
std::shared_ptr< DoFHandler< dim > > dof_handler
std::shared_ptr< CouplingOperator< dim, double > > mortar_coupling_operator
GlobalVectorType & get_system_rhs() override
GlobalVectorType & get_evaluation_point() override
Getter methods to get the private attributes for the physic currently solved NB : dof_handler and pre...
double get_residual_rescale_metric() const override
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_vol...
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
ILU preconditioner used by the iterative linear solver.
const DoFHandler< dim > & get_dof_handler() override
Returns the dof_handler of the tracer physics.
void post_mesh_adaptation() override
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
std::vector< std::shared_ptr< TracerAssemblerBase< dim > > > assemblers
virtual void modify_solution() override
Modify the tracer solution by applying a limiter;.
TableHandler tracer_flow_rate_table
virtual void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, TracerScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data)
Assemble the local rhs for a given cell.
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
void write_tracer_statistics()
Writes the tracer statistics to an output file.
void output_newton_update_norms() override
Output the L2 and Linfty norms of the correction vector.
virtual void setup_assemblers()
sets up the vector of assembler functions
void update_boundary_conditions() override
Update non zero constraints if the boundary is time-dependent.
void reinit_mortar_operators()
Initialize mortar coupling manager, operator, and evaluator.
void output_per_iteration_timer() override
Output the per iteration wallclock times.
std::shared_ptr< MortarManagerBase< dim > > mortar_manager
GlobalVectorType local_evaluation_point
void set_initial_conditions() override
Sets-up the initial conditions associated with the physics. Generally, physics only support imposing ...
GlobalVectorType evaluation_point
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
std::shared_ptr< TracerAssemblerSIPG< dim > > inner_face_assembler
void percolate_time_vectors() override
Rearrange vector solution correctly for transient simulations.
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.
void postprocess(bool first_iteration) override
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
std::shared_ptr< SimulationControl > simulation_control
IndexSet locally_relevant_dofs
std::shared_ptr< Mapping< dim > > get_mapping()
Returns the mapping shared pointer. A MappingQCache is necessary for prescribed rotation in rotor-sta...
virtual void copy_local_matrix_to_global_matrix(const StabilizedMethodsCopyData ©_data)
Copy local cell information to global matrix.
std::shared_ptr< FiniteElement< dim > > fe
std::shared_ptr< Mapping< dim > > mapping
void assemble_system_rhs() override
Assemble the rhs associated with the solver.
void calculate_tracer_statistics()
Calculate tracer statistics : Max, min, average and standard-deviation.
std::shared_ptr< GlobalVectorType > present_solution
std::shared_ptr< ScalarCouplingEvaluationSIPG< dim, 1, double > > mortar_coupling_evaluator
void setup_ilu()
Set up the ILU preconditioner stored in ilu_preconditioner.
void finish_simulation() override
Carry out the operations required to finish a simulation correctly.
const SimulationParameters< dim > & simulation_parameters
void read_checkpoint() override
Allows tracer physics to set up solution vector from checkpoint file;.
virtual std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Gather and return vector of output structs that are particular to some applications.
std::shared_ptr< TrilinosWrappers::PreconditionAMG > amg_preconditioner
AMG preconditioner used by the iterative linear solver.
std::shared_ptr< TracerAssemblerBoundaryNitsche< dim > > boundary_face_assembler
AffineConstraints< double > & get_nonzero_constraints() override
void define_zero_constraints()
Define the zero constraints used to solve the problem.
std::vector< SolutionTransfer< dim, GlobalVectorType > > previous_solutions_transfer
void setup_amg()
Set up the AMG preconditioner stored in amg_preconditioner.
void setup_dofs() override
Sets-up the DofHandler and the degree of freedom associated with the physics.
GlobalVectorType & get_newton_update() override
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
std::map< types::boundary_id, double > postprocess_tracer_flow_rate(const GlobalVectorType ¤t_solution_fd)
AffineConstraints< double > nonzero_constraints
void verify_consistency_of_boundary_conditions()
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary ...
PhysicsID
Unique identifiers for each physics module in Lethe.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ tracer
Passive scalar tracer (Tracer).
FluidDynamicsInitialConditionType
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