Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
cls.cc
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#include <solvers/cls.h>
5
6#include <deal.II/dofs/dof_renumbering.h>
7
8#include <deal.II/fe/fe_simplex_p.h>
9
10#include <deal.II/lac/solver_control.h>
11#include <deal.II/lac/sparsity_tools.h>
12#include <deal.II/lac/trilinos_solver.h>
13
14#include <deal.II/meshworker/mesh_loop.h>
15
16#include <deal.II/numerics/error_estimator.h>
17#include <deal.II/numerics/vector_tools.h>
18
19#include <sys/stat.h>
20
21#include <cmath>
22
23template <int dim>
25 MultiphysicsInterface<dim> *multiphysics_interface,
26 const SimulationParameters<dim> &p_simulation_parameters,
27 const std::shared_ptr<parallel::DistributedTriangulationBase<dim>>
28 &p_triangulation,
29 std::shared_ptr<SimulationControl> p_simulation_control)
31 p_simulation_parameters.physics_solving_strategy.at(PhysicsID::CLS))
32 , multiphysics(multiphysics_interface)
33 , computing_timer(p_triangulation->get_mpi_communicator(),
34 this->pcout,
35 TimerOutput::never,
36 TimerOutput::wall_times)
37 , simulation_parameters(p_simulation_parameters)
38 , triangulation(p_triangulation)
39 , simulation_control(std::move(p_simulation_control))
40 , dof_handler(std::make_shared<DoFHandler<dim>>(*triangulation))
42 .reinitialization_method.sharpening.threshold)
44 p_simulation_parameters.post_processing.isocontour_bounding_boxes
45 .ids_and_isocontours_per_variable.count(Variable::phase))
46{
47 this->pcout << std::setprecision(simulation_control->get_log_precision())
48 << std::scientific;
49
50 AssertThrow(
51 simulation_parameters.physical_properties_manager.get_number_of_fluids() ==
52 2,
53 InvalidNumberOfFluid(simulation_parameters.physical_properties_manager
54 .get_number_of_fluids()));
55
56 AssertThrow(((simulation_parameters.fem_parameters.CLS_uses_dg &&
57 simulation_parameters.multiphysics.cls_parameters
58 .reinitialization_method.reinitialization_method_type ==
60 !simulation_parameters.fem_parameters.CLS_uses_dg),
61 UnsupportedReinitialization());
62
63 AssertThrow(((simulation_parameters.mesh.simplex &&
64 simulation_parameters.multiphysics.cls_parameters
65 .reinitialization_method.reinitialization_method_type !=
67 !simulation_parameters.mesh.simplex),
68 UnsupportedReinitializationWithSimplex());
69
70 if (simulation_parameters.fem_parameters.CLS_uses_dg &&
71 this->simulation_parameters.post_processing.calculate_mass_conservation)
72 {
73 this->pcout
74 << "Warning: DG-CLS and the geometric surface and volume computations are not compatible. Only the global volume will be monitored."
75 << std::endl;
76 }
77
78 if (simulation_parameters.mesh.simplex)
79 {
80 // for simplex meshes
81 fe = std::make_shared<FE_SimplexP<dim>>(
82 simulation_parameters.fem_parameters.CLS_degree);
83 mapping = std::make_shared<MappingFE<dim>>(*fe);
84 cell_quadrature = std::make_shared<QGaussSimplex<dim>>(fe->degree + 1);
86 std::make_shared<QGaussSimplex<dim - 1>>(fe->degree + 1);
87 }
88 else
89 {
90 // Usual case, for quad/hex meshes
91 if (simulation_parameters.fem_parameters.CLS_uses_dg)
92 {
93 fe = std::make_shared<FE_DGQ<dim>>(
94 simulation_parameters.fem_parameters.CLS_degree);
95 }
96 else
97 {
98 fe = std::make_shared<FE_Q<dim>>(
99 simulation_parameters.fem_parameters.CLS_degree);
100 }
101 // Mapping has to be at least Q1, but DGQ0 is allowed
102 mapping = std::make_shared<MappingQ<dim>>(std::max(fe->degree, uint(1)));
103 cell_quadrature = std::make_shared<QGauss<dim>>(fe->degree + 1);
104 face_quadrature = std::make_shared<QGauss<dim - 1>>(fe->degree + 1);
105 }
106
107 // Initialize solution shared_ptr
108 present_solution = std::make_shared<GlobalVectorType>();
109
110 // Allocate solution transfer
112 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
113
114 // Initialize and set size of previous solutions using BDF schemes information
115 previous_solutions = std::make_shared<std::vector<GlobalVectorType>>(
117
118 // Prepare previous solutions transfer
120 for (unsigned int i = 0; i < previous_solutions->size(); ++i)
121 {
122 previous_solutions_transfer.emplace_back(
123 SolutionTransfer<dim, GlobalVectorType>(*this->dof_handler));
124 }
125
126 // Initialize filtered solution shared_ptr
127 filtered_solution = std::make_shared<GlobalVectorType>();
128
129 // Check the value of interface sharpness
130 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
131 .sharpening.interface_sharpness < 1.0)
132 this->pcout
133 << "Warning: interface sharpness values smaller than 1 smooth the interface instead of sharpening it."
134 << std::endl
135 << "The interface sharpness value should be set between 1 and 2"
136 << std::endl;
137
138
139 // Initialize the interface object for subequations to solve
141 std::make_shared<CLSSubequationsInterface<dim>>(this->simulation_parameters,
142 this->pcout,
143 this->triangulation,
144 this->simulation_control);
145
146
147 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
148 .geometric_interface_reinitialization.enable ||
149 simulation_parameters.initial_condition
150 ->cls_initial_condition_smoothing ==
152 {
153 /* For the CLS solver, the interface is defined as the iso-contour
154 \f$\phi\f = 0.5$. Hence, for the SignedDistanceSolver, we set the
155 iso-level to 0.5. We also define the inside part of the domain as
156 \f$\phi>0.5\f$. Since the SignedDistanceSolver considers the inside
157 of the domain as \f$d<0\f$, we scale the phase indicator with a factor
158 of -1.*/
159 this->signed_distance_solver = std::make_shared<
162 fe,
163 simulation_parameters.multiphysics.cls_parameters
164 .reinitialization_method.geometric_interface_reinitialization
165 .max_reinitialization_distance,
166 0.5,
167 -1.0,
168 simulation_parameters.multiphysics.cls_parameters
169 .reinitialization_method.verbosity);
172 simulation_parameters.multiphysics.cls_parameters
173 .reinitialization_method.geometric_interface_reinitialization);
174 }
175}
176
177
178template <int dim>
179void
184
185
186template <int dim>
187void
189{
190 AssertThrow(time_stepping_is_sdirk(
191 this->simulation_control->get_assembly_method()) == false,
192 ExcMessage(
193 "The SDIRK scheme is not yet supported for this physics"));
194
195 this->assemblers.clear();
196
197 // Time-stepping schemes
198 if (time_stepping_is_bdf(this->simulation_control->get_assembly_method()))
199 {
200 this->assemblers.emplace_back(
201 std::make_shared<CLSAssemblerBDF<dim>>(this->simulation_control));
202 }
203
204 // If the CLS solver uses DG, a different set of assemblers is used
205 if (simulation_parameters.fem_parameters.CLS_uses_dg)
206 {
207 this->assemblers.emplace_back(
208 std::make_shared<CLSAssemblerDGCore<dim>>());
209 this->inner_face_assembler = std::make_shared<CLSAssemblerSIPG<dim>>();
210 }
211 else
212 {
213 // Core assembler
214 this->assemblers.emplace_back(std::make_shared<CLSAssemblerCore<dim>>(
215 this->simulation_control,
216 this->simulation_parameters.fem_parameters,
217 this->simulation_parameters.multiphysics.cls_parameters));
218
219 // DCDD shock-capturing assembler
220 if (this->simulation_parameters.stabilization.cls_dcdd_stabilization)
221 this->assemblers.emplace_back(
222 std::make_shared<CLSAssemblerDCDDStabilization<dim>>(
223 this->simulation_control,
224 this->simulation_parameters.stabilization));
225 }
226}
227
228
229template <int dim>
230void
232{
233 TimerOutput::Scope t(this->computing_timer, "Assemble matrix");
234
235 this->system_matrix = 0;
237
238 if (simulation_parameters.fem_parameters.CLS_uses_dg)
240 else
242}
243
244template <int dim>
245void
247{
248 const DoFHandler<dim> &dof_handler_fd =
249 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
250
251 auto scratch_data =
253 this->simulation_parameters.physical_properties_manager,
254 *this->fe,
255 *this->cell_quadrature,
256 *this->face_quadrature,
257 *this->mapping,
258 dof_handler_fd.get_fe());
259
260 WorkStream::run(this->dof_handler->begin_active(),
261 this->dof_handler->end(),
262 *this,
265 scratch_data,
266 StabilizedMethodsCopyData(this->fe->n_dofs_per_cell(),
267 this->cell_quadrature->size()));
268
269 this->system_matrix.compress(VectorOperation::add);
270}
271
272
273template <int dim>
274void
276{
277 const DoFHandler<dim> &dof_handler_fluid =
278 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
279
280 auto scratch_data =
282 this->simulation_parameters.physical_properties_manager,
283 *this->fe,
284 *this->cell_quadrature,
285 *this->face_quadrature,
286 *this->mapping,
287 dof_handler_fluid.get_fe());
288
289 StabilizedDGMethodsCopyData copy_data(this->fe->n_dofs_per_cell(),
290 this->cell_quadrature->size());
291
292 // We first wrap the assembly of the matrix within a cell_worker lambda
293 // function. This is only done for compatibility reasons with the MeshWorker
294 // paradigm and does not have any functional purpose.
295 const auto cell_worker =
296 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
297 CLSScratchData<dim> &scratch_data,
298 StabilizedDGMethodsCopyData &copy_data) {
299 this->assemble_local_system_matrix(cell, scratch_data, copy_data);
300 };
301
302 const auto boundary_worker =
303 [&]([[maybe_unused]] const typename DoFHandler<dim>::active_cell_iterator
304 &cell,
305 [[maybe_unused]] const unsigned int &face_no,
306 [[maybe_unused]] CLSScratchData<dim> &scratch_data,
307 [[maybe_unused]] StabilizedDGMethodsCopyData &copy_data) {};
308
309 const auto face_worker =
310 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
311 const unsigned int &face_no,
312 const unsigned int &sub_face_no,
313 const typename DoFHandler<dim>::active_cell_iterator &neigh_cell,
314 const unsigned int &neigh_face_no,
315 const unsigned int &neigh_sub_face_no,
316 CLSScratchData<dim> &scratch_data,
317 StabilizedDGMethodsCopyData &copy_data) {
318 scratch_data.reinit_internal_face(cell,
319 face_no,
320 sub_face_no,
321 neigh_cell,
322 neigh_face_no,
323 neigh_sub_face_no,
324 this->evaluation_point);
325
326 // Pad copy_data memory for the internal faces elementary matrices
327 // BB note : Array could be pre-allocated
328 copy_data.face_data.emplace_back();
329 auto &copy_data_face = copy_data.face_data.back();
330 copy_data_face.face_matrix.reinit(scratch_data.n_interface_dofs,
331 scratch_data.n_interface_dofs);
332 copy_data_face.joint_dof_indices =
333 scratch_data.fe_interface_values_cls.get_interface_dof_indices();
334
335 // Gather velocity information at the face to advect properly
336 // Get the cell that corresponds to the fluid dynamics
337 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
338 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
339
340 // Reinit the internal face velocity within the scratch data
342 face_no,
343 scratch_data);
344
345 this->inner_face_assembler->assemble_matrix(scratch_data, copy_data);
346 };
347
348 const auto copier = [&](const StabilizedDGMethodsCopyData &copy_data) {
349 this->copy_local_matrix_to_global_matrix(copy_data);
350
351 const AffineConstraints<double> &constraints_used = this->zero_constraints;
352
353 for (const auto &cdf : copy_data.face_data)
354 {
355 constraints_used.distribute_local_to_global(cdf.face_matrix,
356 cdf.joint_dof_indices,
358 }
359 };
360
361 MeshWorker::mesh_loop(this->dof_handler->begin_active(),
362 this->dof_handler->end(),
363 cell_worker,
364 copier,
365 scratch_data,
366 copy_data,
367 MeshWorker::assemble_own_cells |
368 MeshWorker::assemble_boundary_faces |
369 MeshWorker::assemble_own_interior_faces_once |
370 MeshWorker::assemble_ghost_faces_both,
371 boundary_worker,
372 face_worker);
373}
374
375
376template <int dim>
377void
379 const typename DoFHandler<dim>::active_cell_iterator &cell,
380 CLSScratchData<dim> &scratch_data,
381 StabilizedMethodsCopyData &copy_data)
382{
383 copy_data.cell_is_local = cell->is_locally_owned();
384 if (!cell->is_locally_owned())
385 return;
386
387 scratch_data.reinit(cell, this->evaluation_point, *this->previous_solutions);
388
389 const DoFHandler<dim> &dof_handler_fd =
390 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
391
392 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
393 &(*this->triangulation), cell->level(), cell->index(), &dof_handler_fd);
394
395 if (multiphysics->fluid_dynamics_is_block())
396 {
397 // Check if the post processed variable needs to be calculated with the
398 // average velocity profile or the fluid solution.
399 if (this->simulation_parameters.initial_condition->type ==
401 average_velocity_profile &&
402 !this->simulation_parameters.multiphysics.fluid_dynamics &&
403 simulation_control->get_current_time() >
404 this->simulation_parameters.post_processing
405 .initial_time_for_average_velocities)
406 {
407 scratch_data.reinit_velocity(
408 velocity_cell,
409 multiphysics->get_block_time_average_solution(
411 multiphysics->get_block_previous_solutions(
413 this->simulation_parameters.ale);
414 }
415 else
416 {
417 scratch_data.reinit_velocity(
418 velocity_cell,
419 multiphysics->get_block_solution(PhysicsID::fluid_dynamics),
420 multiphysics->get_block_previous_solutions(
422 this->simulation_parameters.ale);
423 }
424 }
425 else
426 {
427 // Check if the post-processed variable needs to be calculated with the
428 // average velocity profile or the fluid solution.
429 if (this->simulation_parameters.initial_condition->type ==
431 average_velocity_profile &&
432 !this->simulation_parameters.multiphysics.fluid_dynamics &&
433 simulation_control->get_current_time() >
434 this->simulation_parameters.post_processing
435 .initial_time_for_average_velocities)
436 {
437 scratch_data.reinit_velocity(
438 velocity_cell,
439 multiphysics->get_time_average_solution(PhysicsID::fluid_dynamics),
440 multiphysics->get_previous_solutions(PhysicsID::fluid_dynamics),
441 this->simulation_parameters.ale);
442 }
443 else
444 {
445 scratch_data.reinit_velocity(
446 velocity_cell,
448 multiphysics->get_previous_solutions(PhysicsID::fluid_dynamics),
449 this->simulation_parameters.ale);
450 }
451 }
452
453 copy_data.reset();
454
455 for (auto &assembler : this->assemblers)
456 {
457 assembler->assemble_matrix(scratch_data, copy_data);
458 }
459
460 cell->get_dof_indices(copy_data.local_dof_indices);
461}
462
463template <int dim>
464void
466 const StabilizedMethodsCopyData &copy_data)
467{
468 if (!copy_data.cell_is_local)
469 return;
470
471 const AffineConstraints<double> &constraints_used = this->zero_constraints;
472 constraints_used.distribute_local_to_global(copy_data.local_matrix,
473 copy_data.local_dof_indices,
474 this->system_matrix);
475}
476
477template <int dim>
478void
480{
481 TimerOutput::Scope t(this->computing_timer, "Assemble RHS");
482
483 this->system_rhs = 0;
485
486 if (simulation_parameters.fem_parameters.CLS_uses_dg)
488
489 else
491}
492
493
494template <int dim>
495void
497{
498 const DoFHandler<dim> &dof_handler_fd =
499 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
500
501 auto scratch_data =
503 this->simulation_parameters.physical_properties_manager,
504 *this->fe,
505 *this->cell_quadrature,
506 *this->face_quadrature,
507 *this->mapping,
508 dof_handler_fd.get_fe());
509
510 WorkStream::run(this->dof_handler->begin_active(),
511 this->dof_handler->end(),
512 *this,
515 scratch_data,
516 StabilizedMethodsCopyData(this->fe->n_dofs_per_cell(),
517 this->cell_quadrature->size()));
518
519 this->system_rhs.compress(VectorOperation::add);
520}
521
522template <int dim>
523void
525{
526 const DoFHandler<dim> &dof_handler_fluid =
527 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
528
529 auto scratch_data =
531 this->simulation_parameters.physical_properties_manager,
532 *this->fe,
533 *this->cell_quadrature,
534 *this->face_quadrature,
535 *this->mapping,
536 dof_handler_fluid.get_fe());
537
538 StabilizedDGMethodsCopyData copy_data(this->fe->n_dofs_per_cell(),
539 this->cell_quadrature->size());
540
541 const auto cell_worker =
542 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
543 CLSScratchData<dim> &scratch_data,
544 StabilizedDGMethodsCopyData &copy_data) {
545 this->assemble_local_system_rhs(cell, scratch_data, copy_data);
546 };
547
548 const auto boundary_worker =
549 [&]([[maybe_unused]] const typename DoFHandler<dim>::active_cell_iterator
550 &cell,
551 [[maybe_unused]] const unsigned int &face_no,
552 [[maybe_unused]] CLSScratchData<dim> &scratch_data,
553 [[maybe_unused]] StabilizedDGMethodsCopyData &copy_data) {};
554
555 const auto face_worker =
556 [&](const typename DoFHandler<dim>::active_cell_iterator &cell,
557 const unsigned int &face_no,
558 const unsigned int &sub_face_no,
559 const typename DoFHandler<dim>::active_cell_iterator &neigh_cell,
560 const unsigned int &neigh_face_no,
561 const unsigned int &neigh_sub_face_no,
562 CLSScratchData<dim> &scratch_data,
564
565 {
566 scratch_data.reinit_internal_face(cell,
567 face_no,
568 sub_face_no,
569 neigh_cell,
570 neigh_face_no,
571 neigh_sub_face_no,
572 this->evaluation_point);
573
574 copy_data.face_data.emplace_back();
575 auto &copy_data_face = copy_data.face_data.back();
576 copy_data_face.joint_dof_indices =
577 scratch_data.fe_interface_values_cls.get_interface_dof_indices();
578 copy_data_face.face_rhs.reinit(scratch_data.n_interface_dofs);
579
580 // Gather velocity information at the face to advect properly.
581 // First gather the dof handler for the fluid dynamics.
582 const DoFHandler<dim> &dof_handler_fluid =
583 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
584 // Get the cell that corresponds to the fluid dynamics
585 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
586 &(*triangulation), cell->level(), cell->index(), &dof_handler_fluid);
587
589 face_no,
590 scratch_data);
591
592 this->inner_face_assembler->assemble_rhs(scratch_data, copy_data);
593 };
594
595
596 const auto copier = [&](const StabilizedDGMethodsCopyData &c) {
598 const AffineConstraints<double> &constraints_used = this->zero_constraints;
599 for (const auto &cdf : c.face_data)
600 {
601 constraints_used.distribute_local_to_global(cdf.face_rhs,
602 cdf.joint_dof_indices,
603 system_rhs);
604 }
605 };
606
607 MeshWorker::mesh_loop(this->dof_handler->begin_active(),
608 this->dof_handler->end(),
609 cell_worker,
610 copier,
611 scratch_data,
612 copy_data,
613 MeshWorker::assemble_own_cells |
614 MeshWorker::assemble_boundary_faces |
615 MeshWorker::assemble_own_interior_faces_once |
616 MeshWorker::assemble_ghost_faces_both,
617 boundary_worker,
618 face_worker);
619}
620
621template <int dim>
622void
624 const typename DoFHandler<dim>::active_cell_iterator &cell,
625 CLSScratchData<dim> &scratch_data,
626 StabilizedMethodsCopyData &copy_data)
627{
628 copy_data.cell_is_local = cell->is_locally_owned();
629 if (!cell->is_locally_owned())
630 return;
631
632 scratch_data.reinit(cell, this->evaluation_point, *this->previous_solutions);
633
634 const DoFHandler<dim> &dof_handler_fd =
635 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
636
637 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
638 &(*this->triangulation), cell->level(), cell->index(), &dof_handler_fd);
639
640 if (multiphysics->fluid_dynamics_is_block())
641 {
642 // Check if the post-processed variable needs to be calculated with the
643 // average velocity profile or the fluid solution.
644 if (this->simulation_parameters.initial_condition->type ==
646 average_velocity_profile &&
647 !this->simulation_parameters.multiphysics.fluid_dynamics &&
648 simulation_control->get_current_time() >
649 this->simulation_parameters.post_processing
650 .initial_time_for_average_velocities)
651 {
652 scratch_data.reinit_velocity(
653 velocity_cell,
654 multiphysics->get_block_time_average_solution(
656 multiphysics->get_block_previous_solutions(
658 this->simulation_parameters.ale);
659 }
660 else
661 {
662 scratch_data.reinit_velocity(
663 velocity_cell,
664 multiphysics->get_block_solution(PhysicsID::fluid_dynamics),
665 multiphysics->get_block_previous_solutions(
667 this->simulation_parameters.ale);
668 }
669 }
670 else
671 {
672 // Check if the post-processed variable needs to be calculated with the
673 // average velocity profile or the fluid solution.
674 if (this->simulation_parameters.initial_condition->type ==
676 average_velocity_profile &&
677 !this->simulation_parameters.multiphysics.fluid_dynamics &&
678 simulation_control->get_current_time() >
679 this->simulation_parameters.post_processing
680 .initial_time_for_average_velocities)
681 {
682 scratch_data.reinit_velocity(
683 velocity_cell,
684 multiphysics->get_time_average_solution(PhysicsID::fluid_dynamics),
685 multiphysics->get_previous_solutions(PhysicsID::fluid_dynamics),
686 this->simulation_parameters.ale);
687 }
688 else
689 {
690 scratch_data.reinit_velocity(
691 velocity_cell,
693 multiphysics->get_previous_solutions(PhysicsID::fluid_dynamics),
694 this->simulation_parameters.ale);
695 }
696 }
697
698 copy_data.reset();
699
700 for (auto &assembler : this->assemblers)
701 {
702 assembler->assemble_rhs(scratch_data, copy_data);
703 }
704
705 cell->get_dof_indices(copy_data.local_dof_indices);
706}
707
708template <int dim>
709void
711 const StabilizedMethodsCopyData &copy_data)
712{
713 if (!copy_data.cell_is_local)
714 return;
715
716 const AffineConstraints<double> &constraints_used = this->zero_constraints;
717 constraints_used.distribute_local_to_global(copy_data.local_rhs,
718 copy_data.local_dof_indices,
719 this->system_rhs);
720}
721
722template <int dim>
723std::vector<OutputStruct<dim, GlobalVectorType>>
725{
726 std::vector<OutputStruct<dim, GlobalVectorType>> solution_output_structs;
727 std::vector<std::string> solution_names(1, "phase");
728 std::vector<DataComponentInterpretation::DataComponentInterpretation>
729 solution_component_interpretation(
730 1, DataComponentInterpretation::component_is_scalar);
731
732 // Phase indicator
733 solution_output_structs.emplace_back(
735 *this->dof_handler,
736 *this->present_solution,
737 solution_names,
738 solution_component_interpretation);
739
740 // Filter phase indicator
741 std::vector<std::string> filtered_solution_names(1, "filtered_phase");
742 std::vector<DataComponentInterpretation::DataComponentInterpretation>
743 filtered_solution_component_interpretation(
744 1, DataComponentInterpretation::component_is_scalar);
745 solution_output_structs.emplace_back(
747 *this->dof_handler,
748 *this->filtered_solution,
749 filtered_solution_names,
750 filtered_solution_component_interpretation);
751
752 auto cls_parameters = this->simulation_parameters.multiphysics.cls_parameters;
753
754 if ((cls_parameters.surface_tension_force.enable &&
755 cls_parameters.surface_tension_force.output_cls_auxiliary_fields) ||
756 cls_parameters.reinitialization_method
757 .pde_based_interface_reinitialization.enable)
758 {
759 std::vector<DataComponentInterpretation::DataComponentInterpretation>
760 projected_phase_indicator_gradient_component_interpretation(
761 dim, DataComponentInterpretation::component_is_scalar);
762 for (int i = 0; i < dim; ++i)
763 projected_phase_indicator_gradient_component_interpretation[i] =
764 DataComponentInterpretation::component_is_part_of_vector;
765
766 std::vector<std::string> phase_gradient_projection_name(
767 dim, "phase_indicator_gradient");
768 solution_output_structs.emplace_back(
770 this->cls_subequations_interface->get_dof_handler(
772 this->cls_subequations_interface->get_solution(
774 phase_gradient_projection_name,
775 projected_phase_indicator_gradient_component_interpretation);
776
777 if (cls_parameters.surface_tension_force.enable &&
778 cls_parameters.surface_tension_force.output_cls_auxiliary_fields)
779 {
780 solution_output_structs.emplace_back(
782 this->cls_subequations_interface->get_dof_handler(
784 this->cls_subequations_interface->get_solution(
786 std::vector<std::string>(1, "curvature"),
787 std::vector<
788 DataComponentInterpretation::DataComponentInterpretation>(
789 1, DataComponentInterpretation::component_is_scalar));
790 }
791 }
792
793 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
794 .geometric_interface_reinitialization.enable)
795 {
796 if ((simulation_control->get_iteration_number() %
797 simulation_parameters.multiphysics.cls_parameters
798 .reinitialization_method.frequency !=
799 0) ||
800 (simulation_control->get_iteration_number() == 0))
801 {
802 TimerOutput::Scope t(this->computing_timer, "Signed distance output");
803
804 signed_distance_solver->setup_dofs();
805
806 signed_distance_solver->set_level_set_from_background_mesh(
808
809 signed_distance_solver->solve();
810 }
811 for (auto &output_struct : signed_distance_solver->gather_output_hook())
812 solution_output_structs.push_back(output_struct);
813
814 signed_distance_solver->output_interface_reconstruction(
815 "interface_reconstruction_" +
816 this->simulation_parameters.simulation_control.output_name,
817 this->simulation_parameters.simulation_control.output_folder,
818 simulation_control->get_current_time(),
819 simulation_control->get_iteration_number());
820 }
821 return solution_output_structs;
822}
823
824template <int dim>
825double
827{
828 auto mpi_communicator = this->triangulation->get_mpi_communicator();
829
830 FEValues<dim> fe_values_cls(*this->mapping,
831 *this->fe,
832 *this->cell_quadrature,
833 update_values | update_quadrature_points |
834 update_JxW_values);
835
836 const unsigned int n_q_points = this->cell_quadrature->size();
837 std::vector<double> phase_exact_solution(n_q_points);
838 std::vector<double> phase_values(n_q_points);
839
840 auto &exact_solution = simulation_parameters.analytical_solution->phase;
841 exact_solution.set_time(this->simulation_control->get_current_time());
842
843 double l2error = 0.;
844
845 for (const auto &cell : this->dof_handler->active_cell_iterators())
846 {
847 if (cell->is_locally_owned())
848 {
849 fe_values_cls.reinit(cell);
850 fe_values_cls.get_function_values(*this->present_solution,
851 phase_values);
852
853 // Get the exact solution at all gauss points
854 exact_solution.value_list(fe_values_cls.get_quadrature_points(),
855 phase_exact_solution);
856
857 for (unsigned int q = 0; q < n_q_points; q++)
858 {
859 double sim = phase_values[q];
860 double exact = phase_exact_solution[q];
861 l2error += (sim - exact) * (sim - exact) * fe_values_cls.JxW(q);
862 }
863 }
864 }
865 l2error = Utilities::MPI::sum(l2error, mpi_communicator);
866 return l2error;
867}
868
869template <int dim>
870template <typename VectorType>
871std::pair<Tensor<1, dim>, Tensor<1, dim>>
873 const GlobalVectorType &solution,
874 const VectorType &solution_fd)
875{
876 const MPI_Comm mpi_communicator = this->triangulation->get_mpi_communicator();
877
878 FEValues<dim> fe_values_cls(*this->mapping,
879 *this->fe,
880 *this->cell_quadrature,
881 update_values | update_quadrature_points |
882 update_JxW_values);
883
884 std::shared_ptr<ConservativeLevelSetFilterBase> filter =
886 this->simulation_parameters.multiphysics.cls_parameters.phase_filter);
887
888 const DoFHandler<dim> &dof_handler_fd =
889 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
890
891 FEValues<dim> fe_values_fd(*this->mapping,
892 dof_handler_fd.get_fe(),
893 *this->cell_quadrature,
894 update_values);
895
896 const unsigned int n_q_points = this->cell_quadrature->size();
897 std::vector<double> phase_values(n_q_points);
898 std::vector<Tensor<1, dim>> velocity_values(n_q_points);
899 std::vector<Point<dim>> quadrature_locations(n_q_points);
900
901 const FEValuesExtractors::Vector velocity(0);
902
903 Tensor<1, dim> barycenter_location;
904 Tensor<1, dim> barycenter_velocity;
905 double volume = 0;
906
907
908 std::map<field, std::vector<double>> fields;
909
910 for (const auto &cell : this->dof_handler->active_cell_iterators())
911 {
912 if (cell->is_locally_owned())
913 {
914 fe_values_cls.reinit(cell);
915 quadrature_locations = fe_values_cls.get_quadrature_points();
916 fe_values_cls.get_function_values(solution, phase_values);
917
918 // Get fluid dynamics active cell iterator
919 typename DoFHandler<dim>::active_cell_iterator cell_fd(
920 &(*(this->triangulation)),
921 cell->level(),
922 cell->index(),
923 &dof_handler_fd);
924
925 fe_values_fd.reinit(cell_fd);
926 fe_values_fd[velocity].get_function_values(solution_fd,
927 velocity_values);
928
929 for (unsigned int q = 0; q < n_q_points; q++)
930 {
931 const double JxW = fe_values_cls.JxW(q);
932 const double filtered_phase_value =
933 filter->filter_phase(phase_values[q]);
934
935 volume += (filtered_phase_value)*JxW;
936 barycenter_location +=
937 (filtered_phase_value)*quadrature_locations[q] * JxW;
938 barycenter_velocity +=
939 (filtered_phase_value)*velocity_values[q] * JxW;
940 }
941 }
942 }
943
944 volume = Utilities::MPI::sum(volume, mpi_communicator);
945 barycenter_location =
946 Utilities::MPI::sum(barycenter_location, mpi_communicator) / volume;
947 barycenter_velocity =
948 Utilities::MPI::sum(barycenter_velocity, mpi_communicator) / volume;
949
950 return std::pair<Tensor<1, dim>, Tensor<1, dim>>(barycenter_location,
951 barycenter_velocity);
952}
953
954template std::pair<Tensor<1, 2>, Tensor<1, 2>>
956 const GlobalVectorType &solution,
957 const GlobalVectorType &current_solution_fd);
958
959
960template std::pair<Tensor<1, 3>, Tensor<1, 3>>
962 const GlobalVectorType &solution,
963 const GlobalVectorType &current_solution_fd);
964
965template std::pair<Tensor<1, 2>, Tensor<1, 2>>
967 const GlobalVectorType &solution,
968 const GlobalBlockVectorType &current_solution_fd);
969
970
971template std::pair<Tensor<1, 3>, Tensor<1, 3>>
973 const GlobalVectorType &solution,
974 const GlobalBlockVectorType &current_solution_fd);
975
976
977template <int dim>
978template <typename VectorType>
979void
981 const GlobalVectorType &solution,
982 const VectorType &current_solution_fd,
983 const Parameters::FluidIndicator monitored_fluid)
984{
985 const MPI_Comm mpi_communicator = this->triangulation->get_mpi_communicator();
986
987 FEValues<dim> fe_values_cls(*this->mapping,
988 *this->fe,
989 *this->cell_quadrature,
990 update_values | update_JxW_values);
991
992 const DoFHandler<dim> &dof_handler_fd =
993 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
994 QGauss<dim> quadrature_formula(dof_handler_fd.get_fe().degree + 1);
995
996 FEValues<dim> fe_values_fd(*this->mapping,
997 dof_handler_fd.get_fe(),
998 quadrature_formula,
999 update_values);
1000
1001 const FEValuesExtractors::Scalar pressure(dim);
1002
1003 const unsigned int n_q_points = this->cell_quadrature->size();
1004 std::vector<double> phase_values(n_q_points);
1005 std::vector<double> density_0(n_q_points);
1006 std::vector<double> density_1(n_q_points);
1007 std::vector<double> pressure_values(n_q_points);
1008
1009 this->volume_monitored = 0.;
1010 this->mass_monitored = 0.;
1011
1012 // Physical properties
1013 const auto density_models =
1014 this->simulation_parameters.physical_properties_manager
1015 .get_density_vector();
1016 std::map<field, std::vector<double>> fields;
1017 fields.insert(
1018 std::pair<field, std::vector<double>>(field::pressure, n_q_points));
1019
1020 for (const auto &cell_cls : this->dof_handler->active_cell_iterators())
1021 {
1022 if (cell_cls->is_locally_owned())
1023 {
1024 fe_values_cls.reinit(cell_cls);
1025 fe_values_cls.get_function_values(solution, phase_values);
1026
1027 if (this->simulation_parameters.physical_properties_manager
1028 .field_is_required(field::pressure))
1029 {
1030 // Get fluid dynamics active cell iterator
1031 typename DoFHandler<dim>::active_cell_iterator cell_fd(
1032 &(*(this->triangulation)),
1033 cell_cls->level(),
1034 cell_cls->index(),
1035 &dof_handler_fd);
1036
1037 fe_values_fd.reinit(cell_fd);
1038 fe_values_fd[pressure].get_function_values(current_solution_fd,
1039 pressure_values);
1040 set_field_vector(field::pressure, pressure_values, fields);
1041 }
1042 // Calculate physical properties for the cell
1043 density_models[0]->vector_value(fields, density_0);
1044 density_models[1]->vector_value(fields, density_1);
1045
1046 for (unsigned int q = 0; q < n_q_points; q++)
1047 {
1048 switch (monitored_fluid)
1049 {
1051 {
1052 this->volume_monitored +=
1053 fe_values_cls.JxW(q) * (1 - phase_values[q]);
1054 this->mass_monitored += fe_values_cls.JxW(q) *
1055 (1 - phase_values[q]) *
1056 density_0[q];
1057 break;
1058 }
1060 {
1061 this->volume_monitored +=
1062 fe_values_cls.JxW(q) * phase_values[q];
1063 this->mass_monitored +=
1064 fe_values_cls.JxW(q) * phase_values[q] * density_1[q];
1065 break;
1066 }
1067 default:
1068 throw std::runtime_error(
1069 "Unsupported number of fluids (>2)");
1070 }
1071 }
1072 }
1073 }
1074
1075 this->volume_monitored =
1076 Utilities::MPI::sum(this->volume_monitored, mpi_communicator);
1077 this->mass_monitored =
1078 Utilities::MPI::sum(this->mass_monitored, mpi_communicator);
1079}
1080
1081template <int dim>
1082template <typename VectorType>
1083Tensor<1, dim>
1085 const GlobalVectorType &solution,
1086 const VectorType &current_solution_fd,
1087 const Parameters::FluidIndicator monitored_fluid)
1088{
1089 const MPI_Comm mpi_communicator = this->triangulation->get_mpi_communicator();
1090
1091 FEValues<dim> fe_values_cls(*this->mapping,
1092 *this->fe,
1093 *this->cell_quadrature,
1094 update_values | update_JxW_values);
1095
1096 const DoFHandler<dim> &dof_handler_fd =
1097 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
1098
1099 FEValues<dim> fe_values_fd(*this->mapping,
1100 dof_handler_fd.get_fe(),
1101 *this->cell_quadrature,
1102 update_values);
1103
1104 const FEValuesExtractors::Vector velocity(0);
1105 const FEValuesExtractors::Scalar pressure(dim);
1106
1107 const unsigned int n_q_points = this->cell_quadrature->size();
1108 std::vector<double> phase_values(n_q_points);
1109 std::vector<double> density_0(n_q_points);
1110 std::vector<double> density_1(n_q_points);
1111 std::vector<double> pressure_values(n_q_points);
1112 std::vector<Tensor<1, dim>> velocity_values(n_q_points);
1113
1114 Tensor<1, dim> total_momentum;
1115
1116 // Physical properties
1117 const auto density_models =
1118 this->simulation_parameters.physical_properties_manager
1119 .get_density_vector();
1120 std::map<field, std::vector<double>> fields;
1121 fields.insert(
1122 std::pair<field, std::vector<double>>(field::pressure, n_q_points));
1123
1124 for (const auto &cell_cls : this->dof_handler->active_cell_iterators())
1125 {
1126 if (cell_cls->is_locally_owned())
1127 {
1128 fe_values_cls.reinit(cell_cls);
1129 fe_values_cls.get_function_values(solution, phase_values);
1130
1131 // Get fluid dynamics active cell iterator
1132 typename DoFHandler<dim>::active_cell_iterator cell_fd(
1133 &(*(this->triangulation)),
1134 cell_cls->level(),
1135 cell_cls->index(),
1136 &dof_handler_fd);
1137 fe_values_fd.reinit(cell_fd);
1138
1139 fe_values_fd[velocity].get_function_values(current_solution_fd,
1140 velocity_values);
1141
1142 if (this->simulation_parameters.physical_properties_manager
1143 .field_is_required(field::pressure))
1144 {
1145 fe_values_fd[pressure].get_function_values(current_solution_fd,
1146 pressure_values);
1147 set_field_vector(field::pressure, pressure_values, fields);
1148 }
1149
1150
1151
1152 // Calculate physical properties for the cell
1153 density_models[0]->vector_value(fields, density_0);
1154 density_models[1]->vector_value(fields, density_1);
1155
1156 for (unsigned int q = 0; q < n_q_points; q++)
1157 {
1158 switch (monitored_fluid)
1159 {
1161 {
1162 total_momentum += fe_values_cls.JxW(q) *
1163 (1 - phase_values[q]) *
1164 velocity_values[q] * density_0[q];
1165 break;
1166 }
1168 {
1169 total_momentum += fe_values_cls.JxW(q) * phase_values[q] *
1170 velocity_values[q] * density_1[q];
1171 break;
1172 }
1173 default:
1174 throw std::runtime_error(
1175 "Unsupported number of fluids (>2)");
1176 }
1177 }
1178 }
1179 }
1180
1181 total_momentum = Utilities::MPI::sum(total_momentum, mpi_communicator);
1182
1183 return total_momentum;
1184}
1185
1186template <int dim>
1187double
1189 const bool pressure_dependent,
1190 const bool temperature_dependent)
1191{
1192 // Get MPI communicator
1193 auto mpi_communicator = this->triangulation->get_mpi_communicator();
1194
1195 // Initialize CLS FEValues and get number of quadrature points
1196 FEValues<dim> fe_values_cls(*this->mapping,
1197 *this->fe,
1198 *this->cell_quadrature,
1199 update_quadrature_points | update_JxW_values);
1200 const unsigned int n_q_points = this->cell_quadrature->size();
1201
1202 // Initialize DoF handlers for fluid dynamics and heat transfer
1203 const DoFHandler<dim> *dof_handler_fd = nullptr;
1204 const DoFHandler<dim> *dof_handler_ht = nullptr;
1205
1206 // Initialize FEValues fluid dynamics and heat transfer unique_ptr
1207 std::unique_ptr<FEValues<dim>> fe_values_fd;
1208 std::unique_ptr<FEValues<dim>> fe_values_ht;
1209
1210 // Initialize solution vectors for fluid dynamics and heat transfer
1211 const GlobalVectorType *current_solution_fd = nullptr;
1212 const GlobalVectorType *current_solution_ht = nullptr;
1213
1214 // Extractor for the pressure component of the fluid dynamics solution
1215 const FEValuesExtractors::Scalar pressure(dim);
1216
1217 // Initialize local vectors
1218 std::vector<double> density_0(n_q_points);
1219 std::vector<double> density_1(n_q_points);
1220 std::vector<double> pressure_values(n_q_points);
1221 std::vector<double> surface_tension(n_q_points);
1222 std::vector<double> temperature_values(n_q_points);
1223
1224 // Get fluid dynamics DoFHandler for the pressure field if needed
1225 if (pressure_dependent)
1226 {
1227 dof_handler_fd =
1228 &multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
1229 fe_values_fd = std::make_unique<FEValues<dim>>(*this->mapping,
1230 dof_handler_fd->get_fe(),
1231 *this->cell_quadrature,
1232 update_values);
1233 current_solution_fd =
1235 }
1236
1237 // Get heat transfer DoFHandler for the temperature field if required
1238 if (temperature_dependent)
1239 {
1240 dof_handler_ht = &multiphysics->get_dof_handler(PhysicsID::heat_transfer);
1241 fe_values_ht = std::make_unique<FEValues<dim>>(*this->mapping,
1242 dof_handler_ht->get_fe(),
1243 *this->cell_quadrature,
1244 update_values);
1245 current_solution_ht =
1246 &multiphysics->get_solution(PhysicsID::heat_transfer);
1247 }
1248 // Get physical property models and initialize independent fields
1249 std::map<field, std::vector<double>> fields;
1250 const auto density_models =
1251 this->simulation_parameters.physical_properties_manager
1252 .get_density_vector();
1253 std::shared_ptr<SurfaceTensionModel> surface_tension_model =
1254 this->simulation_parameters.physical_properties_manager
1255 .get_surface_tension();
1256 fields.insert(
1257 std::pair<field, std::vector<double>>(field::pressure, n_q_points));
1258 fields.insert(
1259 std::pair<field, std::vector<double>>(field::temperature, n_q_points));
1260
1261 // Initialize capillary time-step constraint
1262 double capillary_time_step_constraint = std::numeric_limits<double>::max();
1263
1264 // Element degree
1265 const unsigned int degree = this->dof_handler->get_fe().degree;
1266
1267 // Loop over active cells
1268 for (const auto &cell_cls : this->dof_handler->active_cell_iterators())
1269 {
1270 if (cell_cls->is_locally_owned())
1271 {
1272 fe_values_cls.reinit(cell_cls);
1273
1274 if (pressure_dependent)
1275 {
1276 // Get fluid dynamics active cell iterator
1277 typename DoFHandler<dim>::active_cell_iterator cell_fd(
1278 &(*(this->triangulation)),
1279 cell_cls->level(),
1280 cell_cls->index(),
1281 dof_handler_fd);
1282
1283 fe_values_fd->reinit(cell_fd);
1284 (*fe_values_fd)[pressure].get_function_values(
1285 *current_solution_fd, pressure_values);
1286 set_field_vector(field::pressure, pressure_values, fields);
1287 }
1288
1289 if (temperature_dependent)
1290 {
1291 // Get heat transfer active cell iterator
1292 typename DoFHandler<dim>::active_cell_iterator cell_ht(
1293 &(*(this->triangulation)),
1294 cell_cls->level(),
1295 cell_cls->index(),
1296 dof_handler_ht);
1297
1298 fe_values_ht->reinit(cell_ht);
1299 fe_values_ht->get_function_values(*current_solution_ht,
1300 temperature_values);
1301 set_field_vector(field::temperature, temperature_values, fields);
1302 }
1303
1304 // Compute physical properties of the cell
1305 density_models[0]->vector_value(fields, density_0);
1306 density_models[1]->vector_value(fields, density_1);
1307 surface_tension_model->vector_value(fields, surface_tension);
1308
1309 // Compute cell equivalent diameter (cell size)
1310 double cell_measure =
1311 compute_cell_measure_with_JxW(fe_values_cls.get_JxW_values());
1312 double h = compute_cell_diameter<dim>(cell_measure, degree);
1313
1314 // Loop over quadrature points
1315 for (unsigned int q = 0; q < n_q_points; q++)
1316 {
1317 double density_average = 0.5 * (density_0[q] + density_1[q]);
1318 double surface_tension_q =
1319 std::max(surface_tension[q], 1e-16); // Avoid division by zero
1320 double denominator_inv = 1 / (numbers::PI * surface_tension_q);
1321
1322 // Compute capillary time-step constraint
1323 double new_capillary_time_step_constraint =
1324 std::sqrt(density_average * Utilities::fixed_power<3>(h) *
1325 denominator_inv);
1326
1327 // Keep minimum between current and previously saved value
1328 capillary_time_step_constraint =
1329 std::min(new_capillary_time_step_constraint,
1330 capillary_time_step_constraint);
1331 }
1332 }
1333 }
1334
1335 // Get the minimum among active processes
1336 return Utilities::MPI::min(capillary_time_step_constraint, mpi_communicator);
1337}
1338
1339template <int dim>
1340void
1342{
1343 auto mpi_communicator = this->triangulation->get_mpi_communicator();
1344 unsigned int this_mpi_process(
1345 Utilities::MPI::this_mpi_process(mpi_communicator));
1346
1347 if (this_mpi_process == 0 &&
1348 simulation_parameters.analytical_solution->verbosity ==
1350 {
1351 if (this->simulation_parameters.simulation_control.method ==
1353 this->error_table.omit_column_from_convergence_rate_evaluation("cells");
1354 else
1355 this->error_table.omit_column_from_convergence_rate_evaluation("time");
1356
1357 this->error_table.set_scientific("error_phase", true);
1358 this->error_table.set_precision(
1359 "error_phase", this->simulation_control->get_log_precision());
1360 this->error_table.write_text(std::cout);
1361 }
1362
1364 {
1365 announce_string(this->pcout, "CLS");
1366 this->pcout << std::defaultfloat;
1367 this->computing_timer.print_summary();
1368 this->pcout << std::scientific;
1369 }
1370}
1371
1372template <int dim>
1373void
1375{
1376 for (unsigned int i = this->previous_solutions->size() - 1; i > 0; --i)
1377 {
1378 (*this->previous_solutions)[i] = (*this->previous_solutions)[i - 1];
1379 }
1380 (*this->previous_solutions)[0] = *this->present_solution;
1381}
1382
1383template <int dim>
1384void
1386{
1387 auto mpi_communicator = this->triangulation->get_mpi_communicator();
1388 unsigned int this_mpi_process(
1389 Utilities::MPI::this_mpi_process(mpi_communicator));
1390
1391 if (simulation_parameters.analytical_solution->calculate_error() &&
1392 !first_iteration)
1393 {
1394 double phase_error = calculate_L2_error();
1395
1396 if (this->simulation_control->is_steady())
1397 {
1398 this->error_table.add_value(
1399 "cells", this->triangulation->n_global_active_cells());
1400 }
1401 else
1402 {
1403 this->error_table.add_value(
1404 "time", this->simulation_control->get_current_time());
1405 }
1406 this->error_table.add_value("error_phase", phase_error);
1407 this->error_table.set_scientific("error_phase", true);
1408
1409 if (this_mpi_process == 0)
1410 {
1411 std::string filename =
1412 simulation_parameters.simulation_control.output_folder +
1413 simulation_parameters.analytical_solution->get_filename() +
1414 "_cls.dat";
1415 std::ofstream output(filename.c_str());
1416 this->error_table.write_text(output);
1417 }
1418
1419 if (simulation_parameters.analytical_solution->verbosity ==
1421 {
1422 this->pcout << "L2 error phase : " << phase_error << std::endl;
1423 }
1424 }
1425
1426 if (this->simulation_parameters.post_processing.calculate_mass_conservation)
1427 {
1428 TimerOutput::Scope t(this->computing_timer,
1429 "Calculate mass conservation");
1430 const std::vector<Parameters::FluidIndicator> fluid_indicators = {
1433
1434 const unsigned int n_fluids =
1435 this->simulation_parameters.physical_properties_manager
1436 .get_number_of_fluids();
1437
1438 // Set column names according to dim for volume and mass values
1439 std::string volume_column_name;
1440 std::string mass_column_name;
1441
1442 std::string geometric_volume_column_name;
1443 std::string area_column_name;
1444
1445 // To display when verbose
1446 std::vector<std::string> dependent_column_names;
1447 dependent_column_names.reserve(n_fluids * 2 + 1);
1448 std::vector<double> volumes_masses_momentum_and_sharpening_threshold;
1449 volumes_masses_momentum_and_sharpening_threshold.reserve(n_fluids * 2 +
1450 1);
1451
1452 if (this_mpi_process == 0)
1453 {
1454 // Set conservation monitoring table
1455 if (this->simulation_control->is_steady())
1456 {
1457 this->table_monitoring_cls.add_value(
1458 "cells", this->triangulation->n_global_active_cells());
1459 }
1460 else
1461 {
1462 this->table_monitoring_cls.add_value(
1463 "time", this->simulation_control->get_current_time());
1464 this->table_monitoring_cls.set_scientific("time", true);
1465 this->table_monitoring_cls.set_precision(
1466 "time", this->simulation_control->get_log_precision());
1467 }
1468 }
1469
1470 double geometric_volume_outside, geometric_volume_inside, surface;
1471
1472 // The mesh classifier in the InterfaceTools::integrate_volume_and_surface
1473 // is not compatible with other FE than FE_Q
1474 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1475 {
1476 std::tie(geometric_volume_outside, surface) =
1478 *dof_handler, *fe, *this->present_solution, 0.5);
1479
1480 // Compute geometric inside volume (fluid 1)
1481 const double global_volume =
1482 GridTools::volume(*this->triangulation, *this->mapping);
1483 geometric_volume_inside = global_volume - geometric_volume_outside;
1484 }
1485
1486 for (unsigned int i = 0; i < n_fluids; i++)
1487 {
1488 // Calculate volume and mass
1490 multiphysics->get_solution(
1492 fluid_indicators[i]);
1493
1494 // Calculate momentum
1495 const Tensor<1, dim> momentum =
1497 multiphysics->get_solution(
1499 fluid_indicators[i]);
1500
1501 if (this_mpi_process == 0)
1502 {
1503 std::string fluid_id("");
1504
1505 if (fluid_indicators[i] == Parameters::FluidIndicator::fluid_1)
1506 {
1507 fluid_id = "fluid_1";
1508 }
1509 else if (fluid_indicators[i] ==
1511 {
1512 fluid_id = "fluid_0";
1513 }
1514
1515 std::vector<std::string> momentum_names(
1516 {"momentum-x_" + fluid_id, "momentum-y_" + fluid_id});
1517 if constexpr (dim == 3)
1518 momentum_names.emplace_back("momentum-z_" + fluid_id);
1519
1520 if constexpr (dim == 2)
1521 {
1522 volume_column_name = "surface_" + fluid_id;
1523 mass_column_name = "mass_per_length_" + fluid_id;
1524 geometric_volume_column_name =
1525 "geometric_surface_" + fluid_id;
1526 area_column_name = "length_" + fluid_id;
1527 }
1528 else if constexpr (dim == 3)
1529 {
1530 volume_column_name = "volume_" + fluid_id;
1531 mass_column_name = "mass_" + fluid_id;
1532 geometric_volume_column_name = "geometric_volume_" + fluid_id;
1533 area_column_name = "surface_" + fluid_id;
1534 }
1535
1536 // Add "surface" or "volume" column
1537 this->table_monitoring_cls.add_value(volume_column_name,
1538 this->volume_monitored);
1539 this->table_monitoring_cls.set_scientific(volume_column_name,
1540 true);
1541 this->table_monitoring_cls.set_precision(
1542 volume_column_name,
1543 this->simulation_control->get_log_precision());
1544
1545 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1546 {
1547 // Add "geometric surface" or "geometric volume" column
1548 if (fluid_id == "fluid_1")
1549 {
1550 this->table_monitoring_cls.add_value(
1551 geometric_volume_column_name, geometric_volume_inside);
1552 this->table_monitoring_cls.set_scientific(
1553 geometric_volume_column_name, true);
1554 this->table_monitoring_cls.set_precision(
1555 geometric_volume_column_name,
1556 this->simulation_control->get_log_precision());
1557 }
1558 else
1559 {
1560 this->table_monitoring_cls.add_value(
1561 geometric_volume_column_name, geometric_volume_outside);
1562 this->table_monitoring_cls.set_scientific(
1563 geometric_volume_column_name, true);
1564 this->table_monitoring_cls.set_precision(
1565 geometric_volume_column_name,
1566 this->simulation_control->get_log_precision());
1567 }
1568 }
1569
1570 // Add "mass per length" or "mass" column
1571 this->table_monitoring_cls.add_value(mass_column_name,
1572 this->mass_monitored);
1573 this->table_monitoring_cls.set_scientific(mass_column_name, true);
1574 this->table_monitoring_cls.set_precision(
1575 mass_column_name,
1576 this->simulation_control->get_log_precision());
1577
1578 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1579 {
1580 this->table_monitoring_cls.add_value(area_column_name,
1581 surface);
1582 this->table_monitoring_cls.set_scientific(area_column_name,
1583 true);
1584 this->table_monitoring_cls.set_precision(
1585 area_column_name,
1586 this->simulation_control->get_log_precision());
1587 }
1588 // Add "momentum" columns
1589 for (int d = 0; d < dim; ++d)
1590 {
1591 this->table_monitoring_cls.add_value(momentum_names[d],
1592 momentum[d]);
1593 this->table_monitoring_cls.set_scientific(momentum_names[d],
1594 true);
1595 this->table_monitoring_cls.set_precision(
1596 momentum_names[d],
1597 this->simulation_control->get_log_precision());
1598 }
1599
1600 if (this->simulation_parameters.post_processing.verbosity ==
1602 {
1603 dependent_column_names.emplace_back(volume_column_name);
1604
1605 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1606 {
1607 dependent_column_names.emplace_back(
1608 geometric_volume_column_name);
1609 }
1610
1611 dependent_column_names.emplace_back(mass_column_name);
1612 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1613 {
1614 dependent_column_names.emplace_back(area_column_name);
1615 }
1616 volumes_masses_momentum_and_sharpening_threshold.emplace_back(
1617 this->volume_monitored);
1618 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1619 {
1620 if (fluid_id == "fluid_1")
1621 volumes_masses_momentum_and_sharpening_threshold
1622 .emplace_back(geometric_volume_inside);
1623 else
1624 volumes_masses_momentum_and_sharpening_threshold
1625 .emplace_back(geometric_volume_outside);
1626 }
1627 volumes_masses_momentum_and_sharpening_threshold.emplace_back(
1628 this->mass_monitored);
1629
1630 if (!simulation_parameters.fem_parameters.CLS_uses_dg)
1631 {
1632 volumes_masses_momentum_and_sharpening_threshold
1633 .emplace_back(surface);
1634 }
1635 for (int d = 0; d < dim; ++d)
1636 {
1637 dependent_column_names.emplace_back(momentum_names[d]);
1638 volumes_masses_momentum_and_sharpening_threshold
1639 .emplace_back(momentum[d]);
1640 }
1641 }
1642 }
1643 }
1644
1645 if (this_mpi_process == 0)
1646 {
1647 // Add sharpening threshold column
1648 this->table_monitoring_cls.add_value("sharpening_threshold",
1649 this->sharpening_threshold);
1650
1651 if (this->simulation_control->get_iteration_number() %
1652 this->simulation_parameters.post_processing.output_frequency ==
1653 0)
1654 {
1655 // Save table to .dat
1656 std::string filename =
1657 this->simulation_parameters.simulation_control.output_folder +
1658 this->simulation_parameters.post_processing
1659 .mass_conservation_output_name +
1660 ".dat";
1661 std::ofstream output(filename.c_str());
1662 this->table_monitoring_cls.write_text(output);
1663 }
1664
1665 // Print on terminal
1666 if (this->simulation_parameters.post_processing.verbosity ==
1668 {
1669 volumes_masses_momentum_and_sharpening_threshold.emplace_back(
1670 this->sharpening_threshold);
1671 dependent_column_names.emplace_back("sharpening_threshold");
1672
1673 // Dependent variable columns (volumes, masses and sharpening
1674 // threshold)
1675 std::vector<std::vector<double>>
1676 volumes_masses_and_sharpening_thresholds;
1677 volumes_masses_and_sharpening_thresholds.emplace_back(
1678 volumes_masses_momentum_and_sharpening_threshold);
1679
1680 // Time column
1681 std::string independent_column_name = "time";
1682 std::vector<double> time = {
1683 this->simulation_control->get_current_time()};
1684
1685 TableHandler table = make_table_scalars_vectors(
1686 time,
1687 independent_column_name,
1688 volumes_masses_and_sharpening_thresholds,
1689 dependent_column_names,
1690 this->simulation_parameters.simulation_control.log_precision,
1691 true);
1692
1693 std::cout << std::endl;
1694
1695
1696
1697 announce_string(this->pcout, "CLS Mass Conservation");
1698 table.write_text(std::cout);
1699 }
1700 }
1701 }
1702
1703 if (this->simulation_parameters.post_processing.calculate_barycenter)
1704 {
1705 // Calculate volume and mass (this->mass_monitored)
1706 std::pair<Tensor<1, dim>, Tensor<1, dim>> position_and_velocity;
1707 std::pair<Tensor<1, dim>, Tensor<1, dim>> position_and_velocity_geo;
1708
1709
1710 if (multiphysics->fluid_dynamics_is_block())
1711 {
1712 // Check if the post processed variable needs to be calculated with
1713 // the average velocity profile or the fluid solution.
1714 if (this->simulation_parameters.initial_condition->type ==
1716 average_velocity_profile &&
1717 !this->simulation_parameters.multiphysics.fluid_dynamics &&
1718 simulation_control->get_current_time() >
1719 this->simulation_parameters.post_processing
1720 .initial_time_for_average_velocities)
1721 {
1722 position_and_velocity = calculate_barycenter(
1723 *this->present_solution,
1724 multiphysics->get_block_time_average_solution(
1726 }
1727 else
1728 {
1729 position_and_velocity =
1731 multiphysics->get_block_solution(
1733 }
1734 }
1735 else
1736 {
1737 // Check if the post processed variable needs to be calculated with
1738 // the average velocity profile or the fluid solution.
1739 if (this->simulation_parameters.initial_condition->type ==
1741 average_velocity_profile &&
1742 !this->simulation_parameters.multiphysics.fluid_dynamics &&
1743 simulation_control->get_current_time() >
1744 this->simulation_parameters.post_processing
1745 .initial_time_for_average_velocities)
1746 {
1747 position_and_velocity =
1749 multiphysics->get_time_average_solution(
1751 }
1752 else
1753 {
1754 position_and_velocity =
1756 multiphysics->get_solution(
1758
1759 const DoFHandler<dim> &dof_handler_fd =
1760 multiphysics->get_dof_handler(PhysicsID::fluid_dynamics);
1761
1762 const Mapping<dim> &mapping_fd =
1764
1765 position_and_velocity_geo = InterfaceTools::integrate_barycenter(
1766 *this->dof_handler,
1767 *this->fe,
1768 *this->present_solution,
1769 mapping_fd,
1770 dof_handler_fd,
1771 dof_handler_fd.get_fe(),
1773 0.5);
1774 }
1775 }
1776 if (this_mpi_process == 0)
1777 {
1778 if (simulation_parameters.post_processing.verbosity ==
1780 {
1781 std::cout << std::endl;
1782 std::string independent_column_names = "time";
1783
1784 std::vector<std::string> dependent_column_names;
1785 dependent_column_names.emplace_back("x_cls");
1786 dependent_column_names.emplace_back("y_cls");
1787 if constexpr (dim == 3)
1788 dependent_column_names.emplace_back("z_cls");
1789 dependent_column_names.emplace_back("vx_cls");
1790 dependent_column_names.emplace_back("vy_cls");
1791 if constexpr (dim == 3)
1792 dependent_column_names.emplace_back("vz_cls");
1793
1794 dependent_column_names.emplace_back("x_cls_geo");
1795 dependent_column_names.emplace_back("y_cls_geo");
1796 if constexpr (dim == 3)
1797 dependent_column_names.emplace_back("z_cls_geo");
1798 dependent_column_names.emplace_back("vx_cls_geo");
1799 dependent_column_names.emplace_back("vy_cls_geo");
1800 if constexpr (dim == 3)
1801 dependent_column_names.emplace_back("vz_cls_geo");
1802
1803 std::vector<Tensor<1, dim>> position_vector{
1804 position_and_velocity.first};
1805 std::vector<Tensor<1, dim>> velocity_vector{
1806 position_and_velocity.second};
1807
1808 std::vector<Tensor<1, dim>> position_vector_geo{
1809 position_and_velocity_geo.first};
1810 std::vector<Tensor<1, dim>> velocity_vector_geo{
1811 position_and_velocity_geo.second};
1812
1813 std::vector<std::vector<Tensor<1, dim>>>
1814 position_and_velocity_vectors{position_vector,
1815 velocity_vector,
1816 position_vector_geo,
1817 velocity_vector_geo};
1818
1819 std::vector<double> time = {
1820 this->simulation_control->get_current_time()};
1821
1822 TableHandler table = make_table_scalars_tensors(
1823 time,
1824 independent_column_names,
1825 position_and_velocity_vectors,
1826 dependent_column_names,
1827 this->simulation_parameters.simulation_control.log_precision,
1828 true);
1829
1830 announce_string(this->pcout, "CLS Barycenter");
1831 table.write_text(std::cout);
1832 }
1833
1834 this->table_barycenter.add_value(
1835 "time", simulation_control->get_current_time());
1836 this->table_barycenter.set_scientific("time", true);
1837 this->table_barycenter.set_precision(
1838 "time", this->simulation_control->get_log_precision());
1839
1840 this->table_barycenter.add_value("x_cls",
1841 position_and_velocity.first[0]);
1842 this->table_barycenter.set_scientific("x_cls", true);
1843 this->table_barycenter.set_precision(
1844 "x_cls", this->simulation_control->get_log_precision());
1845
1846 this->table_barycenter.add_value("y_cls",
1847 position_and_velocity.first[1]);
1848 this->table_barycenter.set_scientific("y_cls", true);
1849 this->table_barycenter.set_precision(
1850 "y_cls", this->simulation_control->get_log_precision());
1851
1852 if constexpr (dim == 3)
1853 {
1854 this->table_barycenter.add_value("z_cls",
1855 position_and_velocity.first[2]);
1856 this->table_barycenter.set_scientific("z_cls", true);
1857 this->table_barycenter.set_precision(
1858 "z_cls", this->simulation_control->get_log_precision());
1859 }
1860
1861 this->table_barycenter.add_value("vx_cls",
1862 position_and_velocity.second[0]);
1863 this->table_barycenter.set_scientific("vx_cls", true);
1864 this->table_barycenter.set_precision(
1865 "vx_cls", this->simulation_control->get_log_precision());
1866
1867 this->table_barycenter.add_value("vy_cls",
1868 position_and_velocity.second[1]);
1869 this->table_barycenter.set_scientific("vy_cls", true);
1870 this->table_barycenter.set_precision(
1871 "vy_cls", this->simulation_control->get_log_precision());
1872
1873 if constexpr (dim == 3)
1874 {
1875 this->table_barycenter.add_value("vz_cls",
1876 position_and_velocity.second[2]);
1877 this->table_barycenter.set_scientific("vz_cls", true);
1878 this->table_barycenter.set_precision(
1879 "vz_cls", this->simulation_control->get_log_precision());
1880 }
1881
1882 this->table_barycenter.add_value("x_cls_geo",
1883 position_and_velocity_geo.first[0]);
1884 this->table_barycenter.set_scientific("x_cls_geo", true);
1885 this->table_barycenter.set_precision(
1886 "x_cls_geo", this->simulation_control->get_log_precision());
1887
1888 this->table_barycenter.add_value("y_cls_geo",
1889 position_and_velocity_geo.first[1]);
1890 this->table_barycenter.set_scientific("y_cls_geo", true);
1891 this->table_barycenter.set_precision(
1892 "y_cls_geo", this->simulation_control->get_log_precision());
1893
1894 if constexpr (dim == 3)
1895 {
1896 this->table_barycenter.add_value(
1897 "z_cls_geo", position_and_velocity_geo.first[2]);
1898 this->table_barycenter.set_scientific("z_cls_geo", true);
1899 this->table_barycenter.set_precision(
1900 "z_cls_geo", this->simulation_control->get_log_precision());
1901 }
1902
1903 this->table_barycenter.add_value("vx_cls_geo",
1904 position_and_velocity_geo.second[0]);
1905 this->table_barycenter.set_scientific("vx_cls_geo", true);
1906 this->table_barycenter.set_precision(
1907 "vx_cls_geo", this->simulation_control->get_log_precision());
1908
1909 this->table_barycenter.add_value("vy_cls_geo",
1910 position_and_velocity_geo.second[1]);
1911 this->table_barycenter.set_scientific("vy_cls_geo", true);
1912 this->table_barycenter.set_precision(
1913 "vy_cls_geo", this->simulation_control->get_log_precision());
1914
1915 if constexpr (dim == 3)
1916 {
1917 this->table_barycenter.add_value(
1918 "vz_cls_geo", position_and_velocity_geo.second[2]);
1919 this->table_barycenter.set_scientific("vz_cls_geo", true);
1920 this->table_barycenter.set_precision(
1921 "vz_cls_geo", this->simulation_control->get_log_precision());
1922 }
1923
1924 if (this->simulation_control->get_iteration_number() %
1925 this->simulation_parameters.post_processing.output_frequency ==
1926 0)
1927 {
1928 // Save table to .dat
1929 std::string filename =
1930 this->simulation_parameters.simulation_control.output_folder +
1931 this->simulation_parameters.post_processing
1932 .barycenter_output_name +
1933 ".dat";
1934 std::ofstream output(filename.c_str());
1935 this->table_barycenter.write_text(output);
1936 output.close();
1937 }
1938 }
1939 }
1940
1941 // Phase indicator isocontour bounding boxes
1942 if (this->simulation_parameters.post_processing.isocontour_bounding_boxes
1943 .ids_and_isocontours_per_variable.contains(Variable::phase))
1944 {
1945 TimerOutput::Scope t(this->computing_timer,
1946 "Compute bounding values of phase isocontours");
1949 this->simulation_parameters.post_processing.isocontour_bounding_boxes
1950 .ids_and_isocontours_per_variable,
1951 *this->dof_handler,
1952 *this->present_solution,
1953 this->simulation_control->get_current_time(),
1954 this->simulation_parameters.post_processing.verbosity,
1955 this->pcout,
1956 this->phase_indicator_isocontour_bounding_values_tables);
1957
1958 if (simulation_control->get_iteration_number() %
1959 this->simulation_parameters.post_processing.output_frequency ==
1960 0)
1962 this->dof_handler->get_mpi_communicator(),
1963 this->simulation_parameters.simulation_control.output_folder,
1965 this->simulation_parameters.post_processing.isocontour_bounding_boxes
1966 .ids_and_isocontours_per_variable,
1967 this->phase_indicator_isocontour_bounding_values_tables);
1968 }
1969
1970 // Postprocess probes
1971 if (this->simulation_parameters.post_processing.probing_points
1972 .probing_points_per_variable.contains(Variable::phase))
1973 this->multiphysics->postprocess_probes(
1975
1976 // Compute and update current capillary time-step constraint
1977 if (this->simulation_parameters.simulation_control.method !=
1979 this->simulation_parameters.multiphysics.cls_parameters
1980 .surface_tension_force.enable &&
1981 this->simulation_parameters.simulation_control
1982 .adapt_with_capillary_time_step_ratio)
1983 {
1984 // Compute capillary time-step constraint
1985 this->simulation_control->set_capillary_time_step_constraint(
1987 this->simulation_parameters.physical_properties_manager
1988 .field_is_required(field::pressure),
1989 this->simulation_parameters.physical_properties_manager
1990 .field_is_required(field::temperature)));
1991 }
1992}
1993
1994template <int dim>
1995void
1997{
1998 announce_string(this->pcout, "CLS");
1999 this->pcout << std::defaultfloat;
2000 this->computing_timer.print_summary();
2001 this->pcout << std::scientific;
2002 this->computing_timer.reset();
2003}
2004
2005template <int dim>
2006void
2008{
2009 {
2010 TimerOutput::Scope t(this->computing_timer, "Modify solution");
2011
2012 auto cls_parameters =
2013 this->simulation_parameters.multiphysics.cls_parameters;
2014 // Interface sharpening
2015 if (cls_parameters.reinitialization_method.sharpening.enable)
2016 {
2017 // Interface sharpening is done at a constant frequency
2018 if (this->simulation_control->get_iteration_number() %
2019 this->simulation_parameters.multiphysics.cls_parameters
2020 .reinitialization_method.frequency ==
2021 0)
2022 {
2024 }
2025 }
2026 }
2027
2028 // Apply PDE-based interface reinitialization
2029 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
2030 .pde_based_interface_reinitialization.enable &&
2031 (simulation_control->get_iteration_number() %
2032 simulation_parameters.multiphysics.cls_parameters
2033 .reinitialization_method.frequency ==
2034 0))
2036
2037 // Apply geometric interface reinitialization
2038 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
2039 .geometric_interface_reinitialization.enable &&
2040 (simulation_control->get_iteration_number() %
2041 simulation_parameters.multiphysics.cls_parameters
2042 .reinitialization_method.frequency ==
2043 0))
2045
2046 // Apply filter to phase indicator values
2048
2049 // Solve phase indicator gradient and curvature projections
2050 if (simulation_parameters.multiphysics.cls_parameters.surface_tension_force
2051 .enable)
2052 {
2053 this->cls_subequations_interface->set_cls_solution_and_dof_handler(
2054 *this->present_solution, *this->dof_handler);
2055 this->cls_subequations_interface->solve_specific_subequation(
2057 this->cls_subequations_interface->solve_specific_subequation(
2059 }
2060}
2061
2062template <int dim>
2063void
2065{
2066 if (this->simulation_parameters.multiphysics.cls_parameters
2067 .reinitialization_method.verbosity != Parameters::Verbosity::quiet)
2068 {
2069 this->pcout << "Sharpening interface at step "
2070 << this->simulation_control->get_iteration_number()
2071 << std::endl;
2072 }
2073 if (this->simulation_parameters.multiphysics.cls_parameters
2074 .reinitialization_method.sharpening.type ==
2076 {
2077 if (this->simulation_parameters.multiphysics.cls_parameters
2078 .reinitialization_method.verbosity != Parameters::Verbosity::quiet)
2079 {
2080 this->pcout << " Adapting the sharpening threshold" << std::endl;
2081 }
2082
2084
2085 if (this->simulation_parameters.multiphysics.cls_parameters
2086 .reinitialization_method.verbosity != Parameters::Verbosity::quiet)
2087 {
2088 this->pcout << " ... final sharpening is : "
2089 << this->sharpening_threshold << std::endl;
2090 }
2091 }
2092 else
2093 {
2094 // Constant sharpening
2095 this->sharpening_threshold =
2096 this->simulation_parameters.multiphysics.cls_parameters
2097 .reinitialization_method.sharpening.threshold;
2098 }
2099
2100 // Sharpen the interface of all solutions (present and previous)
2102}
2103
2104
2105template <int dim>
2106double
2108{
2109 // Sharpening threshold (st) search range extrema
2110 double st_min =
2111 0.5 - this->simulation_parameters.multiphysics.cls_parameters
2112 .reinitialization_method.sharpening.threshold_max_deviation;
2113 double st_max =
2114 0.5 + this->simulation_parameters.multiphysics.cls_parameters
2115 .reinitialization_method.sharpening.threshold_max_deviation;
2116
2117 // Useful definitions for readability
2118 const double mass_deviation_tol =
2119 this->simulation_parameters.multiphysics.cls_parameters
2120 .reinitialization_method.sharpening.tolerance *
2122 const unsigned int max_iterations =
2123 this->simulation_parameters.multiphysics.cls_parameters
2124 .reinitialization_method.sharpening.max_iterations;
2125
2126 const Parameters::FluidIndicator monitored_fluid =
2127 this->simulation_parameters.multiphysics.cls_parameters
2128 .reinitialization_method.sharpening.monitored_fluid;
2129
2130 unsigned int nb_search_ite = 0;
2131 // Local variable for the tested sharpening_threshold values
2132
2133 double mass_deviation_min = calculate_mass_deviation(monitored_fluid, st_min);
2134 double mass_deviation_max = calculate_mass_deviation(monitored_fluid, st_max);
2135 double mass_deviation_avg = 0.;
2136 double st_avg = 0.;
2137
2138
2139 // Bissection algorithm to calculate an interface sharpening value that would
2140 // ensure mass conservation of the monitored phase (do-while loop, see
2141 // condition below)
2142 do
2143 {
2144 nb_search_ite++;
2145 // Calculate middle point value
2146 st_avg = (st_min + st_max) / 2.;
2147
2148 mass_deviation_avg = calculate_mass_deviation(monitored_fluid, st_avg);
2149
2150 if (this->simulation_parameters.multiphysics.cls_parameters
2151 .reinitialization_method.verbosity != Parameters::Verbosity::quiet)
2152 {
2153 this->pcout
2154 << " ... step " << nb_search_ite
2155 << " of the search algorithm, min, avg, max mass deviation is : "
2156 << mass_deviation_min << " " << mass_deviation_avg << " "
2157 << mass_deviation_max << std::endl;
2158 }
2159
2160 if (mass_deviation_avg * mass_deviation_min < 0)
2161 {
2162 st_max = st_avg;
2163 mass_deviation_max = mass_deviation_avg;
2164 }
2165 else
2166 {
2167 st_min = st_avg;
2168 mass_deviation_min = mass_deviation_avg;
2169 }
2170 }
2171 while (std::abs(mass_deviation_avg) > mass_deviation_tol &&
2172 nb_search_ite < max_iterations);
2173
2174 // Take minimum deviation in between the two endpoints of the last
2175 // interval searched, if out of the do-while loop because max_iterations is
2176 // reached
2177 if (std::abs(mass_deviation_avg) > mass_deviation_tol)
2178 {
2179 double mass_deviation_endpoint = 0.;
2180 double st_tested = 0;
2181 if (st_min == st_avg)
2182 st_tested = st_max;
2183 else if (st_max == st_avg)
2184 st_tested = st_min;
2185
2186 mass_deviation_endpoint =
2187 calculate_mass_deviation(monitored_fluid, st_tested);
2188
2189 // Retake st_ave value if mass deviation is not lowered at endpoint
2190 // values
2191 if (std::abs(mass_deviation_endpoint) > std::abs(mass_deviation_avg))
2192 {
2193 st_tested = st_avg;
2194 }
2195
2196 // Output message
2197 if (std::abs(mass_deviation_endpoint) > mass_deviation_tol)
2198 {
2199 this->pcout
2200 << " WARNING: Maximum number of iterations (" << nb_search_ite
2201 << ") reached in the " << std::endl
2202 << " adaptive sharpening threshold algorithm, remaining error"
2203 << std::endl
2204 << " on mass conservation is: "
2205 << (this->mass_monitored - this->mass_first_iteration) /
2207 << std::endl
2208 << " Consider increasing the sharpening threshold range or the "
2209 << std::endl
2210 << " number of iterations to reach the mass conservation tolerance."
2211 << std::endl;
2212 }
2213 }
2214
2215 // Output message that mass conservation condition is reached
2216 if (this->simulation_parameters.multiphysics.cls_parameters
2217 .reinitialization_method.verbosity != Parameters::Verbosity::quiet)
2218 {
2219 this->pcout << " ... search algorithm took : " << nb_search_ite
2220 << " step(s) " << std::endl
2221 << " ... error on mass conservation reached: "
2222 << (this->mass_monitored - this->mass_first_iteration) /
2224 << std::endl;
2225 }
2226
2227 return st_avg;
2228}
2229
2230
2231template <int dim>
2232double
2234 const Parameters::FluidIndicator monitored_fluid,
2235 const double sharpening_threshold)
2236{
2237 // Copy present solution CLS
2239
2240 // Sharpen interface using the tested threshold value
2242
2243 // Calculate mass of the monitored phase
2245 multiphysics->get_solution(
2247 monitored_fluid);
2248
2249 // Calculate relative mass deviation
2250 double mass_deviation = (this->mass_monitored - this->mass_first_iteration) /
2252
2253 return mass_deviation;
2254}
2255
2256template <int dim>
2257void
2259 GlobalVectorType &solution,
2260 const double sharpening_threshold,
2261 const bool sharpen_previous_solutions)
2262{
2263 // Limit the phase indicators between 0 and 1
2265 if (sharpen_previous_solutions)
2266 {
2267 for (auto &previous_solution : *previous_solutions)
2268 update_solution_and_constraints(previous_solution);
2269 }
2270
2271 // Assemble matrix and solve the system for interface sharpening
2274
2275 if (sharpen_previous_solutions)
2276 {
2277 for (auto &previous_solution : *previous_solutions)
2278 {
2281 solve_interface_sharpening(previous_solution);
2282 }
2283 }
2284
2285 // Re limit the phase indicators between 0 and 1 after interface
2286 // sharpening
2288 if (sharpen_previous_solutions)
2289 {
2290 for (auto &previous_solution : *previous_solutions)
2291 update_solution_and_constraints(previous_solution);
2292 }
2293}
2294
2295
2296template <int dim>
2297void
2303
2304
2305template <int dim>
2306void
2308 GlobalVectorType &solution)
2309{
2310 // Get fe values of CLS phase indicator
2311 FEValues<dim> fe_values_phase_indicator(*this->mapping,
2312 *this->fe,
2313 *this->cell_quadrature,
2314 update_values | update_JxW_values |
2315 update_gradients);
2316
2317 const unsigned int dofs_per_cell = this->fe->dofs_per_cell;
2318
2319 const unsigned int n_q_points = this->cell_quadrature->size();
2320 FullMatrix<double> local_matrix_phase_indicator(dofs_per_cell, dofs_per_cell);
2321 Vector<double> local_rhs_phase_indicator(dofs_per_cell);
2322 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
2323
2324 std::vector<double> phi_phase_indicator(dofs_per_cell);
2325 std::vector<Tensor<1, dim>> phi_phase_indicator_gradient(dofs_per_cell);
2326
2327 std::vector<double> phase_values(n_q_points);
2328
2329 // Reinitialize system matrix and rhs for the projected phase indicator
2332
2333 double h;
2334 double cell_measure;
2335
2336 const double phase_indicator_diffusion_factor =
2337 this->simulation_parameters.initial_condition
2338 ->projection_step_diffusion_factor;
2339
2340 for (const auto &cell : this->dof_handler->active_cell_iterators())
2341 {
2342 if (cell->is_locally_owned())
2343 {
2344 fe_values_phase_indicator.reinit(cell);
2345
2346 // Compute cell diameter
2347 cell_measure = compute_cell_measure_with_JxW(
2348 fe_values_phase_indicator.get_JxW_values());
2349 h = compute_cell_diameter<dim>(cell_measure, fe->degree);
2350
2351 local_matrix_phase_indicator = 0;
2352 local_rhs_phase_indicator = 0;
2353
2354 // Get phase indicator values
2355 fe_values_phase_indicator.get_function_values(solution, phase_values);
2356
2357 double color_function = 0.0;
2358 for (unsigned int q = 0; q < n_q_points; ++q)
2359 {
2360 color_function +=
2361 phase_values[q] * fe_values_phase_indicator.JxW(q);
2362 }
2363
2364 color_function /= cell_measure;
2365
2366 for (unsigned int q = 0; q < n_q_points; ++q)
2367 {
2368 for (unsigned int k = 0; k < dofs_per_cell; ++k)
2369 {
2370 phi_phase_indicator[k] =
2371 fe_values_phase_indicator.shape_value(k, q);
2372 phi_phase_indicator_gradient[k] =
2373 fe_values_phase_indicator.shape_grad(k, q);
2374 }
2375
2376 for (unsigned int i = 0; i < dofs_per_cell; ++i)
2377 {
2378 // Matrix assembly
2379 for (unsigned int j = 0; j < dofs_per_cell; ++j)
2380 {
2381 local_matrix_phase_indicator(i, j) +=
2382 (phi_phase_indicator[j] * phi_phase_indicator[i] +
2383 phase_indicator_diffusion_factor * h * h *
2384 scalar_product(phi_phase_indicator_gradient[i],
2385 phi_phase_indicator_gradient[j])) *
2386 fe_values_phase_indicator.JxW(q);
2387 }
2388
2389 // rhs
2390 local_rhs_phase_indicator(i) +=
2391 phi_phase_indicator[i] * color_function *
2392 fe_values_phase_indicator.JxW(q);
2393 }
2394 }
2395
2396 cell->get_dof_indices(local_dof_indices);
2397 this->nonzero_constraints.distribute_local_to_global(
2398 local_matrix_phase_indicator,
2399 local_rhs_phase_indicator,
2400 local_dof_indices,
2403 }
2404 }
2405 system_matrix_phase_indicator.compress(VectorOperation::add);
2406 system_rhs_phase_indicator.compress(VectorOperation::add);
2407}
2408
2409
2410template <int dim>
2411void
2413 GlobalVectorType &solution)
2414{
2415 // Solve the L2 projection system
2416 const double linear_solver_tolerance = 1e-13;
2417
2418 GlobalVectorType completely_distributed_phase_indicator_solution(
2419 this->locally_owned_dofs, triangulation->get_mpi_communicator());
2420
2421 SolverControl solver_control(
2422 this->simulation_parameters.linear_solver.at(PhysicsID::CLS).max_iterations,
2423 linear_solver_tolerance,
2424 true,
2425 true);
2426
2427 TrilinosWrappers::SolverCG solver(solver_control);
2428
2429 const unsigned int ilu_fill =
2430 this->simulation_parameters.linear_solver.at(PhysicsID::CLS)
2431 .ilu_precond_fill;
2432 const double ilu_atol =
2433 this->simulation_parameters.linear_solver.at(PhysicsID::CLS)
2434 .ilu_precond_atol;
2435 const double ilu_rtol =
2436 this->simulation_parameters.linear_solver.at(PhysicsID::CLS)
2437 .ilu_precond_rtol;
2438
2439 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
2440 ilu_fill, ilu_atol, ilu_rtol, 0);
2441
2442 ilu_preconditioner = std::make_shared<TrilinosWrappers::PreconditionILU>();
2443
2445 preconditionerOptions);
2446 solver.solve(system_matrix_phase_indicator,
2447 completely_distributed_phase_indicator_solution,
2450
2451 if (this->simulation_parameters.multiphysics.cls_parameters
2452 .surface_tension_force.verbosity != Parameters::Verbosity::quiet)
2453 {
2454 this->pcout << " -Iterative solver (phase indicator) took : "
2455 << solver_control.last_step() << " steps " << std::endl;
2456 }
2457
2458 this->nonzero_constraints.distribute(
2459 completely_distributed_phase_indicator_solution);
2460 solution = completely_distributed_phase_indicator_solution;
2461}
2462
2463
2464template <int dim>
2465void
2467{
2468 this->solution_transfer->prepare_for_coarsening_and_refinement(
2469 *this->present_solution);
2470
2471 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
2472 {
2474 .prepare_for_coarsening_and_refinement((*this->previous_solutions)[i]);
2475 }
2476}
2477
2478
2479template <int dim>
2480void
2482{
2483 auto mpi_communicator = this->triangulation->get_mpi_communicator();
2484
2485 // Set up the vectors for the transfer
2486 GlobalVectorType tmp(this->locally_owned_dofs, mpi_communicator);
2487
2488 // Interpolate the solution at time and previous time
2489 this->solution_transfer->interpolate(tmp);
2490
2491 // Distribute constraints
2492 this->nonzero_constraints.distribute(tmp);
2493
2494 // Fix on the new mesh
2495 *this->present_solution = tmp;
2496
2497 // Transfer previous solutions
2498 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
2499 {
2500 GlobalVectorType tmp_previous_solution(this->locally_owned_dofs,
2501 mpi_communicator);
2502 this->previous_solutions_transfer[i].interpolate(tmp_previous_solution);
2503 this->nonzero_constraints.distribute(tmp_previous_solution);
2504 (*this->previous_solutions)[i] = tmp_previous_solution;
2505 }
2506
2507 // Apply filter to phase indicator
2509}
2510
2511template <int dim>
2512void
2514 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
2515 &ivar,
2516 dealii::Vector<float> &estimated_error_per_cell)
2517{
2518 if (ivar.first == Variable::phase)
2519 {
2520 AssertThrow(
2521 ivar.second.error_estimator ==
2523 ExcMessage(
2524 "Only the Kelly error estimator is currently implemented for the "
2525 "<phase> CLS field."));
2526
2527
2528 ComponentMask phase_mask =
2529 fe->component_mask(FEValuesExtractors::Scalar(0));
2530 compute_kelly(estimated_error_per_cell, phase_mask);
2531 }
2532}
2533
2534template <int dim>
2535void
2537 dealii::Vector<float> &estimated_error_per_cell,
2538 const ComponentMask &component_mask)
2539{
2540 KellyErrorEstimator<dim>::estimate(
2541 *this->mapping,
2542 *this->dof_handler,
2543 *this->face_quadrature,
2544 typename std::map<types::boundary_id, const Function<dim, double> *>(),
2545 *this->present_solution,
2546 estimated_error_per_cell,
2547 component_mask);
2548}
2549
2550template <int dim>
2551std::vector<OutputStructTableHandler>
2553{
2554 std::vector<OutputStructTableHandler> table_output_structs;
2555
2556 std::string prefix =
2557 this->simulation_parameters.simulation_control.output_folder;
2558 std::string suffix = ".checkpoint";
2559
2560 if (this->simulation_parameters.analytical_solution->calculate_error())
2561 table_output_structs.emplace_back(
2562 this->error_table,
2563 prefix + this->simulation_parameters.analytical_solution->get_filename() +
2564 "_CLS" + suffix);
2565
2566 if (this->simulation_parameters.post_processing.calculate_mass_conservation)
2567 table_output_structs.emplace_back(
2569 prefix +
2570 this->simulation_parameters.post_processing
2571 .mass_conservation_output_name +
2572 suffix);
2573
2574 if (this->simulation_parameters.post_processing.calculate_barycenter)
2575 table_output_structs.emplace_back(
2576 this->table_barycenter,
2577 prefix +
2578 this->simulation_parameters.post_processing.barycenter_output_name +
2579 suffix);
2580
2581 if (this->simulation_parameters.post_processing.isocontour_bounding_boxes
2582 .ids_and_isocontours_per_variable.contains(Variable::phase))
2583 {
2584 // Get iterator range that corresponds to the variable "temperature"
2585 auto [begin, end] =
2586 this->simulation_parameters.post_processing.isocontour_bounding_boxes
2587 .ids_and_isocontours_per_variable.equal_range(Variable::phase);
2588
2589 // Initialize iterator for the table(s)
2590 unsigned int i = 0;
2591
2592 for (auto it = begin; it != end; ++it, ++i)
2593 {
2594 // Get isocontour output name
2595 const std::string &isocontour_output_name =
2596 it->second.second.output_name;
2597
2598 table_output_structs.emplace_back(
2600 prefix + isocontour_output_name + suffix);
2601 }
2602 }
2603
2604 return table_output_structs;
2605}
2606
2607template <int dim>
2608void
2610{
2611 auto mpi_communicator = this->triangulation->get_mpi_communicator();
2612
2613 std::vector<const GlobalVectorType *> sol_set_transfer;
2614
2616 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
2617
2618 sol_set_transfer.emplace_back(&(*this->present_solution));
2619 for (const auto &previous_solution : *this->previous_solutions)
2620 {
2621 sol_set_transfer.emplace_back(&previous_solution);
2622 }
2623 this->solution_transfer->prepare_for_serialization(sol_set_transfer);
2624
2625 // Serialize all post-processing tables that are currently used with the CLS
2626 // solver
2627 const std::vector<OutputStructTableHandler> &table_output_structs =
2628 this->gather_tables();
2629 serialize_tables_vector(table_output_structs, mpi_communicator);
2630}
2631
2632template <int dim>
2633void
2635{
2636 auto mpi_communicator = this->triangulation->get_mpi_communicator();
2637
2638 auto previous_solutions_size = this->previous_solutions->size();
2639 this->pcout << "Reading CLS checkpoint" << std::endl;
2640
2641 std::vector<GlobalVectorType *> input_vectors(1 + previous_solutions_size);
2642 GlobalVectorType distributed_system(this->locally_owned_dofs,
2643 mpi_communicator);
2644 input_vectors[0] = &distributed_system;
2645
2646
2647 std::vector<GlobalVectorType> distributed_previous_solutions;
2648 distributed_previous_solutions.reserve(previous_solutions_size);
2649 for (unsigned int i = 0; i < previous_solutions_size; ++i)
2650 {
2651 distributed_previous_solutions.emplace_back(
2652 GlobalVectorType(this->locally_owned_dofs, mpi_communicator));
2653 input_vectors[i + 1] = &distributed_previous_solutions[i];
2654 }
2655
2656 this->solution_transfer->deserialize(input_vectors);
2657
2658 *this->present_solution = distributed_system;
2659 for (unsigned int i = 0; i < previous_solutions_size; ++i)
2660 {
2661 (*this->previous_solutions)[i] = distributed_previous_solutions[i];
2662 }
2663
2664 // Apply filter to phase indicator
2666
2667 // Deserialize all post-processing tables that are currently used with the CLS
2668 // solver
2669 std::vector<OutputStructTableHandler> table_output_structs =
2670 this->gather_tables();
2671 deserialize_tables_vector(table_output_structs, mpi_communicator);
2672
2673 if (this->simulation_parameters.multiphysics.cls_parameters
2674 .reinitialization_method.sharpening.type ==
2676 {
2677 // Calculate volume and mass
2679 *this->present_solution,
2681 this->simulation_parameters.multiphysics.cls_parameters
2682 .reinitialization_method.sharpening.monitored_fluid);
2683
2685 }
2686}
2687
2688
2689template <int dim>
2690void
2692{
2694
2695 auto mpi_communicator = triangulation->get_mpi_communicator();
2696
2697 // Setup DoFs for all active subequations
2698 this->cls_subequations_interface->setup_dofs();
2699
2700 this->dof_handler->distribute_dofs(*this->fe);
2701 DoFRenumbering::Cuthill_McKee(*this->dof_handler);
2702
2703 this->locally_owned_dofs = this->dof_handler->locally_owned_dofs();
2704
2705 this->locally_relevant_dofs =
2706 DoFTools::extract_locally_relevant_dofs(*this->dof_handler);
2707
2708 this->present_solution->reinit(this->locally_owned_dofs,
2710 mpi_communicator);
2711
2712 this->filtered_solution->reinit(this->locally_owned_dofs,
2714 mpi_communicator);
2715
2716 this->level_set.reinit(this->locally_owned_dofs,
2718 mpi_communicator);
2719
2720 // Previous solutions for transient schemes
2721 for (auto &solution : *this->previous_solutions)
2722 {
2723 solution.reinit(this->locally_owned_dofs,
2725 mpi_communicator);
2726 }
2727
2728 this->system_rhs.reinit(this->locally_owned_dofs, mpi_communicator);
2729
2730 this->newton_update.reinit(this->locally_owned_dofs, mpi_communicator);
2731
2732 this->local_evaluation_point.reinit(this->locally_owned_dofs,
2733 mpi_communicator);
2734
2736
2737 // Boundary conditions for Newton correction
2739
2740 // Sparse matrices initialization
2741 DynamicSparsityPattern dsp(this->locally_relevant_dofs);
2742 if (simulation_parameters.fem_parameters.CLS_uses_dg)
2743 {
2744 DoFTools::make_flux_sparsity_pattern(*this->dof_handler,
2745 dsp,
2747 /*keep_constrained_dofs = */ true);
2748 }
2749 else
2750 {
2751 DoFTools::make_sparsity_pattern(*this->dof_handler,
2752 dsp,
2754 /*keep_constrained_dofs = */ false);
2755 }
2756
2757 SparsityTools::distribute_sparsity_pattern(dsp,
2758 this->locally_owned_dofs,
2759 mpi_communicator,
2760 this->locally_relevant_dofs);
2761
2762 // Initialization of phase indicator matrices for interface sharpening.
2763 // system_matrix_phase_indicator is used in
2764 // assemble_L2_projection_interface_sharpening for assembling the system for
2765 // sharpening the interface, while complete_system_matrix_phase_indicator is
2766 // used in update_solution_and_constraints to limit the phase indicator
2767 // values between 0 and 1. According to step-41, to limit the phase indicators
2768 // we compute the Lagrange multiplier as the residual of the original linear
2769 // system, given via the variables complete_system_matrix_phase_indicator and
2770 // complete_system_rhs_phase_indicator
2772 this->locally_owned_dofs,
2773 dsp,
2774 mpi_communicator);
2775
2777 this->locally_owned_dofs,
2778 dsp,
2779 mpi_communicator);
2780
2782 mpi_communicator);
2783
2784 // In update_solution_and_constraints (which limits the phase indicator
2785 // between 0 and 1) nodal_phase_indicator_owned copies the solution, then
2786 // limits it, and finally updates (rewrites) the solution.
2788 mpi_communicator);
2789
2790 // Right hand side of the interface sharpening problem (used in
2791 // assemble_L2_projection_interface_sharpening).
2792 system_rhs_phase_indicator.reinit(this->locally_owned_dofs, mpi_communicator);
2793
2794 this->system_matrix.reinit(this->locally_owned_dofs,
2795 this->locally_owned_dofs,
2796 dsp,
2797 mpi_communicator);
2798
2799 this->pcout << " Number of CLS degrees of freedom: "
2800 << this->dof_handler->n_dofs() << std::endl;
2801
2802 // Provide the CLS dof_handler and solution pointers to the
2803 // multiphysics interface
2804 multiphysics->set_dof_handler(PhysicsID::CLS, this->dof_handler);
2805 multiphysics->set_mapping(PhysicsID::CLS, this->mapping);
2806 multiphysics->set_solution(PhysicsID::CLS, this->present_solution);
2807 multiphysics->set_filtered_solution(PhysicsID::CLS, this->filtered_solution);
2808 multiphysics->set_previous_solutions(PhysicsID::CLS,
2809 this->previous_solutions);
2810
2811 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
2812 .geometric_interface_reinitialization.enable)
2813 {
2814 signed_distance_solver->setup_dofs();
2815 }
2816
2817
2819 this->locally_owned_dofs,
2820 dsp,
2821 mpi_communicator);
2822
2824}
2825
2826template <int dim>
2827void
2829{
2830 if (!this->simulation_parameters.cls_boundary_conditions.time_dependent)
2831 return;
2832
2833 double time = this->simulation_control->get_current_time();
2834 for (auto const &[id, type] :
2835 this->simulation_parameters.cls_boundary_conditions.type)
2836 {
2838 {
2839 this->simulation_parameters.cls_boundary_conditions.phase_indicator
2840 .at(id)
2841 ->set_time(time);
2842 }
2843 }
2845}
2846
2847
2848template <int dim>
2849void
2851{
2852 // Zero constraints
2853 this->zero_constraints.clear();
2854 this->zero_constraints.reinit(this->locally_owned_dofs,
2855 this->locally_relevant_dofs);
2856
2857 DoFTools::make_hanging_node_constraints(*this->dof_handler,
2858 this->zero_constraints);
2859
2860 for (auto const &[id, type] :
2861 this->simulation_parameters.cls_boundary_conditions.type)
2862 {
2864 {
2865 VectorTools::interpolate_boundary_values(
2866 *this->dof_handler,
2867 id,
2868 Functions::ZeroFunction<dim>(),
2869 this->zero_constraints);
2870 }
2872 {
2873 const auto &periodic_boundary =
2874 this->simulation_parameters.cls_boundary_conditions
2875 .periodic_boundaries.at(id);
2876 DoFTools::make_periodicity_constraints(*this->dof_handler,
2877 id,
2878 periodic_boundary.neighbor_id,
2879 periodic_boundary.direction,
2880 this->zero_constraints);
2881 }
2882 }
2883 this->zero_constraints.close();
2884}
2885
2886
2887template <int dim>
2888void
2890{
2891 {
2892 nonzero_constraints.clear();
2894 this->locally_relevant_dofs);
2895
2896 DoFTools::make_hanging_node_constraints(*this->dof_handler,
2898
2899 for (auto const &[id, type] :
2900 this->simulation_parameters.cls_boundary_conditions.type)
2901 {
2903 {
2904 VectorTools::interpolate_boundary_values(
2905 *this->dof_handler,
2906 id,
2907 *this->simulation_parameters.cls_boundary_conditions
2908 .phase_indicator.at(id),
2910 }
2912 {
2913 const auto &periodic_boundary =
2914 this->simulation_parameters.cls_boundary_conditions
2915 .periodic_boundaries.at(id);
2916 DoFTools::make_periodicity_constraints(
2917 *this->dof_handler,
2918 id,
2919 periodic_boundary.neighbor_id,
2920 periodic_boundary.direction,
2922 }
2923 }
2924 }
2925 nonzero_constraints.close();
2926}
2927
2928
2929template <int dim>
2930void
2932{
2933 VectorTools::interpolate(*this->mapping,
2934 *this->dof_handler,
2935 simulation_parameters.initial_condition->CLS,
2936 this->newton_update);
2937 this->nonzero_constraints.distribute(this->newton_update);
2938 *this->present_solution = this->newton_update;
2939
2940
2941 if (simulation_parameters.initial_condition
2942 ->cls_initial_condition_smoothing ==
2945
2946 else if (simulation_parameters.initial_condition
2947 ->cls_initial_condition_smoothing ==
2950
2952
2953 if (this->simulation_parameters.multiphysics.cls_parameters
2954 .reinitialization_method.sharpening.type ==
2956 {
2957 // Calculate volume and mass
2959 *this->present_solution,
2961 this->simulation_parameters.multiphysics.cls_parameters
2962 .reinitialization_method.sharpening.monitored_fluid);
2963
2965 }
2966
2967 // Solve initial phase indicator gradient and curvature projections if
2968 // solution outputs are requested
2969 if ((simulation_parameters.multiphysics.cls_parameters.surface_tension_force
2970 .enable &&
2971 simulation_parameters.multiphysics.cls_parameters.surface_tension_force
2972 .output_cls_auxiliary_fields) ||
2973 simulation_parameters.multiphysics.cls_parameters.reinitialization_method
2974 .pde_based_interface_reinitialization.enable)
2975 {
2976 this->cls_subequations_interface->set_cls_solution_and_dof_handler(
2977 *this->present_solution, *this->dof_handler);
2978 this->cls_subequations_interface->solve_specific_subequation(
2980 this->cls_subequations_interface->solve_specific_subequation(
2982 }
2983
2984 // Reset PDE-based interface reinitialization output directory;
2985 // if it does not exist, create it.
2986 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
2987 .pde_based_interface_reinitialization.enable &&
2988 simulation_parameters.multiphysics.cls_parameters.reinitialization_method
2989 .pde_based_interface_reinitialization.output_reinitialization_steps)
2990 {
2991 auto mpi_communicator = this->triangulation->get_mpi_communicator();
2992 const std::string folder =
2993 this->simulation_parameters.simulation_control.output_folder +
2994 "/pde-based-reinitialization-steps-output/";
2995
2996 struct stat buffer;
2997
2998 if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
2999 {
3000 if (stat(folder.c_str(), &buffer) != 0)
3001 {
3002 create_output_folder(folder);
3003 }
3004 else
3005 {
3006 delete_output_folder(folder);
3007 create_output_folder(folder);
3008 }
3009 }
3010 }
3011
3012 if (this->simulation_parameters.simulation_control.method !=
3014 this->simulation_parameters.multiphysics.cls_parameters
3015 .surface_tension_force.enable &&
3016 this->simulation_parameters.simulation_control
3017 .adapt_with_capillary_time_step_ratio)
3018 {
3019 // Compute capillary time-step constraint
3020 this->simulation_control->set_capillary_time_step_constraint(
3022 this->simulation_parameters.physical_properties_manager
3023 .field_is_required(field::pressure),
3024 this->simulation_parameters.physical_properties_manager
3025 .field_is_required(field::temperature)));
3026
3027 // Update initial time step with capillary constraint if requested
3028 this->simulation_control
3029 ->limit_initial_time_step_with_capillary_time_step_constraint();
3030 }
3031
3033}
3034
3035
3036template <int dim>
3037void
3039{
3040 TimerOutput::Scope t(this->computing_timer, "Setup ILU");
3041
3042 const unsigned int ilu_fill =
3043 simulation_parameters.linear_solver.at(PhysicsID::CLS).ilu_precond_fill;
3044 const double ilu_atol =
3045 simulation_parameters.linear_solver.at(PhysicsID::CLS).ilu_precond_atol;
3046 const double ilu_rtol =
3047 simulation_parameters.linear_solver.at(PhysicsID::CLS).ilu_precond_rtol;
3048 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
3049 ilu_fill, ilu_atol, ilu_rtol, 0);
3050
3051 ilu_preconditioner = std::make_shared<TrilinosWrappers::PreconditionILU>();
3052
3053 ilu_preconditioner->initialize(this->system_matrix, preconditionerOptions);
3054}
3055
3056template <int dim>
3057void
3059{
3060 TimerOutput::Scope t(this->computing_timer, "Setup AMG");
3061
3062 // Constant modes for the phase indicator scalar field
3063 std::vector<std::vector<bool>> constant_modes;
3064
3065 ComponentMask components(1, true);
3066 constant_modes =
3067 DoFTools::extract_constant_modes(*this->dof_handler, components);
3068
3069 // The conservative level set operator is non-symmetric since the phase
3070 // indicator is advected by the fluid velocity
3071 const bool elliptic = false;
3072 bool higher_order_elements = false;
3073 if (this->fe->degree > 1)
3074 higher_order_elements = true;
3075 const unsigned int n_cycles =
3076 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_n_cycles;
3077 const bool w_cycle =
3078 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_w_cycles;
3079 const double aggregation_threshold =
3080 simulation_parameters.linear_solver.at(PhysicsID::CLS)
3081 .amg_aggregation_threshold;
3082 const unsigned int smoother_sweeps =
3083 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_smoother_sweeps;
3084 const unsigned int smoother_overlap =
3085 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_smoother_overlap;
3086 const bool output_details = false;
3087 const char *smoother_type = "ILU";
3088 const char *coarse_type = "ILU";
3089 TrilinosWrappers::PreconditionAMG::AdditionalData preconditionerOptions(
3090 elliptic,
3091 higher_order_elements,
3092 n_cycles,
3093 w_cycle,
3094 aggregation_threshold,
3095 constant_modes,
3096 smoother_sweeps,
3097 smoother_overlap,
3098 output_details,
3099 smoother_type,
3100 coarse_type);
3101
3102 Teuchos::ParameterList parameter_ml;
3103 std::unique_ptr<Epetra_MultiVector> distributed_constant_modes;
3104 preconditionerOptions.set_parameters(parameter_ml,
3105 distributed_constant_modes,
3106 this->system_matrix);
3107 const double ilu_fill =
3108 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_precond_ilu_fill;
3109 const double ilu_atol =
3110 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_precond_ilu_atol;
3111 const double ilu_rtol =
3112 simulation_parameters.linear_solver.at(PhysicsID::CLS).amg_precond_ilu_rtol;
3113 parameter_ml.set("smoother: ifpack level-of-fill", ilu_fill);
3114 parameter_ml.set("smoother: ifpack absolute threshold", ilu_atol);
3115 parameter_ml.set("smoother: ifpack relative threshold", ilu_rtol);
3116
3117 parameter_ml.set("coarse: ifpack level-of-fill", ilu_fill);
3118 parameter_ml.set("coarse: ifpack absolute threshold", ilu_atol);
3119 parameter_ml.set("coarse: ifpack relative threshold", ilu_rtol);
3120
3121 amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionAMG>();
3122 amg_preconditioner->initialize(this->system_matrix, parameter_ml);
3123}
3124
3125template <int dim>
3126void
3128{
3129 TimerOutput::Scope t(this->computing_timer, "Solve linear system");
3130
3131 auto mpi_communicator = this->triangulation->get_mpi_communicator();
3132
3133 const AffineConstraints<double> &constraints_used = this->zero_constraints;
3134
3135 const double absolute_residual =
3136 simulation_parameters.linear_solver.at(PhysicsID::CLS).minimum_residual;
3137 const double relative_residual =
3138 simulation_parameters.linear_solver.at(PhysicsID::CLS).relative_residual;
3139
3140 const double rescale_metric = this->get_residual_rescale_metric();
3141 const double current_residual = this->system_rhs.l2_norm() / rescale_metric;
3142 const double linear_solver_tolerance =
3143 std::max(relative_residual * current_residual, absolute_residual);
3144 const double non_rescaled_linear_solver_tolerance =
3145 linear_solver_tolerance * rescale_metric;
3146
3147 if (this->simulation_parameters.linear_solver.at(PhysicsID::CLS).verbosity !=
3149 {
3150 this->pcout << " -Tolerance of iterative solver is : "
3151 << linear_solver_tolerance << std::endl;
3152 }
3153
3154 GlobalVectorType completely_distributed_solution(this->locally_owned_dofs,
3155 mpi_communicator);
3156
3157 SolverControl solver_control(
3158 simulation_parameters.linear_solver.at(PhysicsID::CLS).max_iterations,
3159 non_rescaled_linear_solver_tolerance,
3160 true,
3161 true);
3162
3163 TrilinosWrappers::SolverGMRES::AdditionalData solver_parameters(
3164 false,
3165 simulation_parameters.linear_solver.at(PhysicsID::CLS).max_krylov_vectors);
3166
3167 TrilinosWrappers::SolverGMRES solver(solver_control, solver_parameters);
3168
3169 const auto preconditioner_type =
3170 simulation_parameters.linear_solver.at(PhysicsID::CLS).preconditioner;
3171
3172 if (preconditioner_type == Parameters::LinearSolver::PreconditionerType::ilu)
3173 {
3174 setup_ilu();
3175 solver.solve(this->system_matrix,
3176 completely_distributed_solution,
3177 this->system_rhs,
3179 }
3180 else if (preconditioner_type ==
3182 {
3183 setup_amg();
3184 solver.solve(this->system_matrix,
3185 completely_distributed_solution,
3186 this->system_rhs,
3188 }
3189 else
3190 AssertThrow(
3191 false,
3192 ExcMessage(
3193 "This linear solver does not support this preconditioner. Only <ilu> and <amg> preconditioners are supported."));
3194
3195 if (simulation_parameters.linear_solver.at(PhysicsID::CLS).verbosity !=
3197 {
3198 this->pcout << " -Iterative solver took : " << solver_control.last_step()
3199 << " steps to reach a residual norm of "
3200 << solver_control.last_value() / rescale_metric << std::endl;
3201 }
3202
3203 // Update constraints and newton vectors
3204 constraints_used.distribute(completely_distributed_solution);
3205 newton_update = completely_distributed_solution;
3206}
3207
3208// This function is explained in detail in step-41 of deal.II tutorials
3209template <int dim>
3210void
3212 GlobalVectorType &solution)
3213{
3214 // This is a penalty parameter for limiting the phase indicator
3215 // in the range of [0,1]. According to step 41, this parameter depends
3216 // on the problem itself and needs to be chosen large enough (for example,
3217 // there is no convergence using the penalty_parameter = 1)
3218 const double penalty_parameter = 100;
3219
3221 this->triangulation->get_mpi_communicator());
3222
3223 nodal_phase_indicator_owned = solution;
3224
3228
3229 this->bounding_constraints.clear();
3230
3231 std::vector<bool> dof_touched(this->dof_handler->n_dofs(), false);
3232
3233 for (const auto &cell : this->dof_handler->active_cell_iterators())
3234 {
3235 if (cell->is_locally_owned())
3236 {
3237 for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell;
3238 ++v)
3239 {
3240 Assert(this->dof_handler->get_fe().dofs_per_cell ==
3241 GeometryInfo<dim>::vertices_per_cell,
3242 ExcNotImplemented());
3243 const unsigned int dof_index = cell->vertex_dof_index(v, 0);
3244 if (this->locally_owned_dofs.is_element(dof_index))
3245 {
3246 const double solution_value =
3247 nodal_phase_indicator_owned(dof_index);
3248 if (lambda(dof_index) +
3249 penalty_parameter *
3250 mass_matrix_phase_indicator(dof_index, dof_index) *
3251 (solution_value - this->phase_upper_bound) >
3252 0)
3253 {
3254 this->bounding_constraints.add_line(dof_index);
3255 this->bounding_constraints.set_inhomogeneity(
3256 dof_index, this->phase_upper_bound);
3257 nodal_phase_indicator_owned(dof_index) =
3258 this->phase_upper_bound;
3259 lambda(dof_index) = 0;
3260 }
3261 else if (lambda(dof_index) +
3262 penalty_parameter *
3264 dof_index) *
3265 (solution_value - this->phase_lower_bound) <
3266 0)
3267 {
3268 this->bounding_constraints.add_line(dof_index);
3269 this->bounding_constraints.set_inhomogeneity(
3270 dof_index, this->phase_lower_bound);
3271 nodal_phase_indicator_owned(dof_index) =
3272 this->phase_lower_bound;
3273 lambda(dof_index) = 0;
3274 }
3275 }
3276 }
3277 }
3278 }
3279 solution = nodal_phase_indicator_owned;
3280 this->bounding_constraints.close();
3281}
3282
3283
3284template <int dim>
3285void
3287 GlobalVectorType &solution,
3288 const double sharpening_threshold)
3289{
3290 const double interface_sharpness =
3291 this->simulation_parameters.multiphysics.cls_parameters
3292 .reinitialization_method.sharpening.interface_sharpness;
3293
3294 FEValues<dim> fe_values_cls(*this->mapping,
3295 *this->fe,
3296 *this->cell_quadrature,
3297 update_values | update_JxW_values);
3298
3299 const unsigned int dofs_per_cell = this->fe->dofs_per_cell;
3300 const unsigned int n_q_points = this->cell_quadrature->size();
3301 FullMatrix<double> local_matrix_phase_indicator(dofs_per_cell, dofs_per_cell);
3302 Vector<double> local_rhs_phase_indicator(dofs_per_cell);
3303 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
3304 std::vector<double> phi_phase(dofs_per_cell);
3305
3306 std::vector<double> phase_values(n_q_points);
3307
3310
3311 for (const auto &cell : this->dof_handler->active_cell_iterators())
3312 {
3313 if (cell->is_locally_owned())
3314 {
3315 fe_values_cls.reinit(cell);
3316
3317 local_matrix_phase_indicator = 0;
3318 local_rhs_phase_indicator = 0;
3319
3320 fe_values_cls.get_function_values(solution, phase_values);
3321
3322 for (unsigned int q = 0; q < n_q_points; ++q)
3323 {
3324 auto phase_value = phase_values[q];
3325 // phase_value = std::min(std::max(phase_value, 0.), 1.);
3326
3327 for (unsigned int k = 0; k < dofs_per_cell; ++k)
3328 {
3329 phi_phase[k] = fe_values_cls.shape_value(k, q);
3330 }
3331 for (unsigned int i = 0; i < dofs_per_cell; ++i)
3332 {
3333 // Matrix assembly
3334 for (unsigned int j = 0; j < dofs_per_cell; ++j)
3335 {
3336 local_matrix_phase_indicator(i, j) +=
3337 (phi_phase[j] * phi_phase[i]) * fe_values_cls.JxW(q);
3338 }
3339
3340 // $$ (if 0 <= \phi <= c) {\Phi = c ^ (1 - \alpha) * (\phi
3341 // ^ \alpha)}$$
3342 // $$ (if c < \phi <= 1) {\Phi = 1 - (1 - c) ^ (1 -
3343 // \alpha)
3344 // * (1 - \phi) ^ \alpha}
3345 if (phase_value >= 0 && phase_value <= sharpening_threshold)
3346 local_rhs_phase_indicator(i) +=
3347 std::pow(sharpening_threshold,
3348 (1. - interface_sharpness)) *
3349 std::pow(phase_value, interface_sharpness) *
3350 phi_phase[i] * fe_values_cls.JxW(q);
3351 else
3352 {
3353 local_rhs_phase_indicator(i) +=
3354 (1 -
3355 std::pow((1. - sharpening_threshold),
3356 (1. - interface_sharpness)) *
3357 std::pow((1. - phase_value), interface_sharpness)) *
3358 phi_phase[i] * fe_values_cls.JxW(q);
3359 }
3360 }
3361 }
3362
3363 cell->get_dof_indices(local_dof_indices);
3364 this->nonzero_constraints.distribute_local_to_global(
3365 local_matrix_phase_indicator,
3366 local_rhs_phase_indicator,
3367 local_dof_indices,
3370 }
3371 }
3372
3373 system_matrix_phase_indicator.compress(VectorOperation::add);
3374 system_rhs_phase_indicator.compress(VectorOperation::add);
3375}
3376
3377template <int dim>
3378void
3380 GlobalVectorType &solution)
3381{
3382 // Solve the L2 projection system
3383 const double linear_solver_tolerance = 1e-15;
3384
3385 if (this->simulation_parameters.multiphysics.cls_parameters
3386 .reinitialization_method.verbosity ==
3388 {
3389 this->pcout << " -Tolerance of iterative solver is : "
3390 << linear_solver_tolerance << std::endl;
3391 }
3392
3393 GlobalVectorType completely_distributed_phase_indicator_solution(
3394 this->locally_owned_dofs, triangulation->get_mpi_communicator());
3395
3396
3397 SolverControl solver_control(
3398 this->simulation_parameters.linear_solver.at(PhysicsID::CLS).max_iterations,
3399 linear_solver_tolerance,
3400 true,
3401 true);
3402
3403 TrilinosWrappers::SolverCG solver(solver_control);
3404
3405 //**********************************************
3406 // Trillinos Wrapper ILU Preconditioner
3407 //*********************************************
3408 const unsigned int ilu_fill =
3409 this->simulation_parameters.linear_solver.at(PhysicsID::CLS)
3410 .ilu_precond_fill;
3411 const double ilu_atol =
3412 this->simulation_parameters.linear_solver.at(PhysicsID::CLS)
3413 .ilu_precond_atol;
3414 const double ilu_rtol =
3415 this->simulation_parameters.linear_solver.at(PhysicsID::CLS)
3416 .ilu_precond_rtol;
3417
3418 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
3419 ilu_fill, ilu_atol, ilu_rtol, 0);
3420
3421 std::shared_ptr<TrilinosWrappers::PreconditionILU> ilu_preconditioner =
3422 std::make_shared<TrilinosWrappers::PreconditionILU>();
3423
3425 preconditionerOptions);
3426
3427 solver.solve(system_matrix_phase_indicator,
3428 completely_distributed_phase_indicator_solution,
3431
3432 if (this->simulation_parameters.multiphysics.cls_parameters
3433 .reinitialization_method.verbosity ==
3435 {
3436 this->pcout << " -Iterative solver took : " << solver_control.last_step()
3437 << " steps " << std::endl;
3438 }
3439
3440 this->nonzero_constraints.distribute(
3441 completely_distributed_phase_indicator_solution);
3442 solution = completely_distributed_phase_indicator_solution;
3443}
3444
3445template <int dim>
3446void
3448 TrilinosWrappers::SparseMatrix &mass_matrix)
3449{
3450 QGauss<dim> quadrature_formula(this->cell_quadrature->size());
3451
3452 FEValues<dim> fe_values_cls(*this->fe,
3453 quadrature_formula,
3454 update_values | update_JxW_values);
3455
3456
3457 const unsigned int dofs_per_cell = this->fe->dofs_per_cell;
3458 const unsigned int n_q_points = quadrature_formula.size();
3459 FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell);
3460 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
3461 for (const auto &cell : this->dof_handler->active_cell_iterators())
3462 {
3463 if (cell->is_locally_owned())
3464 {
3465 fe_values_cls.reinit(cell);
3466 cell_matrix = 0;
3467 for (unsigned int q = 0; q < n_q_points; ++q)
3468 for (unsigned int i = 0; i < dofs_per_cell; ++i)
3469 cell_matrix(i, i) +=
3470 (fe_values_cls.shape_value(i, q) *
3471 fe_values_cls.shape_value(i, q) * fe_values_cls.JxW(q));
3472 cell->get_dof_indices(local_dof_indices);
3473 this->nonzero_constraints.distribute_local_to_global(
3474 cell_matrix, local_dof_indices, mass_matrix);
3475 }
3476 }
3477}
3478
3479
3480template <int dim>
3481void
3483 const GlobalVectorType &original_solution,
3485{
3486 // Initializations
3487 auto mpi_communicator = this->triangulation->get_mpi_communicator();
3488 GlobalVectorType filtered_solution_owned(this->locally_owned_dofs,
3489 mpi_communicator);
3490 filtered_solution_owned = original_solution;
3491 filtered_solution.reinit(original_solution);
3492
3493 // Create filter object
3495 this->simulation_parameters.multiphysics.cls_parameters.phase_filter);
3496
3497 // Apply filter to the solution
3498 for (auto p : this->locally_owned_dofs)
3499 {
3500 filtered_solution_owned[p] =
3501 filter->filter_phase(filtered_solution_owned[p]);
3502 }
3503 filtered_solution = filtered_solution_owned;
3504
3505 if (this->simulation_parameters.multiphysics.cls_parameters.phase_filter
3506 .verbosity == Parameters::Verbosity::verbose)
3507 {
3508 this->pcout << "Filtered phase values: " << std::endl;
3509 for (const double filtered_phase : filtered_solution)
3510 {
3511 this->pcout << filtered_phase << std::endl;
3512 }
3513 }
3514}
3515
3516template <int dim>
3517void
3519{
3520 TimerOutput::Scope t(this->computing_timer, "PDE-based reinitialization");
3521
3522 // Reinitialize previous CLS solution
3523 // (this is only coherent with BDF1 and BDF2)
3524 if (this->simulation_parameters.multiphysics.cls_parameters
3525 .reinitialization_method.frequency > 1)
3526 {
3527 auto mpi_communicator = this->triangulation->get_mpi_communicator();
3528
3529 GlobalVectorType previous_reinitialized_solution_owned(
3530 this->locally_owned_dofs, mpi_communicator);
3531
3532 // Set CLS information in the CLS subequations interface
3533 this->cls_subequations_interface->set_cls_solution_and_dof_handler(
3534 (*this->previous_solutions)[0], *this->dof_handler);
3535
3536 // Solve phase gradient projection followed by PDE-based interface
3537 // reinitialization steps
3538 this->cls_subequations_interface->solve_specific_subequation(
3540 this->cls_subequations_interface->solve_specific_subequation(
3542
3543 // Overwrite CLS previous solution with the reinitialized result
3544 FETools::interpolate(
3545 this->cls_subequations_interface->get_dof_handler(
3547 this->cls_subequations_interface->get_solution(
3549 *this->dof_handler,
3550 this->nonzero_constraints,
3551 previous_reinitialized_solution_owned);
3552 (*this->previous_solutions)[0] = previous_reinitialized_solution_owned;
3553 }
3554
3555 // Set CLS information in the CLS subequations interface
3556 this->cls_subequations_interface->set_cls_solution_and_dof_handler(
3557 *this->present_solution, *this->dof_handler);
3558
3559 // Solve phase gradient projection followed by PDE-based interface
3560 // reinitialization steps
3561 this->cls_subequations_interface->solve_specific_subequation(
3563 this->cls_subequations_interface->solve_specific_subequation(
3565
3566 // Overwrite the CLS solution with the PDE-based interface reinitialization
3567 FETools::interpolate(
3568 this->cls_subequations_interface->get_dof_handler(
3570 this->cls_subequations_interface->get_solution(
3572 *this->dof_handler,
3573 this->nonzero_constraints,
3574 this->local_evaluation_point);
3576}
3577
3578template <int dim>
3579void
3581 const GlobalVectorType &solution,
3582 GlobalVectorType &level_set_solution)
3583{
3584 auto mpi_communicator = this->triangulation->get_mpi_communicator();
3585
3586 GlobalVectorType level_set_owned(this->locally_owned_dofs, mpi_communicator);
3587
3588 for (auto p : this->locally_owned_dofs)
3589 {
3590 const double phase = solution[p];
3591 level_set_owned[p] = (-2.0 * phase + 1.0);
3592 }
3593
3594 this->nonzero_constraints.distribute(level_set_owned);
3595
3596 level_set_solution = level_set_owned;
3597}
3598
3599template <int dim>
3600void
3602 const GlobalVectorType &level_set_solution,
3603 GlobalVectorType &phase_indicator_solution)
3604{
3605 auto mpi_communicator = this->triangulation->get_mpi_communicator();
3606
3607 GlobalVectorType solution_owned(this->locally_owned_dofs, mpi_communicator);
3608
3609 for (auto p : this->locally_owned_dofs)
3610 {
3611 const double signed_dist = level_set_solution[p];
3612 solution_owned[p] =
3613 signed_distance_transformation->transform_signed_distance(signed_dist);
3614 }
3615 this->nonzero_constraints.distribute(solution_owned);
3616
3617 phase_indicator_solution = solution_owned;
3618}
3619
3620template <int dim>
3621void
3623{
3624 TimerOutput::Scope t(this->computing_timer, "Geometric reinitialization");
3625
3626 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
3627 .verbosity != Parameters::Verbosity::quiet)
3628 {
3629 announce_string(this->pcout, "CLS geometric interface reinitialization");
3630 this->pcout << "In redistanciation of the previous solution ..."
3631 << std::endl;
3632 }
3633
3634 auto mpi_communicator = this->triangulation->get_mpi_communicator();
3635
3636 signed_distance_solver->setup_dofs();
3637
3638 GlobalVectorType previous_level_set(locally_owned_dofs,
3640 mpi_communicator);
3641
3642 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
3643 .frequency != 1)
3644 {
3645 signed_distance_solver->set_level_set_from_background_mesh(
3646 *dof_handler, (*this->previous_solutions)[0]);
3647
3648 signed_distance_solver->solve();
3649
3650 GlobalVectorType previous_level_set_owned(this->locally_owned_dofs,
3651 mpi_communicator);
3652
3653 FETools::interpolate(signed_distance_solver->dof_handler,
3654 signed_distance_solver->get_signed_distance(),
3655 *this->dof_handler,
3656 this->nonzero_constraints,
3657 previous_level_set_owned);
3658
3659
3660 previous_level_set = previous_level_set_owned;
3661
3662 compute_phase_indicator_from_level_set(previous_level_set,
3663 (*this->previous_solutions)[0]);
3664 }
3665
3666 if (simulation_parameters.multiphysics.cls_parameters.reinitialization_method
3667 .verbosity != Parameters::Verbosity::quiet)
3668 this->pcout << "In redistanciation of the present solution ..."
3669 << std::endl;
3670
3671 signed_distance_solver->set_level_set_from_background_mesh(
3672 *dof_handler, *this->present_solution);
3673
3674 signed_distance_solver->solve();
3675
3676 GlobalVectorType level_set_owned(this->locally_owned_dofs, mpi_communicator);
3677
3678 FETools::interpolate(signed_distance_solver->dof_handler,
3679 signed_distance_solver->get_signed_distance(),
3680 *this->dof_handler,
3681 this->nonzero_constraints,
3682 level_set_owned);
3683
3684
3685 this->level_set = level_set_owned;
3686
3688 *this->present_solution);
3689}
3690
3691
3692template class ConservativeLevelSet<2>;
3693template class ConservativeLevelSet<3>;
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 assembles the transient time arising from BDF time integration for the CLS equation....
Class that assembles the core of the CLS solver. According to the following weak form: with an SUPG ...
Assemble the Discontinuity-Capturing Directional Dissipation (DCDD) stabilization term for the CLS ph...
Class that assembles the core (cells) of the CLS equation for DG elements. This class assembles the w...
Store the information required by the assembly procedure for a CLS free surface equation....
void reinit(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType &current_solution, const std::vector< VectorType > &previous_solutions)
Reinitialize the content of the scratch.
void reinit_velocity(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType &current_solution, const std::vector< VectorType > &previous_solutions, const Parameters::ALE< dim > &ale)
Reinitialize the velocity, calculated by the Fluid Dynamics.
static std::shared_ptr< ConservativeLevelSetFilterBase > model_cast(const Parameters::CLS_PhaseFilter &phase_filter_parameters)
Instantiate and return a pointer to a ConservativeLevelSetFilterBase object by casting it to the prop...
Definition cls_filter.cc:7
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
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
void pre_mesh_adaptation() override
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
Definition cls.cc:2466
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
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
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
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
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
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
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
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
std::shared_ptr< Quadrature< dim > > cell_quadrature
Definition cls.h:792
Solver to compute the signed distance from a given level of a level-set field. It is based on the met...
PhysicsSolverStrategy< GlobalVectorType > * physics_solving_strategy
static std::shared_ptr< SignedDistanceTransformationBase > model_cast(const Parameters::CLS_GeometricInterfaceReinitialization &geometric_redistanciation_parameters)
Instantiate and return a pointer to a SignedDistanceTransformationBase object by casting it to the pr...
Responsible for storing the information calculated using the discontinuous galerkin (DG) assembly of ...
Definition copy_data.h:127
std::vector< CopyDataFace > face_data
Definition copy_data.h:149
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Definition copy_data.h:67
Vector< double > local_rhs
Definition copy_data.h:105
FullMatrix< double > local_matrix
Definition copy_data.h:104
void reset()
Resets the cell_matrix, cell_rhs, strong_residual and strong_jacobian to zero.
Definition copy_data.h:92
std::vector< types::global_dof_index > local_dof_indices
Definition copy_data.h:106
@ curvature_projection
CLS curvature L2 projection.
@ pde_based_interface_reinitialization
CLS PDE-based interface reinitialization.
@ phase_gradient_projection
CLS phase indicator gradient L2 projection.
double compute_cell_measure_with_JxW(const std::vector< double > &JxW_values)
Computes the area (2D) or volume (3D) of the cell by integrating 1 over the cell, by summing JxW valu...
Definition utilities.h:1017
TableHandler make_table_scalars_tensors(const std::vector< T > &independent_values, const std::string &independent_column_name, const std::vector< Tensor< 1, dim > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation=false)
Generate a table from a vector of scalars (independent variable) and a vector of Tensor<1,...
Definition utilities.cc:59
void create_output_folder(const std::string &dirname)
Creates the simulation output folder.
Definition utilities.cc:401
TableHandler make_table_scalars_vectors(const std::vector< T > &independent_values, const std::string &independent_column_name, const std::vector< std::vector< double > > &dependent_vector, const std::vector< std::string > &dependent_column_names, const unsigned int display_precision, const bool display_scientific_notation=false)
Generate a table from a vector of scalars (independent variable) and a vector of vectors of scalars (...
Definition utilities.cc:24
void delete_output_folder(const std::string &dirname)
Delete the output folder and its content.
Definition utilities.cc:407
void serialize_tables_vector(const std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Serializes all the TableHandler objects in table_output_structs.
Definition utilities.h:602
void announce_string(const ConditionalOStream &pcout, const std::string &expression, const char delimiter='-')
Prints a string and then adds a line above and below made with dashes containing as many dashes as th...
Definition utilities.h:500
double compute_cell_diameter(const double cell_measure, const unsigned int fe_degree)
Computes equivalent cell diameter by comparing the area to a disk (2D) or the volume to a sphere (3D)...
Definition utilities.h:989
void deserialize_tables_vector(std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Deserializes all the TableHandler objects in table_output_structs.
Definition utilities.h:624
Variable
Solution fields of the different physics that are used as an indicator for multiple purposes (e....
@ phase
Phase indicator scalar field from CLS.
@ velocity
Velocity vector field from fluid dynamics.
@ pressure
Pressure scalar field from fluid dynamics.
PhysicsID
Unique identifiers for each physics module in Lethe.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ CLS
@ heat_transfer
Heat transfer (Temperature).
void postprocess_isocontour_bounding_values(const Variable &variable, const std::multimap< Variable, std::pair< unsigned int, typename Parameters::PostProcessing< dim >::IsocontourBoundingBoxes::Isocontour > > &ids_and_isocontours_per_variable, const DoFHandler< dim > &dof_handler, const VectorType &solution_vector, const double current_time, const Parameters::Verbosity &verbosity, const ConditionalOStream &pcout, std::vector< TableHandler > &isocontour_bounding_values_tables)
Identifies the bounding values of requested isocontours using InterfaceTools::compute_isocontour_boun...
void write_isocontour_bounding_values_tables(const MPI_Comm &mpi_communicator, const std::string &output_folder, const Variable &variable, const std::multimap< Variable, std::pair< unsigned int, typename Parameters::PostProcessing< dim >::IsocontourBoundingBoxes::Isocontour > > &ids_and_isocontours_per_variable, const std::vector< TableHandler > &isocontour_bounding_values_tables)
Writes the bounding values tables of the specified isocontours in their respective output files.
std::pair< Point< dim >, Tensor< 1, dim > > integrate_barycenter(const DoFHandler< dim > &dof_handler, const FiniteElement< dim > &fe, const VectorType &level_set_vector_relevant_copy, const Mapping< dim > &mapping_velocity, const DoFHandler< dim > &dof_handler_velocity, const FiniteElement< dim > &fe_velocity, const VectorType &velocity_vector)
Integrate the barycenter position and velocity of the volume enclosed by the zero-level of a level se...
std::pair< double, double > integrate_volume_and_surface(const DoFHandler< dim > &dof_handler, const FiniteElement< dim > &fe, const VectorType &level_set_vector_relevant_copy)
Integrate the surface area of a given level of a level set field and the volume enclosed by it....
FluidIndicator
Class to account for different fluid indicators. This is used for multiphase simulations in PostProce...
Definition parameters.h:75
void set_field_vector(const field &id, const std::vector< double > &data, std::map< field, std::vector< double > > &fields)
std::pair< double, double > calculate_L2_error(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Function< dim > *exact_solution, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculates the L2 norm of the error on velocity and pressure.
Struct containing information about the solution output. It is used to pass all the information requi...
@ ilu
Incomplete LU Factorization.
GlobalVectorType VectorType
bool time_stepping_is_bdf(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the bdf family.
bool time_stepping_is_sdirk(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the sdirk family.
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17
dealii::TrilinosWrappers::MPI::BlockVector GlobalBlockVectorType
Definition vector.h:18