Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
heat_transfer.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
4#ifndef lethe_heat_transfer_h
5#define lethe_heat_transfer_h
6
7#include <core/bdf.h>
9#include <core/vector.h>
10
17
18#include <deal.II/base/convergence_table.h>
19#include <deal.II/base/quadrature_lib.h>
20#include <deal.II/base/timer.h>
21
22#include <deal.II/distributed/tria_base.h>
23
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>
28
29#include <deal.II/grid/grid_tools.h>
30
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>
34
35#include <deal.II/non_matching/fe_values.h>
36#include <deal.II/non_matching/mesh_classifier.h>
37
38#include <deal.II/numerics/solution_transfer.h>
39
40#include <utility>
41
43 HeatTransferBoundaryConditionMissing,
44 types::boundary_id,
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.");
47
48
49/**
50 * @brief Implementation of heat transfer as an auxiliary physics. The heat
51 * equation is weakly coupled to the velocity field. Equation solved:
52 * \f$ \rho C_p \cdot \left( \frac{dT}{dt} + u \cdot \nabla T \right) =
53 * k \cdot \nabla^2 T + \tau : \nabla u \f$
54 *
55 */
56
57template <int dim>
58class HeatTransfer : public AuxiliaryPhysics<dim, GlobalVectorType>
59{
60public:
61 /**
62 * @brief Constructor of the HeatTransfer object.
63 *
64 * @param multiphysics_interface Map of the auxiliary physics that will be
65 * solved on top of a computational fluid dynamic simulation.
66 *
67 * @param p_simulation_parameters Contain the simulation parameter file
68 * information.
69 *
70 * @param p_triangulation Contain the mesh information. In a
71 * parallel::DistributedTriangulationBase<dim> not every detail may be known
72 * on each processor. The mesh is distributed between the processors.
73 *
74 * @param p_simulation_control Object responsible for the control of
75 * steady-state and transient simulations. Contains all the information
76 * related to time stepping and the stopping criteria.
77 *
78 */
80 MultiphysicsInterface<dim> *multiphysics_interface,
81 const SimulationParameters<dim> &p_simulation_parameters,
82 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
83 &p_triangulation,
84 std::shared_ptr<SimulationControl> p_simulation_control)
86 p_simulation_parameters.physics_solving_strategy.at(
88 , multiphysics(multiphysics_interface)
89 , computing_timer(p_triangulation->get_mpi_communicator(),
90 this->pcout,
91 TimerOutput::never,
92 TimerOutput::wall_times)
93 , simulation_parameters(p_simulation_parameters)
94 , triangulation(p_triangulation)
95 , simulation_control(std::move(p_simulation_control))
96 , dof_handler(std::make_shared<DoFHandler<dim>>(*triangulation))
98 p_simulation_parameters.physical_properties_manager
99 .get_thermal_conductivity_vector())
101 p_simulation_parameters.post_processing.isocontour_bounding_boxes
102 .ids_and_isocontours_per_variable.count(Variable::temperature))
103 {
104 this->pcout << std::setprecision(simulation_control->get_log_precision())
105 << std::scientific;
106
107 if (simulation_parameters.mesh.simplex)
108 {
109 // for simplex meshes
110 fe = std::make_shared<FE_SimplexP<dim>>(
111 simulation_parameters.fem_parameters.temperature_degree);
112 temperature_mapping = std::make_shared<MappingFE<dim>>(*fe);
113 cell_quadrature = std::make_shared<QGaussSimplex<dim>>(fe->degree + 1);
115 std::make_shared<QGaussSimplex<dim - 1>>(fe->degree + 1);
116 }
117 else
118 {
119 // Usual case, for quad/hex meshes
120 fe = std::make_shared<FE_Q<dim>>(
121 simulation_parameters.fem_parameters.temperature_degree);
122 temperature_mapping = std::make_shared<MappingQ<dim>>(fe->degree);
123 cell_quadrature = std::make_shared<QGauss<dim>>(fe->degree + 1);
124 face_quadrature = std::make_shared<QGauss<dim - 1>>(fe->degree + 1);
125 }
126
127 // Initialize solution shared_ptr
128 present_solution = std::make_shared<GlobalVectorType>();
129
130 // Allocate solution transfer
132 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
133
134 // Initialize and set size of previous solutions using BDF schemes
135 // information
136 previous_solutions = std::make_shared<std::vector<GlobalVectorType>>(
138
139 // Prepare previous solutions transfer
141 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
142 {
143 previous_solutions_transfer.emplace_back(
144 SolutionTransfer<dim, GlobalVectorType>(*this->dof_handler));
145 }
146
147 if (simulation_parameters.post_processing.calculate_average_temp_and_hf)
148 {
150 std::make_shared<AverageScalar<dim>>(*this->dof_handler);
151 }
152 }
153
154 /**
155 * @brief Call for the assembly of the matrix and the right-hand side.
156 *
157 * @deprecated This function is to be deprecated when the new assembly mechanism
158 * is integrated to this solver.
159 */
160 void
162
163 /**
164 * @brief Call for the assembly of the right-hand side.
165 *
166 * @deprecated This function is to be deprecated when the new assembly mechanism
167 * is integrated to this solver.
168 */
169 void
170 assemble_rhs();
171
172 /**
173 * @brief Call for the assembly of the matrix and the right-hand side of the Nitsche restriction for the heat transfer equation.
174 *
175 * @param assemble_matrix Boolean that is true for matrix assembly, and false for rhs assembly.
176 */
177 void
178 assemble_nitsche_heat_restriction(const bool assemble_matrix);
179
180 /**
181 * @brief Gather and return vector of output structs that are particular to some applications.
182 *
183 * @return Vector of OutputStructs that will be used to write the output results as VTU files.
184 */
185 std::vector<OutputStruct<dim, GlobalVectorType>>
186 gather_output_hook() override;
187
188 /**
189 * @brief Calculate delta_T_ref for the DCDD shock capture mechanism. delta_T_ref = T_max - T_min.
190 *
191 * @param minimum_delta_T_ref Minimum temperature value acceptable as reference to calculate the DCDD shock capture stabilization term.
192 * DCDD shock capture elements are divided by delta_T_ref. Limiting
193 * delta_T_ref prevents overestimation of the virtual diffusivity at
194 * simulations with low differences between minimum and maximum temperatures.
195 *
196 * @return The difference between the maximal temperature and the minimal temperature in the whole domain.
197 */
198 double
199 calculate_delta_T_ref(double minimum_delta_T_ref = 1.);
200
201 /**
202 * @brief Calculate the L2 error of the solution.
203 */
204 double
206
207
208 /**
209 * @brief Carry out the operations required to finish a simulation correctly.
210 */
211 void
212 finish_simulation() override;
213
214 /**
215 * @brief Rearrange vector solution correctly for transient simulations.
216 */
217 void
218 percolate_time_vectors() override;
219
220 /**
221 * @brief Postprocess the auxiliary physics results. Post-processing this case implies
222 * the calculation of all derived quantities using the solution vector of the
223 * physics. It does not concern the output of the solution using the
224 * DataOutObject, which is accomplished through the attach_solution_to_output
225 * function
226 */
227 void
228 postprocess(bool first_iteration) override;
229
230 /**
231 * @brief Output the per iteration wallclock times.
232 */
233 void
235
236 /**
237 * @brief Prepare the auxiliary physics variables for a
238 * mesh refinement/coarsening.
239 */
240 void
241 pre_mesh_adaptation() override;
242
243 /**
244 * @brief Interpolate the auxiliary physics variables to the new mesh.
245 */
246 void
247 post_mesh_adaptation() override;
248
249 /**
250 * @brief Compute the error estimator for mesh refinement.
251 *
252 * @param[in] ivar The current element of the map
253 * simulation_parameters.mesh_adaptation.variables
254 *
255 * @param[in,out] estimated_error_per_cell The deal.II vector of
256 * estimated_error_per_cell
257 */
258 void
260 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
261 &ivar,
262 dealii::Vector<float> &estimated_error_per_cell) override;
263
264 /**
265 * @brief Compute the Kelly error estimator on the temperature variable for mesh refinement.
266 * See :
267 * https://www.dealii.org/current/doxygen/deal.II/classKellyErrorEstimator.html
268 * for more information on the Kelly error estimator.
269 *
270 * @param[in,out] estimated_error_per_cell The deal.II vector of
271 * estimated_error_per_cell
272 * @param[in] component_mask The component mask corresponding to the
273 * temperature variable
274 */
275 void
276 compute_kelly(dealii::Vector<float> &estimated_error_per_cell,
277 const ComponentMask &component_mask);
278
279 /**
280 * @brief Prepare Heat Transfer to write checkpoint.
281 */
282 void
283 write_checkpoint() override;
284
285 /**
286 * @brief Allow Heat Transfer to set up solution vector from checkpoint file.
287 */
288 void
289 read_checkpoint() override;
290
291 /**
292 * @brief Returns a vector of references to TableHandler objects that needs to
293 * be serialized/deserialized for the Heat Transfer solver.
294 *
295 * @return Structure containing a vector of references to TableHandler objects
296 * that needs to be serialized/deserialized for the Heat Transfer solver, and
297 * their corresponding file names.
298 */
299 std::vector<OutputStructTableHandler>
300 gather_tables() override;
301
302 /**
303 * @brief Set up the DofHandler and the degrees of freedom associated with the physics.
304 */
305 void
306 setup_dofs() override;
307
308 /**
309 * @brief Set up the initial conditions associated with the physics.
310 * heat_transfer allows a temperature function initial condition over the
311 * the domain.
312 */
313 void
314 set_initial_conditions() override;
315
316 /**
317 * @brief Update non zero constraints if the boundary is time-dependent.
318 */
319 void
321
322 /**
323 * @brief Call for the solution of the linear system of equation using ILU
324 * or GMRES.
325 */
326 void
327 solve_linear_system() override;
328
329 /**
330 * @brief Set up the ILU preconditioner stored in ilu_preconditioner.
331 */
332 void
333 setup_ilu();
334
335 /**
336 * @brief Set up the AMG preconditioner stored in amg_preconditioner.
337 */
338 void
339 setup_amg();
340
341 /**
342 * @brief Getter method to access the private attribute dof_handler for the
343 * physic currently solved. NB : dof_handler is now passed to the
344 * multiphysics interface at the end of the setup_dofs method.
345 *
346 * @return A list of the indices of the degrees of freedom.
347 */
348 const DoFHandler<dim> &
350 {
351 return *dof_handler;
352 }
353
354 /**
355 * @brief Getter method to access the private attribute evaluation_point for
356 * the physic currently solved.
357 *
358 * @return The vector at which the evaluation is performed.
359 */
362 {
363 return evaluation_point;
364 }
365
366 /**
367 * @brief Getter method to access the private attribute
368 * local_evaluation_point for the physic currently solved.
369 *
370 * @return The local evaluation point. Ghosts cells are not considered in
371 * this evaluation.
372 */
375 {
377 }
378
379 /**
380 * @brief Getter method to access the private attribute
381 * newton_update for the physic currently solved.
382 *
383 * @return The direction used to perform the newton iteration.
384 */
387 {
388 return newton_update;
389 }
390
391 /**
392 * @brief Getter method to access the private attribute
393 * present_solution for the physic currently solved. NB : present_solution is
394 * now passed to the multiphysics interface at the end of the setup_dofs
395 * method.
396 *
397 * @return A vector containing all the values of the solution.
398 */
401 {
402 return *present_solution;
403 }
404
405 /**
406 * @brief Getter method to access the private attribute
407 * system_rhs for the physic currently solved.
408 *
409 * @return Right hand side vector.
410 */
412 get_system_rhs() override
413 {
414 return system_rhs;
415 }
416
417 /**
418 * @brief Getter method to access the private attribute
419 * nonzero_constraints for the physic currently solved.
420 *
421 * @return Store the nonzero constraints that arise from several sources such
422 * as boundary conditions and hanging nodes in the mesh. See the deal.II
423 * documentation on constraints on degrees of freedom for more information.
424 */
425 AffineConstraints<double> &
427 {
428 return nonzero_constraints;
429 }
430
431 /**
432 * @brief Output the L2 and Linfty norms of the correction vector.
433 */
434 void
436 {
437 this->pcout << "\t ||dT||_L2 = " << std::setw(6) << newton_update.l2_norm()
438 << std::setw(6)
439 << "\t ||dT||_Linfty = " << newton_update.linfty_norm()
440 << std::endl;
441 }
442
443 /**
444 * @brief Return the metric for residual rescaling. By default, should return 1.
445 * If the rescale_residual_by_volume is set to true, the method
446 * returns the global volume of the triangulation.
447 *
448 * @return Rescale metric.
449 */
450 double
452 {
453 return simulation_parameters.linear_solver.at(PhysicsID::heat_transfer)
454 .rescale_residual_by_volume ?
455 std::sqrt(GridTools::volume(*this->triangulation,
456 *this->temperature_mapping)) :
457 1.;
458 }
459
460private:
461 /**
462 * @brief Verify consistency of the input parameters for boundary
463 * conditions to ensure that for every boundary condition within the
464 * triangulation, a boundary condition has been specified in the input file.
465 */
466 void
468 {
469 // Sanity check all of the boundary conditions of the triangulation to
470 // ensure that they have a type.
471 std::vector<types::boundary_id> boundary_ids_in_triangulation =
472 this->triangulation->get_boundary_ids();
473 for (auto const &boundary_id_in_tria : boundary_ids_in_triangulation)
474 {
475 AssertThrow(simulation_parameters.boundary_conditions_ht.type.find(
476 boundary_id_in_tria) !=
477 simulation_parameters.boundary_conditions_ht.type.end(),
478 HeatTransferBoundaryConditionMissing(boundary_id_in_tria));
479 }
480 }
481
482 /**
483 * @brief Assemble the matrix associated with the solver
484 */
485 void
486 assemble_system_matrix() override;
487
488 /**
489 * @brief Assemble the rhs associated with the solver
490 */
491 void
492 assemble_system_rhs() override;
493
494
495 /**
496 * @brief Assemble the local matrix for a given cell.
497 *
498 * Use the WorkStream class to assemble the system matrix. It is
499 * a thread safe function.
500 *
501 * @param cell The cell for which the local matrix is assembled.
502 *
503 * @param scratch_data The scratch data which is used to store
504 * the calculated finite element information at the gauss point.
505 * See the documentation for HeatTransferScratchData for more
506 * information
507 *
508 * @param copy_data The copy data which is used to store
509 * the results of the assembly over a cell
510 */
511 virtual void
513 const typename DoFHandler<dim>::active_cell_iterator &cell,
514 HeatTransferScratchData<dim> &scratch_data,
515 StabilizedMethodsCopyData &copy_data);
516
517 /**
518 * @brief Assemble the local rhs for a given cell
519 *
520 * @param cell The cell for which the local matrix is assembled.
521 *
522 * @param scratch_data The scratch data which is used to store
523 * the calculated finite element information at the gauss point.
524 * See the documentation for HeatTransferScratchData for more
525 * information
526 *
527 * @param copy_data The copy data which is used to store
528 * the results of the assembly over a cell
529 */
530 virtual void
532 const typename DoFHandler<dim>::active_cell_iterator &cell,
533 HeatTransferScratchData<dim> &scratch_data,
534 StabilizedMethodsCopyData &copy_data);
535
536 /**
537 * @brief Set up the vector of assembler functions
538 */
539 virtual void
541
542
543 /**
544 * @brief Copy local cell information to global matrix
545 */
546
547 virtual void
549 const StabilizedMethodsCopyData &copy_data);
550
551 /**
552 * @brief Copy local cell rhs information to global rhs
553 */
554
555 virtual void
557
558 /**
559 * @brief Post-processing.
560 * Calculate temperature statistics on the domain : Max, min, average and
561 * standard-deviation.
562 *
563 * @param gather_cls Boolean true when CLS=true (multiphase flow), used to gather
564 * CLS information.
565 *
566 * @param monitored_fluid Fluid indicator (fluid_0 or fluid_1 or both) corresponding
567 * to the phase of interest.
568 *
569 * @param domain_name String indicating the monitored_fluid in the output filename.
570 *
571 * @param time_average Boolean true when calculating the spacial average of the time-averaged temperature solution.
572 */
573
574 void
576 const bool gather_cls,
577 const Parameters::FluidIndicator monitored_fluid,
578 const std::string &domain_name,
579 const bool time_average);
580
581 /**
582 * @brief Post-processing. Write the temperature statistics to an output file.
583 *
584 * @param domain_name string indicating the postprocessed_fluid in the
585 * console output, table and filename.
586 */
587
588 void
589 write_temperature_statistics(const std::string &domain_name);
590
591 /**
592 * @brief Compute the algebraic (phase indicator and liquid fraction weighted)
593 * melt volume (3D) or surface (2D) in a domain. The monitored fluid must
594 * be selected with
595 * Parameters::PostProcessing::monitored_fluid_with_phase_change.
596 *
597 * @remark For CLS multiphase flow, only one of the fluids can be monitored.
598 */
599 void
601
602 /**
603 * @brief Post-processing. Write the algebraic melt volume to an output file.
604 */
605 void
607
608 /**
609 * @brief Compute the geometric melt volume (3D) or surface (2D) and the
610 * contour surface area (3D) or length (2D) in a domain. The melt region is
611 * delimited by the Parameters::PostProcessing::melting_temperature
612 * isosurface (3D) or isocurve (2D) within the subdomain occupied by the fluid
613 * selected with
614 * Parameters::PostProcessing::monitored_fluid_with_phase_change.
615 *
616 * @remark For CLS multiphase flow, only one of the fluids can be monitored.
617 * The volume is computed as the geometrical volume with respect to
618 * the phase indicator isocurve (isosurface) of value 0.5.
619 */
620 void
622
623 /**
624 * @brief Write the geometric melt volume to an output file.
625 */
626 void
628
629 /**
630 * Post-processing. Calculate the heat flux at heat transfer boundary
631 * conditions.
632 *
633 * @param gather_cls boolean true when CLS=true (multiphase flow), used to gather
634 * CLS information
635 *
636 * @param current_solution_fd current solution for the fluid dynamics, parsed
637 * by postprocess
638 */
639 template <typename VectorType>
640 void
641 postprocess_heat_flux_on_bc(const bool gather_cls,
642 const VectorType &current_solution_fd);
643
644 /**
645 * Post-processing. Calculate the heat flux in the Nitsche immersed boundary.
646 *
647 */
648 void
650
651 /**
652 * Post-processing. Calculate the thermal energy \f$ (\rho \cdot C_p \cdot T)
653 * \f$ in a fluid domain.
654 *
655 * @param gather_cls Boolean true when CLS=true (multiphase flow), used to gather
656 * CLS information.
657 *
658 * @param monitored_fluid Fluid indicator (fluid_0 or fluid_1 or both) corresponding
659 * to the phase of interest.
660 *
661 * @param domain_name String indicating the monitored_fluid in the console output,
662 * table and filename.
663 *
664 * @param current_solution_fd Current solution for the fluid dynamics, parsed
665 * by postprocess.
666 */
667
668 template <typename VectorType>
669 void
671 const bool gather_cls,
672 const Parameters::FluidIndicator monitored_fluid,
673 const std::string &domain_name,
674 const VectorType &current_solution_fd);
675
676 /**
677 * @brief Post-processing. Write the heat transfer values to an output file.
678 *
679 * @param domain_name string indicating the postprocessed_fluid in the
680 * console output, table and filename.
681 */
682
683 void
684 write_heat_flux(const std::string &domain_name);
685
686 /**
687 * @brief Set a phase_coefficient that is used in the postprocessing, to
688 * account for multiphase flow.
689 *
690 * Returns
691 * - a double: phase_coefficient from 0 to 1, see the documentation on CLS for
692 * more information,
693 * - a boolean: point_is_in_postprocessed_fluid, true if the quadrature point
694 * is in the postprocessed_fluid (used for min_max_temperature calculation)
695 *
696 * @param gather_cls boolean true when CLS=true (multiphase flow), used to gather
697 * CLS information
698 *
699 * @param monitored_fluid Fluid indicator (fluid_0 or fluid_1 or both) corresponding
700 * to the phase of interest.
701 *
702 * @param phase_value_q double corresponding to the phase value at this quadrature point
703 */
704
705 std::pair<double, bool>
706 set_phase_coefficient(const bool gather_cls,
707 const Parameters::FluidIndicator monitored_fluid,
708 const double phase_value_q);
709
710
712
713 /**
714 * @brief Store information related to the computing time such as CPU times or
715 * wall time.
716 */
717 TimerOutput computing_timer;
718
719 /**
720 * @brief Contain the simulation parameter file information.
721 */
723
724
725 // Core elements for the heat transfer simulation
726
727 /**
728 * @brief Collection of cells that cover the domain on which one wants to
729 * solve a partial differential equation.
730 */
731 std::shared_ptr<parallel::DistributedTriangulationBase<dim>> triangulation;
732 /**
733 * @brief Responsible for the control of steady-state and transient
734 * simulations. Contains all the information related to time stepping and the
735 * stopping criteria. See simulation_control abstract class for more
736 * information.
737 */
738 std::shared_ptr<SimulationControl> simulation_control;
739 /**
740 * @brief Given a triangulation and a description of a finite element, this
741 * class enumerates degrees of freedom on all vertices, edges, faces, and
742 * cells of the triangulation.
743 */
744 std::shared_ptr<DoFHandler<dim>> dof_handler;
745 /**
746 * @brief The base class for finite element.
747 */
748 std::shared_ptr<FiniteElement<dim>> fe;
749
750 /**
751 * @brief Store some convergence data, such as residuals of the cg-method,
752 * or some evaluated <i>L<sup>2</sup></i>-errors of discrete solutions.
753 * Evaluate convergence rates or orders.
754 */
755 ConvergenceTable error_table;
756
757 // Mapping and Quadrature
758
759 /**
760 * @brief Transformation which maps point in the reference cell to
761 * points in the actual grid cell.
762 */
763 std::shared_ptr<Mapping<dim>> temperature_mapping;
764 /**
765 * @brief Approximate an integral by evaluating the integrand at specific
766 * points and summing the point values with specific weights.
767 */
768 std::shared_ptr<Quadrature<dim>> cell_quadrature;
769 /**
770 * @brief Approximate an integral by evaluating the integrand at specific
771 * points and summing the point values with specific weights.
772 */
773 std::shared_ptr<Quadrature<dim - 1>> face_quadrature;
774
775
776 // Solution storage:
777
778 /**
779 * @brief Store a subset of the DoF indices that are stored on a
780 * particular processor on a distributed architecture.
781 */
783 /**
784 * @brief Store a subset of the DoF indices that contains both the
785 * locally_owned_dofs and the DoF indices on ghost cells.
786 */
788
789 /**
790 * @brief The point at which the evaluation is performed.
791 */
793 /**
794 * @brief The local evaluation point. Ghosts cells are not considered in
795 * this evaluation.
796 */
798 /**
799 * @brief The direction \f$ \delta u^n \f$ used to perform the newton iteration
800 * in \f$ u^{n+1} = u^n + \alpha ^n \delta u ^n \f$. Where \f$ \alpha ^n \f$
801 * is the size of the step.
802 */
804 /**
805 * @brief A vector containing all the values of the solution.
806 */
807 std::shared_ptr<GlobalVectorType> present_solution;
808 /**
809 * @brief The right hand side vector.
810 */
812 /**
813 * @brief Store the nonzero constraints that arise from several sources such
814 * as boundary conditions and hanging nodes in the mesh. See the deal.II
815 * documentation on constraints on degrees of freedom for more information.
816 */
817 AffineConstraints<double> nonzero_constraints;
818 AffineConstraints<double> zero_constraints;
819 /**
820 * @brief The system matrix.
821 */
822 TrilinosWrappers::SparseMatrix system_matrix;
823
824 /**
825 * @brief ILU preconditioner used by the iterative linear solver.
826 */
827 std::shared_ptr<TrilinosWrappers::PreconditionILU> ilu_preconditioner;
828
829 /**
830 * @brief AMG preconditioner used by the iterative linear solver.
831 */
832 std::shared_ptr<TrilinosWrappers::PreconditionAMG> amg_preconditioner;
833
834
835 /**
836 * @brief Previous solution vector.
837 */
838 std::shared_ptr<std::vector<GlobalVectorType>> previous_solutions;
839
840 /**
841 * @brief SolutionTransfer<dim, GlobalVectorType>> is
842 * used to implement the transfer of a discrete FE function
843 * (e.g. a solution vector) from one mesh to another. This Deal.ii class is
844 * used for mesh_refinement and simulation restarts.
845 */
846 std::shared_ptr<SolutionTransfer<dim, GlobalVectorType>> solution_transfer;
847
848 /**
849 * @brief previous_solutions_transfer occupies the same role as
850 * solution_transfer but for solutions at previous time steps.
851 */
852 std::vector<SolutionTransfer<dim, GlobalVectorType>>
854
855 /**
856 * @brief Reference for GGLS https://onlinelibrary.wiley.com/doi/abs/10.1002/nme.2324
857 * Warning, this GGLS implementation is valid only for Linear elements
858 * Quad elements will be lacking the third derivative of the diffusion
859 * operator Whether this affects or not the final result is unclear to me at
860 * the moment. Additionnaly, this formulation does not use the gradient of the
861 * source term. The same applies, I have no clue if this is detrimental or not
862 * to the solution since anyway the GGLS term scales as h^(order+1).
863 */
864 const bool GGLS = true;
865
866 /**
867 * @brief Assemblers for the matrix and the right hand side (RHS).
868 */
869 std::vector<std::shared_ptr<HeatTransferAssemblerBase<dim>>> assemblers;
870
871 /**
872 * @brief Temperature statistics table used for post-processing. It contains
873 * the minimum , maximum, average and standard deviation of the temperature.
874 */
875 TableHandler statistics_table;
876
877 /**
878 * @brief Contain heat flux information used for post-processing:
879 * - the total fluxes on a boundary: \f$(-k \nabla T + u \rho C_p) \cdot n \f$
880 * - the convective heat flux on a boundary: \f$ h(T-T_{inf}) \f$
881 * - the total fluxes on the nitsche immersed boundaries (if active)
882 */
883 TableHandler heat_flux_table;
884
885 // Heat flux postprocessing
886
887 /**
888 * @brief Abstract class that allows to calculate the thermal conductivity on
889 * each quadrature point using the temperature of the fluid.
890 */
891 std::vector<std::shared_ptr<ThermalConductivityModel>>
893
894 /**
895 * @brief Compute the average temperature in time.
896 */
897 std::shared_ptr<AverageScalar<dim>> average_temperature;
898
899 /**
900 * @brief Locally owned average temperature calculated using the AverageScalar object.
901 */
903
904 /**
905 * @brief Compute local heat flux quantities from temperature field and
906 * material properties.
907 */
908 std::vector<HeatFluxPostprocessor<dim>> heat_flux_postprocessors;
909
910 /**
911 * @brief Compute local average heat flux quantities from temperature field and
912 * material properties.
913 */
914 std::vector<HeatFluxPostprocessor<dim>> average_heat_flux_postprocessors;
915
916 /*
917 * Phase change post-processing. These parameters track the presence of a
918 * phase change physical property and the associated post-processing
919 * information
920 */
921
922 /**
923 * @brief Liquid fraction in the domain.
924 */
926
927 /**
928 * @brief Evolution of the melt volume in the simulated domain.
929 */
931
932 /**
933 * @brief Vector of tables containing evolution of temperature isocontour
934 * bounding values.
935 */
937};
938
939
940#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)
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 &copy_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 &copy_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 &copy_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 &current_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 &current_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 &copy_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...
Definition copy_data.h:67
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...
Definition parameters.h:75
Simulation control classes for managing time-stepping and iteration control in Lethe.
GlobalVectorType VectorType
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17