4#ifndef lethe_heat_transfer_h
5#define lethe_heat_transfer_h
18#include <deal.II/base/convergence_table.h>
19#include <deal.II/base/quadrature_lib.h>
20#include <deal.II/base/timer.h>
22#include <deal.II/distributed/tria_base.h>
24#include <deal.II/fe/fe_q.h>
25#include <deal.II/fe/fe_simplex_p.h>
26#include <deal.II/fe/mapping_fe.h>
27#include <deal.II/fe/mapping_q.h>
29#include <deal.II/grid/grid_tools.h>
31#include <deal.II/lac/trilinos_precondition.h>
32#include <deal.II/lac/trilinos_sparse_matrix.h>
33#include <deal.II/lac/trilinos_vector.h>
35#include <deal.II/non_matching/fe_values.h>
36#include <deal.II/non_matching/mesh_classifier.h>
38#include <deal.II/numerics/solution_transfer.h>
43 HeatTransferBoundaryConditionMissing,
45 <<
"The boundary id: " << arg1
46 <<
" is defined in the triangulation, but not as a boundary condition for the heat transfer 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.");
82 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
84 std::shared_ptr<SimulationControl> p_simulation_control)
92 TimerOutput::wall_times)
98 p_simulation_parameters.physical_properties_manager
99 .get_thermal_conductivity_vector())
101 p_simulation_parameters.post_processing.isocontour_bounding_boxes
110 fe = std::make_shared<FE_SimplexP<dim>>(
115 std::make_shared<QGaussSimplex<dim - 1>>(
fe->degree + 1);
120 fe = std::make_shared<FE_Q<dim>>(
132 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
144 SolutionTransfer<dim, GlobalVectorType>(*this->dof_handler));
150 std::make_shared<AverageScalar<dim>>(*this->dof_handler);
185 std::vector<OutputStruct<dim, GlobalVectorType>>
260 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
262 dealii::Vector<float> &estimated_error_per_cell)
override;
276 compute_kelly(dealii::Vector<float> &estimated_error_per_cell,
277 const ComponentMask &component_mask);
299 std::vector<OutputStructTableHandler>
348 const DoFHandler<dim> &
425 AffineConstraints<double> &
454 .rescale_residual_by_volume ?
471 std::vector<types::boundary_id> boundary_ids_in_triangulation =
473 for (
auto const &boundary_id_in_tria : boundary_ids_in_triangulation)
476 boundary_id_in_tria) !=
478 HeatTransferBoundaryConditionMissing(boundary_id_in_tria));
513 const typename DoFHandler<dim>::active_cell_iterator &cell,
532 const typename DoFHandler<dim>::active_cell_iterator &cell,
576 const bool gather_cls,
578 const std::string &domain_name,
579 const bool time_average);
639 template <
typename VectorType>
668 template <
typename VectorType>
671 const bool gather_cls,
673 const std::string &domain_name,
705 std::pair<double, bool>
708 const double phase_value_q);
748 std::shared_ptr<FiniteElement<dim>>
fe;
852 std::vector<SolutionTransfer<dim, GlobalVectorType>>
869 std::vector<std::shared_ptr<HeatTransferAssemblerBase<dim>>>
assemblers;
891 std::vector<std::shared_ptr<ThermalConductivityModel>>
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)
Class that stores the information required by the assembly procedure for a heat transfer advection-di...
void write_geometric_melt_volume()
Write the geometric melt volume to an output file.
void percolate_time_vectors() override
Rearrange vector solution correctly for transient simulations.
void write_algebraic_melt_volume()
Post-processing. Write the algebraic melt volume to an output file.
TimerOutput computing_timer
Store information related to the computing time such as CPU times or wall time.
HeatTransfer(MultiphysicsInterface< dim > *multiphysics_interface, const SimulationParameters< dim > &p_simulation_parameters, const std::shared_ptr< parallel::DistributedTriangulationBase< dim > > &p_triangulation, std::shared_ptr< SimulationControl > p_simulation_control)
Constructor of the HeatTransfer object.
void assemble_nitsche_heat_restriction(const bool assemble_matrix)
Call for the assembly of the matrix and the right-hand side of the Nitsche restriction for the heat t...
GlobalVectorType local_evaluation_point
The local evaluation point. Ghosts cells are not considered in this evaluation.
void postprocess_geometric_melt_volume_and_surface()
Compute the geometric melt volume (3D) or surface (2D) and the contour surface area (3D) or length (2...
void solve_linear_system() override
Call for the solution of the linear system of equation using ILU or GMRES.
GlobalVectorType & get_system_rhs() override
Getter method to access the private attribute system_rhs for the physic currently solved.
IndexSet locally_owned_dofs
Store a subset of the DoF indices that are stored on a particular processor on a distributed architec...
std::shared_ptr< SimulationControl > simulation_control
Responsible for the control of steady-state and transient simulations. Contains all the information r...
GlobalVectorType average_temperature_to_output
Locally owned average temperature calculated using the AverageScalar object.
double calculate_L2_error()
Calculate the L2 error of the solution.
TableHandler melt_volume_geo_table
Evolution of the melt volume in the simulated domain.
TableHandler heat_flux_table
Contain heat flux information used for post-processing:
std::shared_ptr< AverageScalar< dim > > average_temperature
Compute the average temperature in time.
std::shared_ptr< TrilinosWrappers::PreconditionAMG > amg_preconditioner
AMG preconditioner used by the iterative linear solver.
void postprocess_algebraic_melt_volume()
Compute the algebraic (phase indicator and liquid fraction weighted) melt volume (3D) or surface (2D)...
MultiphysicsInterface< dim > * multiphysics
void postprocess_temperature_statistics(const bool gather_cls, const Parameters::FluidIndicator monitored_fluid, const std::string &domain_name, const bool time_average)
Post-processing. Calculate temperature statistics on the domain : Max, min, average and standard-devi...
void setup_ilu()
Set up the ILU preconditioner stored in ilu_preconditioner.
std::vector< HeatFluxPostprocessor< dim > > heat_flux_postprocessors
Compute local heat flux quantities from temperature field and material properties.
TrilinosWrappers::SparseMatrix system_matrix
The system matrix.
void output_per_iteration_timer() override
Output the per iteration wallclock times.
virtual void copy_local_matrix_to_global_matrix(const StabilizedMethodsCopyData ©_data)
Copy local cell information to global matrix.
GlobalVectorType & get_local_evaluation_point() override
Getter method to access the private attribute local_evaluation_point for the physic currently solved.
virtual void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, HeatTransferScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data)
Assemble the local rhs for a given cell.
AffineConstraints< double > zero_constraints
void compute_kelly(dealii::Vector< float > &estimated_error_per_cell, const ComponentMask &component_mask)
Compute the Kelly error estimator on the temperature variable for mesh refinement....
void write_checkpoint() override
Prepare Heat Transfer to write checkpoint.
virtual void setup_assemblers()
Set up the vector of assembler functions.
const SimulationParameters< dim > & simulation_parameters
Contain the simulation parameter file information.
GlobalVectorType & get_present_solution() override
Getter method to access the private attribute present_solution for the physic currently solved....
void post_mesh_adaptation() override
Interpolate the auxiliary physics variables to the new mesh.
std::vector< std::shared_ptr< ThermalConductivityModel > > thermal_conductivity_models
Abstract class that allows to calculate the thermal conductivity on each quadrature point using the t...
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
Approximate an integral by evaluating the integrand at specific points and summing the point values w...
virtual void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, HeatTransferScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data)
Assemble the local matrix for a given cell.
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
SolutionTransfer<dim, GlobalVectorType>> is used to implement the transfer of a discrete FE function ...
std::shared_ptr< Quadrature< dim > > cell_quadrature
Approximate an integral by evaluating the integrand at specific points and summing the point values w...
void write_heat_flux(const std::string &domain_name)
Post-processing. Write the heat transfer values to an output file.
std::vector< SolutionTransfer< dim, GlobalVectorType > > previous_solutions_transfer
previous_solutions_transfer occupies the same role as solution_transfer but for solutions at previous...
std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Gather and return vector of output structs that are particular to some applications.
std::pair< double, bool > set_phase_coefficient(const bool gather_cls, const Parameters::FluidIndicator monitored_fluid, const double phase_value_q)
Set a phase_coefficient that is used in the postprocessing, to account for multiphase flow.
void write_temperature_statistics(const std::string &domain_name)
Post-processing. Write the temperature statistics to an output file.
GlobalVectorType evaluation_point
The point at which the evaluation is performed.
void setup_amg()
Set up the AMG preconditioner stored in amg_preconditioner.
std::shared_ptr< Mapping< dim > > temperature_mapping
Transformation which maps point in the reference cell to points in the actual grid cell.
void assemble_rhs()
Call for the assembly of the right-hand side.
const bool GGLS
Reference for GGLS https://onlinelibrary.wiley.com/doi/abs/10.1002/nme.2324 Warning,...
void read_checkpoint() override
Allow Heat Transfer to set up solution vector from checkpoint file.
GlobalVectorType newton_update
The direction used to perform the newton iteration in . Where is the size of the step.
void finish_simulation() override
Carry out the operations required to finish a simulation correctly.
std::vector< TableHandler > temperature_isocontour_bounding_values_tables
Vector of tables containing evolution of temperature isocontour bounding values.
void pre_mesh_adaptation() override
Prepare the auxiliary physics variables for a mesh refinement/coarsening.
void postprocess_thermal_energy_in_fluid(const bool gather_cls, const Parameters::FluidIndicator monitored_fluid, const std::string &domain_name, const VectorType ¤t_solution_fd)
AffineConstraints< double > & get_nonzero_constraints() override
Getter method to access the private attribute nonzero_constraints for the physic currently solved.
std::vector< std::shared_ptr< HeatTransferAssemblerBase< dim > > > assemblers
Assemblers for the matrix and the right hand side (RHS).
const DoFHandler< dim > & get_dof_handler() override
Getter method to access the private attribute dof_handler for the physic currently solved....
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.
double calculate_delta_T_ref(double minimum_delta_T_ref=1.)
Calculate delta_T_ref for the DCDD shock capture mechanism. delta_T_ref = T_max - T_min.
std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for t...
double get_residual_rescale_metric() const override
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_vol...
void update_boundary_conditions() override
Update non zero constraints if the boundary is time-dependent.
std::shared_ptr< DoFHandler< dim > > dof_handler
Given a triangulation and a description of a finite element, this class enumerates degrees of freedom...
ConvergenceTable error_table
Store some convergence data, such as residuals of the cg-method, or some evaluated L2-errors of discr...
void postprocess(bool first_iteration) override
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
void output_newton_update_norms() override
Output the L2 and Linfty norms of the correction vector.
IndexSet locally_relevant_dofs
Store a subset of the DoF indices that contains both the locally_owned_dofs and the DoF indices on gh...
void assemble_system_matrix() override
Assemble the matrix associated with the solver.
std::vector< HeatFluxPostprocessor< dim > > average_heat_flux_postprocessors
Compute local average heat flux quantities from temperature field and material properties.
std::shared_ptr< GlobalVectorType > present_solution
A vector containing all the values of the solution.
std::shared_ptr< FiniteElement< dim > > fe
The base class for finite element.
void assemble_system_rhs() override
Assemble the rhs associated with the solver.
void setup_dofs() override
Set up the DofHandler and the degrees of freedom associated with the physics.
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
Previous solution vector.
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
Collection of cells that cover the domain on which one wants to solve a partial differential equation...
void verify_consistency_of_boundary_conditions()
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary ...
void postprocess_heat_flux_on_bc(const bool gather_cls, const VectorType ¤t_solution_fd)
GlobalVectorType & get_evaluation_point() override
Getter method to access the private attribute evaluation_point for the physic currently solved.
GlobalVectorType & get_newton_update() override
Getter method to access the private attribute newton_update for the physic currently solved.
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
ILU preconditioner used by the iterative linear solver.
TableHandler statistics_table
Temperature statistics table used for post-processing. It contains the minimum , maximum,...
AffineConstraints< double > nonzero_constraints
Store the nonzero constraints that arise from several sources such as boundary conditions and hanging...
virtual void copy_local_rhs_to_global_rhs(const StabilizedMethodsCopyData ©_data)
Copy local cell rhs information to global rhs.
void assemble_matrix_and_rhs()
Call for the assembly of the matrix and the right-hand side.
GlobalVectorType system_rhs
The right hand side vector.
void postprocess_heat_flux_on_nitsche_ib()
void set_initial_conditions() override
Set up the initial conditions associated with the physics. heat_transfer allows a temperature functio...
TableHandler melt_volume_alge_table
Liquid fraction in the domain.
PhysicsSolverStrategy< GlobalVectorType > * physics_solving_strategy
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
DeclException1(HeatTransferBoundaryConditionMissing, types::boundary_id,<< "The boundary id: "<< arg1<< " is defined in the triangulation, but not as a boundary condition for the heat transfer 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.")
Variable
Solution fields of the different physics that are used as an indicator for multiple purposes (e....
@ temperature
Temperature scalar field from heat transfer.
PhysicsID
Unique identifiers for each physics module in Lethe.
@ heat_transfer
Heat transfer (Temperature).
FluidIndicator
Class to account for different fluid indicators. This is used for multiphase simulations in PostProce...
Simulation control classes for managing time-stepping and iteration control in Lethe.
GlobalVectorType VectorType
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType