Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
cls.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_cls_h
5#define lethe_cls_h
6
7#include <core/bdf.h>
10#include <core/vector.h>
11
14#include <solvers/cls_filter.h>
20
21#include <deal.II/base/convergence_table.h>
22#include <deal.II/base/table_handler.h>
23#include <deal.II/base/timer.h>
24
25#include <deal.II/distributed/tria_base.h>
26
27#include <deal.II/grid/grid_tools.h>
28
29#include <deal.II/lac/trilinos_precondition.h>
30#include <deal.II/lac/trilinos_sparse_matrix.h>
31#include <deal.II/lac/trilinos_vector.h>
32
33#include <deal.II/numerics/solution_transfer.h>
34
35
37 InvalidNumberOfFluid,
38 int,
39 << "The CLS physics is enabled, but the number of fluids is set to " << arg1
40 << ". The CLS solver only supports 2 fluids.");
41
43 CLSBoundaryConditionMissing,
44 types::boundary_id,
45 << "The boundary id: " << arg1
46 << " is defined in the triangulation, but not as a boundary condition for the CLS 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
49 UnsupportedReinitialization,
50 "The CLS physics has been set to use DG and the latter implementation currently does not support any interface reinitialization mechanism.");
51
53 UnsupportedReinitializationWithSimplex,
54 "The CLS physics has been set to use simplex and the latter implementation currently does not support the geometric interface reinitialization mechanism.");
55
57 UnsupportedInitialProjection,
58 "The CLS physics has been set to use DG and the latter implementation currently does not support defining an initial condition with a projection.");
59
60template <int dim>
61class ConservativeLevelSet : public AuxiliaryPhysics<dim, GlobalVectorType>
62{
63public:
64 /**
65 * @brief CLS - Base constructor.
66 */
68 MultiphysicsInterface<dim> *multiphysics_interface,
69 const SimulationParameters<dim> &p_simulation_parameters,
70 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
71 &p_triangulation,
72 std::shared_ptr<SimulationControl> p_simulation_control);
73
74 /**
75 * @brief CLS - Base destructor. At the present
76 * moment this is an interface with nothing.
77 */
79
80 /**
81 * @brief Call for the assembly of the right-hand side
82 *
83 * @deprecated This function is to be deprecated when the new assembly mechanism
84 * is integrated to this solver
85 */
86 void
88
89 /**
90 * @brief Gather and return vector of output structs that are particular to some applications.
91 *
92 * @return Vector of OutputStructs that will be used to write the output results as VTU files.
93 */
94 virtual std::vector<OutputStruct<dim, GlobalVectorType>>
95 gather_output_hook() override;
96
97 /**
98 * @brief Calculates the L2 error of the solution
99 */
100 double
102
103 /**
104 * @brief Calculates the volume and mass for a given fluid phase.
105 * Used for conservation monitoring.
106 *
107 * @param solution CLS solution (phase indicator)
108 *
109 * @param current_solution_fd current solution for the fluid dynamics
110 *
111 * @param monitored_fluid Fluid indicator (fluid_0 or fluid_1) corresponding to
112 * the phase of interest.
113 */
114 template <typename VectorType>
115 void
117 const VectorType &current_solution_fd,
118 const Parameters::FluidIndicator monitored_fluid);
119
120 /**
121 * @brief Calculates the momentum for a given fluid phase.
122 * Used for conservation monitoring.
123 *
124 * @param[in] solution CLS solution (phase indicator)
125 *
126 * @param[in] current_solution_fd current solution for the fluid dynamics
127 *
128 * @param[in] monitored_fluid Fluid indicator (fluid_0 or fluid_1)
129 * corresponding to the phase of interest.
130 *
131 * @return A tensor<1,dim> corresponding to the entry_string in the prm file.
132 */
133 template <typename VectorType>
134 Tensor<1, dim>
135 calculate_momentum(const GlobalVectorType &solution,
136 const VectorType &current_solution_fd,
137 const Parameters::FluidIndicator monitored_fluid);
138
139 /**
140 * @brief Calculates the barycenter of the fluid and its velocity
141 *
142 * @param[in] solution CLS solution
143 *
144 * @param[in] current_solution_fd Fluid dynamics solution
145 *
146 */
147 template <typename VectorType>
148 std::pair<Tensor<1, dim>, Tensor<1, dim>>
150 const VectorType &current_solution_fd);
151
152 /**
153 * @brief Computes the capillary time-step constraint
154 *
155 * The time-step constraint for capillary-driven multiphase flows
156 * is computed according to [1]:
157 * \f[
158 * \Delta t_\sigma = \sqrt{\frac{(\rho_0 + \rho_1) h^3}{2 \pi \sigma}}
159 * \f]
160 *
161 * @param[in] pressure_dependent Boolean indicating if the pressure field is
162 * required. The DensityIsothermalIdealGas model requires the pressure field
163 * to compute the density.
164 *
165 * @param[in] temperature_dependent Boolean indicating if the temperature
166 * field is required. The SurfaceTensionLinear and SurfaceTensionPhaseChange
167 * models depend on the temperature field.
168 *
169 * @return Computed value of the capillary time-step constraint
170 *
171 * Reference:
172 *
173 * [1] F. Denner, F. Evrard, and B. van Wachem, “Breaching the capillary
174 * time-step constraint using a coupled VOF method with implicit surface
175 * tension,” J. Comput. Phys., vol. 459, p. 111128, Jun. 2022,
176 * doi: 10.1016/j.jcp.2022.111128
177 */
178 double
179 compute_capillary_time_step_constraint(const bool pressure_dependent,
180 const bool temperature_dependent);
181
182 /**
183 * @brief Carry out the operations required to finish a simulation correctly.
184 */
185 void
186 finish_simulation() override;
187
188 /**
189 * @brief Carry out the operations required to rearrange the values of the
190 * previous solution at the end of a time step
191 */
192 void
193 percolate_time_vectors() override;
194
195 /**
196 * @brief Carry out modifications on the auxiliary physic solution.
197 */
198 void
199 modify_solution() override;
200
201 /**
202 * @brief Postprocess the auxiliary physics results. Post-processing this case implies
203 * the calculation of all derived quantities using the solution vector of the
204 * physics. It does not concern the output of the solution using the
205 * DataOutObject, which is accomplished through the attach_solution_to_output
206 * function
207 */
208 void
209 postprocess(bool first_iteration) override;
210
211 /**
212 * @brief Output the per iteration wallclock times.
213 */
214 void
216
217 /**
218 * @brief pre_mesh_adaption Prepares the auxiliary physics variables for a
219 * mesh refinement/coarsening
220 */
221 void
222 pre_mesh_adaptation() override;
223
224 /**
225 * @brief post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
226 */
227 void
228 post_mesh_adaptation() override;
229
230
231 /**
232 * @brief Compute the error estimator for mesh refinement.
233 *
234 * @param[in] ivar The current element of the map
235 * simulation_parameters.mesh_adaptation.variables
236 *
237 * @param[in,out] estimated_error_per_cell The deal.II vector of
238 * estimated_error_per_cell
239 */
240 void
242 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
243 &ivar,
244 dealii::Vector<float> &estimated_error_per_cell) override;
245
246 /**
247 * @brief Compute the Kelly error estimator on the phase variable for mesh refinement.
248 * See :
249 * https://www.dealii.org/current/doxygen/deal.II/classKellyErrorEstimator.html
250 * for more information on the Kelly error estimator.
251 *
252 * @param[in,out] estimated_error_per_cell The deal.II vector of
253 * estimated_error_per_cell
254 * @param[in] component_mask The component mask corresponding to the phase
255 * variable
256 */
257 void
258 compute_kelly(dealii::Vector<float> &estimated_error_per_cell,
259 const ComponentMask &component_mask);
260
261 /**
262 * @brief Prepares auxiliary physics to write checkpoint
263 */
264 void
265 write_checkpoint() override;
266
267
268 /**
269 * @brief Set solution vector of Auxiliary Physics using checkpoint
270 */
271 void
272 read_checkpoint() override;
273
274 /**
275 * @brief Returns a vector of references to TableHandler objects that needs to
276 * be serialized/deserialized for the CLS solver.
277 *
278 * @return Structure containing a vector of references to TableHandler objects
279 * that needs to be serialized/deserialized for the CLS solver, and their
280 * corresponding file names.
281 */
282 std::vector<OutputStructTableHandler>
283 gather_tables() override;
284
285 /**
286 * @brief Sets-up the DofHandler and the degree of freedom associated with the physics.
287 */
288 void
289 setup_dofs() override;
290
291 /**
292 * @brief defined the zero constraints used to solve the problem.
293 */
294 void
296
297 /**
298 * @brief defined the non zero constraints used to solve the problem.
299 */
300 void
302
303 /**
304 * @brief Sets-up the initial conditions associated with the physics. Generally, physics
305 * only support imposing nodal values, but some physics additionally support
306 * the use of L2 projection or steady-state solutions.
307 */
308 void
309 set_initial_conditions() override;
310
311 /**
312 * @brief Update non zero constraints if the boundary is time dependent
313 */
314 void
316
317 /**
318 * @brief Call for the solution of the linear system of equation using a strategy appropriate
319 * to the auxiliary physics
320 */
321 void
322 solve_linear_system() override;
323
324 /**
325 * @brief Set up the ILU preconditioner stored in ilu_preconditioner.
326 */
327 void
328 setup_ilu();
329
330 /**
331 * @brief Set up the AMG preconditioner stored in amg_preconditioner.
332 */
333 void
334 setup_amg();
335
336 /**
337 * @brief Getter methods to get the private attributes for the physic currently solved
338 * NB : dof_handler and present_solution are passed to the multiphysics
339 * interface at the end of the setup_dofs method
340 */
341
342 const DoFHandler<dim> &
344 {
345 return *dof_handler;
346 }
347
350 {
351 return evaluation_point;
352 }
353
356 {
358 }
359
362 {
363 return newton_update;
364 }
365
368 {
369 return *present_solution;
370 }
371
373 get_system_rhs() override
374 {
375 return system_rhs;
376 }
377
378 AffineConstraints<double> &
380 {
381 return nonzero_constraints;
382 }
383
384 const DoFHandler<dim> &
390
391 const DoFHandler<dim> &
397
398 const GlobalVectorType &
404
405 const GlobalVectorType &
411 /**
412 * @brief Output the L2 and Linfty norms of the correction vector.
413 */
414 void
416 {
417 this->pcout << "\t ||dphi||_L2 = " << std::setw(6)
418 << newton_update.l2_norm() << std::setw(6)
419 << "\t ||dphi||_Linfty = " << newton_update.linfty_norm()
420 << std::endl;
421 }
422
423 /**
424 * @brief Return the metric for residual rescaling. By default, should return 1.
425 * If the rescale_residual_by_volume is set to true, the method
426 * returns the square root of the global volume of the triangulation.
427 *
428 * @return Rescale metric.
429 */
430 double
432 {
433 return simulation_parameters.linear_solver.at(PhysicsID::CLS)
434 .rescale_residual_by_volume ?
435 std::sqrt(
436 GridTools::volume(*this->triangulation, *this->mapping)) :
437 1.;
438 }
439
440private:
441 /**
442 * @brief Verify consistency of the input parameters for boundary
443 * conditions to ensure that for every boundary condition within the
444 * triangulation, a boundary condition has been specified in the input file.
445 */
446 void
448 {
449 // Sanity check all of the boundary conditions of the triangulation to
450 // ensure that they have a type.
451 std::vector<types::boundary_id> boundary_ids_in_triangulation =
452 this->triangulation->get_boundary_ids();
453 for (auto const &boundary_id_in_tria : boundary_ids_in_triangulation)
454 {
455 AssertThrow(simulation_parameters.cls_boundary_conditions.type.find(
456 boundary_id_in_tria) !=
457 simulation_parameters.cls_boundary_conditions.type.end(),
458 CLSBoundaryConditionMissing(boundary_id_in_tria));
459 }
460 }
461
462 /**
463 * @brief Assembles the matrix associated with the solver.
464 */
465 void
466 assemble_system_matrix() override;
467
468 /**
469 * @brief Assemble the matrix associated with the solver when CG elements are used.
470 */
471 void
473
474 /**
475 * @brief Assemble the matrix associated with the solver when DG elements are used.
476 */
477 void
479
480 /**
481 * @brief Assemble the rhs associated with the solver
482 */
483 void
484 assemble_system_rhs() override;
485
486 /**
487 * @brief Assemble the rhs associated with the solver when CG elements are used.
488 */
489 void
491
492 /**
493 * @brief Assemble the rhs associated with the solver when DG elements are used.
494 */
495 void
497
498 /**
499 * @brief Assemble the local matrix for a given cell.
500 *
501 * This function is used by the WorkStream class to assemble
502 * the system matrix. It is a thread safe function.
503 *
504 * @param cell The cell for which the local matrix is assembled.
505 *
506 * @param scratch_data The scratch data which is used to store
507 * the calculated finite element information at the gauss point.
508 * See the documentation for CLSScratchData for more
509 * information
510 *
511 * @param copy_data The copy data which is used to store
512 * the results of the assembly over a cell
513 */
514 virtual void
516 const typename DoFHandler<dim>::active_cell_iterator &cell,
517 CLSScratchData<dim> &scratch_data,
518 StabilizedMethodsCopyData &copy_data);
519
520 /**
521 * @brief Assemble the local rhs for a given cell
522 *
523 * @param cell The cell for which the local matrix is assembled.
524 *
525 * @param scratch_data The scratch data which is used to store
526 * the calculated finite element information at the gauss point.
527 * See the documentation for CLSScratchData for more
528 * information
529 *
530 * @param copy_data The copy data which is used to store
531 * the results of the assembly over a cell
532 */
533 virtual void
535 const typename DoFHandler<dim>::active_cell_iterator &cell,
536 CLSScratchData<dim> &scratch_data,
537 StabilizedMethodsCopyData &copy_data);
538
539 /**
540 * @brief sets up the vector of assembler functions
541 */
542 virtual void
544
545
546 /**
547 * @brief Copy local cell information to global matrix
548 */
549
550 virtual void
552 const StabilizedMethodsCopyData &copy_data);
553
554 /**
555 * @brief Copy local cell rhs information to global rhs
556 */
557
558 virtual void
560
561 /**
562 * @brief Limit the phase indicators between 0 and 1. This is necessary before interface sharpening.
563 * More information can be found in step_41 of deal.II tutorials:
564 * https://www.dealii.org/current/doxygen/deal.II/step_41.html
565 */
566 void
568
569 /**
570 * @brief Assemble the system for interface sharpening
571 * * This function assembles the weak form of:
572 * \f$ \Phi = c ^ {(1 - \alpha)} * (\phi ^ \alpha)\f$ if \f$ 0 <=
573 * \phi <= c \ \f$
574 * \f$ \Phi = 1 - (1 - c) ^ {(1 - \alpha)} * (1 - \phi) ^ \alpha \f$ if \f$c <
575 * \phi <= 1 \f$
576 * Reference for sharpening method
577 * https://www.sciencedirect.com/science/article/pii/S0045782500002000
578 *
579 * @param solution CLS solution (phase indicator)
580 *
581 * @param sharpening_threshold Interface sharpening threshold that represents
582 * the mass conservation level
583 *
584 */
585 void
587 GlobalVectorType &solution,
588 const double sharpening_threshold);
589
590 /**
591 * @brief Solves the assembled system to sharpen the interface. The linear_solver_tolerance
592 * is hardcoded = 1e-15, and an ILU Preconditioner is used. After solving the
593 * system, this function overwrites the solution with the sharpened solution
594 *
595 * @param solution CLS solution (phase indicator)
596 */
597 void
599
600 /**
601 * @brief Assembles a mass_matrix which is used in update_solution_and_constraints function
602 * to limit the phase indicators of cells in the range of [0,1] before
603 * sharpening the interface. More information can be found in step_41 of
604 * deal.II tutorials:
605 * https://www.dealii.org/current/doxygen/deal.II/step_41.html
606 *
607 * @param mass_matrix
608 */
609 void
610 assemble_mass_matrix(TrilinosWrappers::SparseMatrix &mass_matrix);
611
612 /**
613 * @brief Carries out interface sharpening. It is called in the modify solution function.
614 * Launches sharpen_interface with the possibility to ensure conservation and
615 * handles output messages.
616 */
617 void
619
620 /**
621 * @brief Find the sharpening threshold to ensure mass conservation of the fluid
622 * monitored, as given in the prm (CLS, subsection monitoring), by binary
623 * search.
624 */
625 double
627
628 /**
629 * @brief Calculate the mass deviation of the monitored fluid, between the current
630 * iteration and the mass at first iteration (mass_first_iteration). Used to
631 * test multiple sharpening threshold in the binary search algorithm
632 * (adaptive sharpening).
633 *
634 * @param monitored_fluid Fluid indicator (fluid_0 or fluid_1) corresponding to
635 * the phase of interest.
636 *
637 * @param sharpening_threshold Interface sharpening threshold that represents the
638 * mass conservation level
639 */
640 double
642 const double sharpening_threshold);
643
644 /**
645 * @brief Carries out interface sharpening. It is called in the modify solution function.
646 *
647 * @param solution CLS solution (phase indicator)
648 *
649 * @param sharpening_threshold Interface sharpening threshold that represents the mass conservation level
650 *
651 * @param sharpen_previous_solutions Boolean true if sharpening is applied on the present
652 * and past solutions, false if the sharpening is applied on the given
653 * solution vector only. Used to determine the sharpening threshold by binary
654 * search.
655 */
656 void
658 const double sharpening_threshold,
659 const bool sharpen_previous_solutions);
660
661 /**
662 * @brief Carries out the smoothing phase indicator with a projection step (to avoid a staircase interface).
663 */
664 void
666
667 /**
668 * @brief Assembles the matrix and rhs for calculation of a smooth phase indicator using a projection.
669 *
670 * @param solution CLS solution (phase indicator)
671 */
672 void
674
675 /**
676 * @brief Solves smooth phase indicator system.
677 * @param solution CLS solution (phase indicator)
678 */
679 void
681
682 /**
683 * @brief Apply filter on phase indicator values.
684 *
685 * @param[in] original_solution CLS solution vector to which the filter is to
686 * be applied.
687 *
688 * @param[out] filtered_solution Solution vector with filtered phase indicator
689 * values.
690 */
691 void
692 apply_phase_filter(const GlobalVectorType &original_solution,
694
695 /**
696 * @brief Reinitialize the interface between fluids using the PDE-based
697 * approach.
698 */
699 void
701
702 /**
703 * @brief Compute level-set field from the phase indicator field using an
704 * inverse tanh-based transformation.
705 *
706 * @param[in] solution Phase indicator solution field
707 *
708 * @param[out] level_set_solution Level-set solution field
709 */
710 void
712 GlobalVectorType &level_set_solution);
713
714 /**
715 * @brief Compute the phase indicator field from level-set field using a
716 * tanh-based transformation.
717 *
718 * @param[in] level_set_solution Level-set solution field
719 *
720 * @param[out] phase_indicator_solution Phase indicator solution field
721 */
722 void
724 const GlobalVectorType &level_set_solution,
725 GlobalVectorType &phase_indicator_solution);
726
727 /**
728 * @brief Reinitialize the interface between fluids using the geometric
729 * approach.
730 */
731 void
733
734 /**
735 * @brief Helper function to reinit the face velocity with the adequate solution.
736 * This prevents code duplication throughout the CLS class. The function looks
737 * at the multiphysics interface to decide if the velocity is a block velocity
738 * or a regular velocity. Furthermore, it also checks if a time-averaged
739 * solution is required. Otherwise, the code here would be copied four times.
740 *
741 * @param[in] velocity_cell the iterator of the cell where the velocity is to
742 * be reinitialized.
743 *
744 * @param[in] face_no the face index where the velocity is to be
745 * reinitialized.
746 *
747 * @param[in,out] scratch_data the scratch data to be used for the
748 * reinitialization.
749 */
750 inline void
752 const typename DoFHandler<dim>::active_cell_iterator &velocity_cell,
753 const unsigned int &face_no,
754 CLSScratchData<dim> &scratch_data)
755 {
756 if (multiphysics->fluid_dynamics_is_block())
757 {
758 scratch_data.reinit_face_velocity(velocity_cell,
759 face_no,
760 multiphysics->get_block_solution(
762 this->simulation_parameters.ale);
763 }
764 else
765 {
766 scratch_data.reinit_face_velocity(velocity_cell,
767 face_no,
768 multiphysics->get_solution(
770 this->simulation_parameters.ale);
771 }
772 }
773
774
776
778
779 TimerOutput computing_timer;
780
782
783 // Core elements for the CLS simulation
784 std::shared_ptr<parallel::DistributedTriangulationBase<dim>> triangulation;
785 std::shared_ptr<SimulationControl> simulation_control;
786 std::shared_ptr<DoFHandler<dim>> dof_handler;
787 std::shared_ptr<FiniteElement<dim>> fe;
788 ConvergenceTable error_table;
789
790 // Mapping and Quadrature
791 std::shared_ptr<Mapping<dim>> mapping;
792 std::shared_ptr<Quadrature<dim>> cell_quadrature;
793 std::shared_ptr<Quadrature<dim - 1>> face_quadrature;
794
795 // Solution storage
798
802 std::shared_ptr<GlobalVectorType> present_solution;
804 AffineConstraints<double> nonzero_constraints;
805 AffineConstraints<double> bounding_constraints;
806 AffineConstraints<double> zero_constraints;
807 TrilinosWrappers::SparseMatrix system_matrix;
808 std::shared_ptr<GlobalVectorType> filtered_solution;
809
810 /// Level-set field obtained from the phase indicator field using a tanh-based
811 /// transformation
813
814 // Previous solutions vectors
815 std::shared_ptr<std::vector<GlobalVectorType>> previous_solutions;
816
817 // Solution transfer classes
818 std::shared_ptr<SolutionTransfer<dim, GlobalVectorType>> solution_transfer;
819 std::vector<SolutionTransfer<dim, GlobalVectorType>>
821
822 // Phase indicator matrices for interface sharpening
823 TrilinosWrappers::SparseMatrix system_matrix_phase_indicator;
824 TrilinosWrappers::SparseMatrix complete_system_matrix_phase_indicator;
827 TrilinosWrappers::SparseMatrix mass_matrix_phase_indicator;
828
829 // For projected phase indicator gradient (PIG), projected curvature, and
830 // PDE-based interface reinitialization
831 std::shared_ptr<CLSSubequationsInterface<dim>> cls_subequations_interface;
832
833 std::shared_ptr<TrilinosWrappers::PreconditionILU> ilu_preconditioner;
834
835 /**
836 * @brief AMG preconditioner used by the iterative linear solver of the main
837 * conservative level set system.
838 */
839 std::shared_ptr<TrilinosWrappers::PreconditionAMG> amg_preconditioner;
840
841 // Lower and upper bounds of phase indicator
842 const double phase_upper_bound = 1.0;
843 const double phase_lower_bound = 0.0;
844
845 // Conservation Analysis
851
852 // Barycenter analysis
853 TableHandler table_barycenter;
854
855 /**
856 * @brief Vector of tables containing evolution of phase indicator isocontour
857 * bounding values.
858 */
860
861 // Assemblers for the matrix and rhs
862 std::vector<std::shared_ptr<CLSAssemblerBase<dim>>> assemblers;
863
864 // Face assemblers, used only for DG methods
865 std::shared_ptr<CLSAssemblerSIPG<dim>> inner_face_assembler;
866
867 // Phase indicator filter
868 std::shared_ptr<ConservativeLevelSetFilterBase> filter;
869
870 // Signed distance solver for geometric redistanciation
871 std::shared_ptr<InterfaceTools::SignedDistanceSolver<dim, GlobalVectorType>>
873
874 // Signed distance transformation function to a phase indicator
875 std::shared_ptr<SignedDistanceTransformationBase>
877};
878
879
880
881#endif
AuxiliaryPhysics(const Parameters::NonLinearSolver non_linear_solver_parameters)
Store the information required by the assembly procedure for a CLS free surface equation....
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)
Reinitialize the content of the scratch regarding the velocity for internal/boundary faces....
const SimulationParameters< dim > & simulation_parameters
Definition cls.h:781
GlobalVectorType system_rhs_phase_indicator
Definition cls.h:825
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 cls.cc:2513
TableHandler table_monitoring_cls
Definition cls.h:846
double find_sharpening_threshold()
Find the sharpening threshold to ensure mass conservation of the fluid monitored, as given in the prm...
Definition cls.cc:2107
TableHandler table_barycenter
Definition cls.h:853
GlobalVectorType nodal_phase_indicator_owned
Definition cls.h:775
std::shared_ptr< GlobalVectorType > filtered_solution
Definition cls.h:808
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
Definition cls.h:815
void percolate_time_vectors() override
Carry out the operations required to rearrange the values of the previous solution at the end of a ti...
Definition cls.cc:1374
double mass_monitored
Definition cls.h:848
void assemble_mass_matrix(TrilinosWrappers::SparseMatrix &mass_matrix)
Assembles a mass_matrix which is used in update_solution_and_constraints function to limit the phase ...
Definition cls.cc:3447
void assemble_system_rhs() override
Assemble the rhs associated with the solver.
Definition cls.cc:479
ConvergenceTable error_table
Definition cls.h:788
void compute_level_set_from_phase_indicator(const GlobalVectorType &solution, GlobalVectorType &level_set_solution)
Compute level-set field from the phase indicator field using an inverse tanh-based transformation.
Definition cls.cc:3580
void assemble_projection_phase_indicator(GlobalVectorType &solution)
Assembles the matrix and rhs for calculation of a smooth phase indicator using a projection.
Definition cls.cc:2307
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
Definition cls.h:784
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 cls.h:431
void setup_amg()
Set up the AMG preconditioner stored in amg_preconditioner.
Definition cls.cc:3058
const double phase_lower_bound
Definition cls.h:843
double sharpening_threshold
Definition cls.h:850
void assemble_system_matrix_dg()
Assemble the matrix associated with the solver when DG elements are used.
Definition cls.cc:275
virtual void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data)
Assemble the local rhs for a given cell.
Definition cls.cc:623
std::shared_ptr< SimulationControl > simulation_control
Definition cls.h:785
GlobalVectorType & get_evaluation_point() override
Getter methods that give access to the private attributes of the physics being solved....
Definition cls.h:349
TrilinosWrappers::SparseMatrix system_matrix
Definition cls.h:807
GlobalVectorType newton_update
Definition cls.h:801
void solve_interface_sharpening(GlobalVectorType &solution)
Solves the assembled system to sharpen the interface. The linear_solver_tolerance is hardcoded = 1e-1...
Definition cls.cc:3379
virtual void copy_local_rhs_to_global_rhs(const StabilizedMethodsCopyData &copy_data)
Copy local cell rhs information to global rhs.
Definition cls.cc:710
ConservativeLevelSet(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)
CLS - Base constructor.
Definition cls.cc:24
void modify_solution() override
Carry out modifications on the auxiliary physic solution.
Definition cls.cc:2007
void solve_projection_phase_indicator(GlobalVectorType &solution)
Solves smooth phase indicator system.
Definition cls.cc:2412
std::shared_ptr< CLSSubequationsInterface< dim > > cls_subequations_interface
Definition cls.h:831
void update_boundary_conditions() override
Update non zero constraints if the boundary is time dependent.
Definition cls.cc:2828
void smooth_phase_indicator(GlobalVectorType &solution)
Carries out the smoothing phase indicator with a projection step (to avoid a staircase interface).
Definition cls.cc:2298
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
Definition cls.h:793
void update_solution_and_constraints(GlobalVectorType &solution)
Limit the phase indicators between 0 and 1. This is necessary before interface sharpening....
Definition cls.cc:3211
void postprocess(bool first_iteration) override
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
Definition cls.cc:1385
std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for t...
Definition cls.cc:2552
GlobalVectorType & get_system_rhs() override
Definition cls.h:373
void pre_mesh_adaptation() override
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
Definition cls.cc:2466
void output_newton_update_norms() override
Output the L2 and Linfty norms of the correction vector.
Definition cls.h:415
std::shared_ptr< CLSAssemblerSIPG< dim > > inner_face_assembler
Definition cls.h:865
void assemble_system_rhs_cg()
Assemble the rhs associated with the solver when CG elements are used.
Definition cls.cc:496
std::shared_ptr< DoFHandler< dim > > dof_handler
Definition cls.h:786
MultiphysicsInterface< dim > * multiphysics
Definition cls.h:777
TrilinosWrappers::SparseMatrix system_matrix_phase_indicator
Definition cls.h:823
std::vector< std::shared_ptr< CLSAssemblerBase< dim > > > assemblers
Definition cls.h:862
void compute_kelly(dealii::Vector< float > &estimated_error_per_cell, const ComponentMask &component_mask)
Compute the Kelly error estimator on the phase variable for mesh refinement. See : https://www....
Definition cls.cc:2536
virtual void copy_local_matrix_to_global_matrix(const StabilizedMethodsCopyData &copy_data)
Copy local cell information to global matrix.
Definition cls.cc:465
GlobalVectorType local_evaluation_point
Definition cls.h:800
void finish_simulation() override
Carry out the operations required to finish a simulation correctly.
Definition cls.cc:1341
void define_zero_constraints()
defined the zero constraints used to solve the problem.
Definition cls.cc:2850
double calculate_L2_error()
Calculates the L2 error of the solution.
Definition cls.cc:826
std::shared_ptr< ConservativeLevelSetFilterBase > filter
Definition cls.h:868
void setup_ilu()
Set up the ILU preconditioner stored in ilu_preconditioner.
Definition cls.cc:3038
double compute_capillary_time_step_constraint(const bool pressure_dependent, const bool temperature_dependent)
Computes the capillary time-step constraint.
Definition cls.cc:1188
void write_checkpoint() override
Prepares auxiliary physics to write checkpoint.
Definition cls.cc:2609
const double phase_upper_bound
Definition cls.h:842
~ConservativeLevelSet()=default
CLS - Base destructor. At the present moment this is an interface with nothing.
void sharpen_interface(GlobalVectorType &solution, const double sharpening_threshold, const bool sharpen_previous_solutions)
Carries out interface sharpening. It is called in the modify solution function.
Definition cls.cc:2258
GlobalVectorType complete_system_rhs_phase_indicator
Definition cls.h:826
double volume_monitored
Definition cls.h:847
GlobalVectorType level_set
Definition cls.h:812
std::shared_ptr< FiniteElement< dim > > fe
Definition cls.h:787
void assemble_system_matrix_cg()
Assemble the matrix associated with the solver when CG elements are used.
Definition cls.cc:246
AffineConstraints< double > zero_constraints
Definition cls.h:806
void compute_phase_indicator_from_level_set(const GlobalVectorType &level_set_solution, GlobalVectorType &phase_indicator_solution)
Compute the phase indicator field from level-set field using a tanh-based transformation.
Definition cls.cc:3601
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
Definition cls.h:818
AffineConstraints< double > nonzero_constraints
Definition cls.h:804
std::shared_ptr< SignedDistanceTransformationBase > signed_distance_transformation
Definition cls.h:876
GlobalVectorType system_rhs
Definition cls.h:803
const GlobalVectorType & get_curvature_solution()
Definition cls.h:406
AffineConstraints< double > & get_nonzero_constraints() override
Definition cls.h:379
virtual void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, CLSScratchData< dim > &scratch_data, StabilizedMethodsCopyData &copy_data)
Assemble the local matrix for a given cell.
Definition cls.cc:378
void set_initial_conditions() override
Sets-up the initial conditions associated with the physics. Generally, physics only support imposing ...
Definition cls.cc:2931
TrilinosWrappers::SparseMatrix mass_matrix_phase_indicator
Definition cls.h:827
GlobalVectorType & get_present_solution() override
Definition cls.h:367
void solve_linear_system() override
Call for the solution of the linear system of equation using a strategy appropriate to the auxiliary ...
Definition cls.cc:3127
void reinitialize_interface_with_geometric_method()
Reinitialize the interface between fluids using the geometric approach.
Definition cls.cc:3622
const DoFHandler< dim > & get_dof_handler() override
Getter methods to get the private attributes for the physic currently solved NB : dof_handler and pre...
Definition cls.h:343
double calculate_mass_deviation(const Parameters::FluidIndicator monitored_fluid, const double sharpening_threshold)
Calculate the mass deviation of the monitored fluid, between the current iteration and the mass at fi...
Definition cls.cc:2233
const DoFHandler< dim > & get_projected_phase_indicator_gradient_dof_handler()
Definition cls.h:385
TrilinosWrappers::SparseMatrix complete_system_matrix_phase_indicator
Definition cls.h:824
TimerOutput computing_timer
Definition cls.h:779
IndexSet locally_owned_dofs
Definition cls.h:796
void define_non_zero_constraints()
defined the non zero constraints used to solve the problem.
Definition cls.cc:2889
void calculate_volume_and_mass(const GlobalVectorType &solution, const VectorType &current_solution_fd, const Parameters::FluidIndicator monitored_fluid)
Calculates the volume and mass for a given fluid phase. Used for conservation monitoring.
Definition cls.cc:980
void assemble_system_matrix() override
Assembles the matrix associated with the solver.
Definition cls.cc:231
std::vector< SolutionTransfer< dim, GlobalVectorType > > previous_solutions_transfer
Definition cls.h:820
virtual void setup_assemblers()
sets up the vector of assembler functions
Definition cls.cc:188
Tensor< 1, dim > calculate_momentum(const GlobalVectorType &solution, const VectorType &current_solution_fd, const Parameters::FluidIndicator monitored_fluid)
Calculates the momentum for a given fluid phase. Used for conservation monitoring.
Definition cls.cc:1084
void verify_consistency_of_boundary_conditions()
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary ...
Definition cls.h:447
void output_per_iteration_timer() override
Output the per iteration wallclock times.
Definition cls.cc:1996
std::shared_ptr< InterfaceTools::SignedDistanceSolver< dim, GlobalVectorType > > signed_distance_solver
Definition cls.h:872
void post_mesh_adaptation() override
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
Definition cls.cc:2481
void handle_interface_sharpening()
Carries out interface sharpening. It is called in the modify solution function. Launches sharpen_inte...
Definition cls.cc:2064
void apply_phase_filter(const GlobalVectorType &original_solution, GlobalVectorType &filtered_solution)
Apply filter on phase indicator values.
Definition cls.cc:3482
GlobalVectorType evaluation_point
Definition cls.h:799
void setup_dofs() override
Sets-up the DofHandler and the degree of freedom associated with the physics.
Definition cls.cc:2691
void read_checkpoint() override
Set solution vector of Auxiliary Physics using checkpoint.
Definition cls.cc:2634
void assemble_rhs()
Call for the assembly of the right-hand side.
Definition cls.cc:180
std::pair< Tensor< 1, dim >, Tensor< 1, dim > > calculate_barycenter(const GlobalVectorType &solution, const VectorType &current_solution_fd)
Calculates the barycenter of the fluid and its velocity.
Definition cls.cc:872
GlobalVectorType & get_newton_update() override
Definition cls.h:361
void assemble_L2_projection_interface_sharpening(GlobalVectorType &solution, const double sharpening_threshold)
Assemble the system for interface sharpening.
Definition cls.cc:3286
virtual std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Gather and return vector of output structs that are particular to some applications.
Definition cls.cc:724
std::shared_ptr< Mapping< dim > > mapping
Definition cls.h:791
const GlobalVectorType & get_projected_phase_indicator_gradient_solution()
Definition cls.h:399
IndexSet locally_relevant_dofs
Definition cls.h:797
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
Definition cls.h:833
double mass_first_iteration
Definition cls.h:849
void reinitialize_interface_with_pde_based_method()
Reinitialize the interface between fluids using the PDE-based approach.
Definition cls.cc:3518
std::shared_ptr< TrilinosWrappers::PreconditionAMG > amg_preconditioner
AMG preconditioner used by the iterative linear solver of the main conservative level set system.
Definition cls.h:839
std::vector< TableHandler > phase_indicator_isocontour_bounding_values_tables
Vector of tables containing evolution of phase indicator isocontour bounding values.
Definition cls.h:859
std::shared_ptr< GlobalVectorType > present_solution
Definition cls.h:802
AffineConstraints< double > bounding_constraints
Definition cls.h:805
void reinit_face_velocity_with_adequate_solution(const typename DoFHandler< dim >::active_cell_iterator &velocity_cell, const unsigned int &face_no, CLSScratchData< dim > &scratch_data)
Helper function to reinit the face velocity with the adequate solution. This prevents code duplicatio...
Definition cls.h:751
void assemble_system_rhs_dg()
Assemble the rhs associated with the solver when DG elements are used.
Definition cls.cc:524
const DoFHandler< dim > & get_curvature_dof_handler()
Definition cls.h:392
GlobalVectorType & get_local_evaluation_point() override
Definition cls.h:355
std::shared_ptr< Quadrature< dim > > cell_quadrature
Definition cls.h:792
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Definition copy_data.h:67
DeclExceptionMsg(UnsupportedReinitialization, "The CLS physics has been set to use DG and the latter implementation currently does not support any interface reinitialization mechanism.")
DeclException1(InvalidNumberOfFluid, int,<< "The CLS physics is enabled, but the number of fluids is set to "<< arg1<< ". The CLS solver only supports 2 fluids.")
@ curvature_projection
CLS curvature L2 projection.
@ phase_gradient_projection
CLS phase indicator gradient L2 projection.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ CLS
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