14#include <deal.II/base/exceptions.h>
16#include <deal.II/dofs/dof_renumbering.h>
17#include <deal.II/dofs/dof_tools.h>
19#include <deal.II/grid/grid_tools.h>
21#include <deal.II/lac/precondition.h>
22#include <deal.II/lac/solver_bicgstab.h>
23#include <deal.II/lac/solver_control.h>
24#include <deal.II/lac/solver_gmres.h>
25#include <deal.II/lac/sparse_matrix_tools.h>
26#include <deal.II/lac/vector.h>
28#include <deal.II/multigrid/mg_coarse.h>
29#include <deal.II/multigrid/mg_constrained_dofs.h>
30#include <deal.II/multigrid/mg_matrix.h>
31#include <deal.II/multigrid/mg_smoother.h>
32#include <deal.II/multigrid/mg_tools.h>
33#include <deal.II/multigrid/mg_transfer_global_coarsening.h>
34#include <deal.II/multigrid/mg_transfer_matrix_free.h>
35#if DEAL_II_VERSION_GTE(9, 8, 0)
36# include <deal.II/multigrid/mg_transfer_matrix_free.templates.h>
38# include <deal.II/multigrid/mg_transfer_global_coarsening.templates.h>
42#include <deal.II/lac/trilinos_solver.h>
44#include <deal.II/multigrid/multigrid.h>
46#include <deal.II/numerics/vector_tools.h>
54template <
typename VectorType>
62 :
comm(MPI_COMM_WORLD)
63 ,
pcout(std::cout, Utilities::MPI::this_mpi_process(
comm) == 0)
64 ,
timer(
pcout, TimerOutput::never, TimerOutput::wall_times)
110template <
typename VectorType,
typename VectorTypePrecondition>
119 template <
typename PreconditionType>
122 const VectorTypePrecondition &src) {
123 preconditioner->vmult(dst, src);
136 if constexpr (std::is_same_v<VectorType, VectorTypePrecondition>)
157 template <
typename U = VectorTypePrecondition>
158 requires(!std::is_same_v<VectorType, U>)
167 const std::function<void(VectorTypePrecondition &,
168 const VectorTypePrecondition &)>
172 mutable VectorTypePrecondition
src_;
175 mutable VectorTypePrecondition
dst_;
181template <
typename VectorType>
214template <
typename VectorType>
229 using Number =
typename VectorType::value_type;
242 typename GlobalSparseMatrixType,
243 typename GlobalSparsityPattern,
247 const DoFHandler<dim> &dof_handler,
248 const GlobalSparseMatrixType &global_sparse_matrix,
249 const GlobalSparsityPattern &global_sparsity_pattern,
250 const AffineConstraints<Number> &constraints,
251 const std::shared_ptr<const Utilities::MPI::Partitioner> &partitioner,
252 const unsigned int mg_level)
254 this->
timer.enter_subsection(
"asm::indices");
256 std::vector<std::vector<types::global_dof_index>>
patches;
258 const auto add_indices = [&](
const auto &local_dof_indices) {
259 std::vector<types::global_dof_index> local_dof_indices_temp;
261 for (
const auto i : local_dof_indices)
262 if (!constraints.is_constrained(i))
263 local_dof_indices_temp.emplace_back(i);
265 if (!local_dof_indices_temp.empty())
266 patches.push_back(local_dof_indices_temp);
269 if (mg_level == numbers::invalid_unsigned_int)
270 for (
const auto &cell : dof_handler.active_cell_iterators())
272 if (cell->is_locally_owned() ==
false)
275 std::vector<types::global_dof_index> local_dof_indices(
276 cell->get_fe().n_dofs_per_cell());
277 cell->get_dof_indices(local_dof_indices);
279 add_indices(local_dof_indices);
282 for (
const auto &cell : dof_handler.mg_cell_iterators_on_level(mg_level))
284 if (cell->is_locally_owned_on_level() ==
false)
287 std::vector<types::global_dof_index> local_dof_indices(
288 cell->get_fe().n_dofs_per_cell());
289 cell->get_mg_dof_indices(local_dof_indices);
291 add_indices(local_dof_indices);
294 const IndexSet locally_owned_dofs =
295 (mg_level == numbers::invalid_unsigned_int) ?
296 dof_handler.locally_owned_dofs() :
297 dof_handler.locally_owned_mg_dofs(mg_level);
299 IndexSet ghost_dofs(locally_owned_dofs.size());
300 for (
const auto &indices :
patches)
301 ghost_dofs.add_indices(indices.begin(), indices.end());
303 std::shared_ptr<const Utilities::MPI::Partitioner> partition =
304 std::make_shared<Utilities::MPI::Partitioner>(locally_owned_dofs,
308 if (dealii::internal::is_partitioner_contained(partition, partitioner))
310 partition = partitioner;
319 this->patches.resize(
patches.size());
320 for (
unsigned int c = 0; c <
patches.size(); ++c)
322 this->patches[c].resize(0);
323 this->patches[c].reserve(
patches[c].size());
325 for (
const auto &i :
patches[c])
326 this->patches[c].emplace_back(partition->global_to_local(i));
329 this->
timer.leave_subsection(
"asm::indices");
330 this->
timer.enter_subsection(
"asm::restrict");
332 std::vector<FullMatrix<Number>>
blocks;
338#pragma GCC diagnostic push
339#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
340 SparseMatrixTools::restrict_to_full_matrices(global_sparse_matrix,
341 global_sparsity_pattern,
344#pragma GCC diagnostic pop
346 this->
timer.leave_subsection(
"asm::restrict");
347 this->
timer.enter_subsection(
"asm::invert");
349 this->blocks.resize(
blocks.size());
351 for (
unsigned int b = 0; b <
blocks.size(); ++b)
355 this->blocks[b] =
blocks[b];
356 this->blocks[b].compute_lu_factorization();
359 this->
timer.leave_subsection(
"asm::invert");
363 this->
timer.enter_subsection(
"asm::weight");
364 Vector<Number> vector_weights;
367 for (
const auto &patch :
patches)
369 const unsigned int dofs_per_cell = patch.size();
370 vector_weights.reinit(dofs_per_cell);
372 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
373 vector_weights[i] = 1.0;
375 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
376 weights[patch[i]] += vector_weights[i];
379 weights.compress(VectorOperation::add);
385 this->
timer.leave_subsection(
"asm::weight");
398 this->
timer.enter_subsection(
"asm::vmult");
406 src_ptr.update_ghost_values();
408 Vector<Number> vector_src, vector_dst, vector_weights;
410 for (
unsigned int c = 0; c <
patches.size(); ++c)
412 const unsigned int dofs_per_cell =
patches[c].size();
414 vector_src.reinit(dofs_per_cell);
415 vector_dst.reinit(dofs_per_cell);
417 vector_weights.reinit(dofs_per_cell);
419 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
420 vector_src[i] = src_ptr.local_element(
patches[c][i]);
423 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
428 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
429 vector_src[i] *= vector_weights[i];
431 blocks[c].solve(vector_src);
432 vector_dst = vector_src;
436 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
437 vector_dst[i] *= vector_weights[i];
439 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
440 dst_ptr.local_element(
patches[c][i]) += vector_dst[i];
443 src_ptr.zero_out_ghost_values();
444 dst_ptr.compress(VectorOperation::add);
449 this->
timer.leave_subsection(
"asm::vmult");
454 std::vector<std::vector<unsigned int>>
patches;
457 std::vector<LAPACKFullMatrix<Number>>
blocks;
480 template <
class VectorType,
class PreconditionerType>
504 initialize(
const PreconditionerType &precondition);
519 const PreconditionerType,
526 template <
class VectorType,
class PreconditionerType>
534 template <
class VectorType,
class PreconditionerType>
542 template <
class VectorType,
class PreconditionerType>
545 const PreconditionerType &preconditioner_)
552 template <
class VectorType,
class PreconditionerType>
561 template <
class VectorType,
class PreconditionerType>
576template <
int dim,
typename Number>
578 :
public MGTransferBase<LinearAlgebra::distributed::Vector<Number>>
581 using VectorType = LinearAlgebra::distributed::Vector<Number>;
589 build(
const MGLevelObject<MGTwoLevelTransfer<dim, VectorType>> &transfers,
590 const DoFHandler<dim> &dof_handler,
591 const MGConstrainedDoFs &mg_constrained_dofs,
592 const std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
593 &external_partitioners_in)
595 if (transfers.min_level() != transfers.max_level())
597 this->
n_gc_levels = transfers.max_level() - transfers.min_level();
599 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
600 external_partitioners;
602 for (
unsigned int l = transfers.min_level(); l <= transfers.max_level();
604 external_partitioners.emplace_back(external_partitioners_in[l]);
606 gc.initialize_two_level_transfers(transfers);
607 gc.build(external_partitioners);
610 ls.initialize_constraints(mg_constrained_dofs);
612 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
613 external_partitioners(
min_h_level + external_partitioners_in.size() -
616 for (
unsigned int i =
n_gc_levels; i < external_partitioners_in.size(); ++i)
618 external_partitioners_in[i];
620 ls.build(dof_handler, external_partitioners);
623 template <
class InVector,
int spacedim>
626 MGLevelObject<VectorType> &dst,
627 const InVector &src)
const
631 gc.copy_to_mg(dof_handler, dst, src);
640 for (
unsigned int l = dst.min_level(); l <= dst.max_level(); ++l)
649 ls.copy_to_mg(dof_handler, dst_ls, src);
652 gc.copy_to_mg(dof_handler, dst_gc, dst_ls[dst_ls.min_level()]);
654 for (
unsigned int l = dst.min_level(); l <= dst.max_level(); ++l)
661 template <
class OutVector,
int spacedim>
665 const MGLevelObject<VectorType> &src)
const
669 gc.copy_from_mg(dof_handler, dst, src);
676 for (
unsigned int l =
n_gc_levels; l <= src.max_level(); ++l)
679 ls.copy_from_mg(dof_handler, dst, src_ls);
682 template <
typename InVectorType>
685 MGLevelObject<VectorType> &dst,
686 const InVectorType &src)
const
690 gc.interpolate_to_mg(dof_handler, dst, src);
699 for (
unsigned int l = dst.min_level(); l <= dst.max_level(); ++l)
708 ls.interpolate_to_mg(dof_handler, dst_ls, src);
711 gc.interpolate_to_mg(dof_handler, dst_gc, dst_ls[dst_ls.min_level()]);
713 for (
unsigned int l = dst.min_level(); l <= dst.max_level(); ++l)
726 gc.prolongate(to_level, dst, src);
737 gc.restrict_and_add(from_level, dst, src);
746 MGTransferMatrixFree<dim, Number>
ls;
747#if DEAL_II_VERSION_GTE(9, 8, 0)
748 MGTransferMatrixFree<dim, Number>
gc;
750 MGTransferGlobalCoarsening<dim, VectorType>
gc;
759 :
pcout(std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
773 this->use_manifold_for_normal =
false;
778 this->dof_handler.get_fe().degree >=
780 .mg_p_min_coarsening_degree,
782 "The prescribed minimum polynomial degree for the p-multigrid needs to be lower than the velocity/pressure interpolation order."));
788 const std::shared_ptr<Mapping<dim>> &mapping,
789 const std::shared_ptr<Quadrature<dim>> &cell_quadrature,
790 const std::shared_ptr<Function<dim>> &forcing_function,
791 const std::shared_ptr<SimulationControl> &simulation_control,
792 const std::shared_ptr<PhysicalPropertiesManager> &physical_properties_manager,
793 const std::shared_ptr<FESystem<dim>> &fe)
795 AssertThrow(*cell_quadrature ==
796 QGauss<dim>(this->
dof_handler.get_fe().degree + 1),
797 ExcNotImplemented());
802 const auto &triangulation =
dof_handler.get_triangulation();
805 const unsigned int n_h_levels = triangulation.n_global_levels();
806 unsigned int min_h_level = 0;
807 const unsigned int max_h_level = n_h_levels - 1;
820 int mg_level_min_cells =
825 std::vector<unsigned int> n_cells_on_levels(
826 triangulation.n_global_levels(), 0);
828 for (
unsigned int l = 0; l < triangulation.n_levels(); ++l)
829 for (
const auto &cell : triangulation.cell_iterators_on_level(l))
830 if (cell->is_locally_owned_on_level())
831 n_cells_on_levels[l]++;
833 Utilities::MPI::sum(n_cells_on_levels,
837 if (mg_min_level != -1)
840 mg_min_level <=
static_cast<int>(MGTools::max_level_for_coarse_mesh(
842 ExcMessage(std::string(
843 "The maximum level allowed for the coarse mesh (mg min level) is: " +
845 MGTools::max_level_for_coarse_mesh(triangulation)) +
848 min_h_level = mg_min_level;
850 else if (mg_level_min_cells != -1)
853 mg_level_min_cells <=
855 n_cells_on_levels[MGTools::max_level_for_coarse_mesh(
858 "The mg level min cells specified are larger than the cells of the finest mg level."));
860 for (
unsigned int level = min_h_level; level <= max_h_level; ++level)
862 const int n_cells_on_level =
863 static_cast<int>(n_cells_on_levels[level]);
864 if (n_cells_on_level >= mg_level_min_cells)
873 const auto mg_coarsening_type =
877 auto polynomial_coarsening_sequence =
878 MGTransferGlobalCoarseningTools::create_polynomial_coarsening_sequence(
880 this->simulation_parameters.linear_solver
882 .mg_p_coarsening_type);
888 .mg_p_min_coarsening_degree;
890 std::erase(polynomial_coarsening_sequence, p);
892 std::vector<std::pair<unsigned int, unsigned int>> levels;
894 if (mg_coarsening_type ==
898 for (
const auto i : polynomial_coarsening_sequence)
899 levels.emplace_back(min_h_level, i);
902 for (
unsigned int i = min_h_level + 1; i <= max_h_level; ++i)
903 levels.emplace_back(i, polynomial_coarsening_sequence.back());
905 else if (mg_coarsening_type ==
908 AssertThrow(
false, ExcNotImplemented());
910 else if (mg_coarsening_type ==
913 AssertThrow(
false, ExcNotImplemented());
915 else if (mg_coarsening_type ==
919 for (
unsigned int i = min_h_level; i <= max_h_level; ++i)
920 levels.emplace_back(i, polynomial_coarsening_sequence.back());
924 AssertThrow(
false, ExcNotImplemented());
932 std::map<unsigned int, unsigned int> p_map;
933 for (
const auto &[_, p] : levels)
934 p_map.insert({p, p_map.size()});
938 for (
const auto [p, l] : p_map)
947 .mg_use_fe_q_iso_q1 &&
951 mg_coarsening_type ==
953 ExcNotImplemented());
955 const auto points = QGaussLobatto<1>(p + 1).get_points();
959 FESystem<dim>(FE_Q_iso_Q1<dim>(points), dim + 1));
965 FESystem<dim>(FE_Q<dim>(p), dim + 1));
974 this->
pcout << std::endl;
975 this->
pcout <<
" -Levels of MG preconditioner:" << std::endl;
978 this->
pcout <<
" Level " << level <<
": "
980 .n_dofs(levels[level].first)
981 <<
" DoFs, " << n_cells_on_levels[levels[level].first]
982 <<
" cells" << std::endl;
983 this->
pcout << std::endl;
990 this->
pcout <<
" -MG vertical communication efficiency: "
991 << MGTools::vertical_communication_efficiency(
995 this->
pcout <<
" -MG workload imbalance: "
996 << MGTools::workload_imbalance(triangulation)
1000 std::vector<std::shared_ptr<const Utilities::MPI::Partitioner>>
1004 MGLevelObject<AffineConstraints<MGNumber>> level_constraints;
1013 this->
mg_setup_timer.enter_subsection(
"Set boundary conditions");
1024 FEValuesExtractors::Vector velocities(0);
1025 FEValuesExtractors::Scalar
pressure(dim);
1027 for (
auto const &[
id, type] :
1032 std::set<types::boundary_id> no_normal_flux_boundaries;
1033 no_normal_flux_boundaries.insert(
id);
1037 const unsigned int p_level = p_map[levels[level].second];
1039 AffineConstraints<double> temp_constraints;
1041 const IndexSet locally_owned_level_dofs =
1043 levels[level].first);
1044 const IndexSet locally_relevant_level_dofs =
1045 DoFTools::extract_locally_relevant_level_dofs(
1047 temp_constraints.reinit(locally_owned_level_dofs,
1048 locally_relevant_level_dofs);
1050 VectorTools::compute_no_normal_flux_constraints_on_level(
1053 no_normal_flux_boundaries,
1057 .get_refinement_edge_indices(levels[level].first),
1058 levels[level].first);
1059 temp_constraints.close();
1061 levels[level].first, temp_constraints);
1100 "Partial slip boundary conditions are not supported by the matrix free application."));
1113 std::set<types::boundary_id> dirichlet_boundary_id = {
id};
1115 for (
const auto [_, l] : p_map)
1118 dirichlet_boundary_id,
1119 fe->component_mask(velocities));
1126 "The boundary condition specified is not supported."));
1130 this->
mg_setup_timer.leave_subsection(
"Set boundary conditions");
1137 const unsigned int p_level = p_map[levels[level].second];
1139 level_constraints[level].clear();
1141 const auto &level_dof_handler = this->
dof_handlers[p_level];
1143 const IndexSet owned_dofs =
1144 level_dof_handler.locally_owned_mg_dofs(levels[level].first);
1145 const IndexSet relevant_dofs =
1146 DoFTools::extract_locally_relevant_level_dofs(level_dof_handler,
1147 levels[level].first);
1149 level_constraints[level].reinit(owned_dofs, relevant_dofs);
1152 .fix_pressure_constant &&
1153 level == this->minlevel)
1155 types::global_dof_index min_index = numbers::invalid_unsigned_int;
1157 std::vector<types::global_dof_index> dof_indices;
1160 for (
const auto &cell :
1161 level_dof_handler.mg_cell_iterators_on_level(this->minlevel))
1163 if (cell->is_locally_owned_on_level())
1165 const auto &fe = cell->get_fe();
1167 dof_indices.resize(fe.n_dofs_per_cell());
1168 cell->get_mg_dof_indices(dof_indices);
1170 for (
unsigned int i = 0; i < dof_indices.size(); ++i)
1171 if (fe.system_to_component_index(i).first == dim)
1172 min_index = std::min(min_index, dof_indices[i]);
1178 Utilities::MPI::min(min_index,
1179 level_dof_handler.get_mpi_communicator());
1181 AffineConstraints<double> temp_constraints;
1182 temp_constraints.reinit(owned_dofs, relevant_dofs);
1183 if (relevant_dofs.is_element(min_index))
1184 temp_constraints.add_line(min_index);
1187 levels[level].first, temp_constraints);
1199 .get_number_of_solids() > 0)
1201 AffineConstraints<double> solid_constraints;
1202 solid_constraints.reinit(owned_dofs, relevant_dofs);
1204 levels[level].first,
1208 solid_constraints.close();
1210 levels[level].first, solid_constraints);
1214 level_constraints[level],
1215 levels[level].first,
1225 Quadrature<dim> quadrature_mg =
1226 QGauss<dim>(level_dof_handler.get_fe().degree + 1);
1229 .mg_use_fe_q_iso_q1 &&
1230 level == this->minlevel)
1233 mg_coarsening_type ==
1235 ExcNotImplemented());
1238 QGaussLobatto<1>(level_dof_handler.get_fe().degree + 1)
1241 quadrature_mg = QIterated<dim>(QGauss<1>(2), points);
1250 .mg_use_fe_q_iso_q1 &&
1251 level == this->minlevel) ?
1252 this->dof_handler_fe_q_iso_q1 :
1254 level_constraints[level],
1257 physical_properties_manager,
1258 this->simulation_parameters.stabilization.stabilization,
1259 levels[level].first,
1261 this->simulation_parameters.boundary_conditions,
1262 this->simulation_parameters.linear_solver
1264 .mg_enable_hessians_jacobian,
1266 this->simulation_parameters.mortar_parameters.enable);
1272 partitioners[level] =
1279 this->
mg_setup_timer.enter_subsection(
"Create transfer operator");
1281 this->
mg_transfer_ls = std::make_shared<LSTransferType>(min_h_level);
1283 if (p_map.size() > 1)
1285 this->
transfers.resize(0, p_map.size() - 1);
1287 for (
unsigned int level =
transfers.min_level();
1292 level_constraints[level + 1],
1293 level_constraints[level],
1301 this->mg_constrained_dofs[this->mg_constrained_dofs.max_level()],
1304 this->
mg_setup_timer.leave_subsection(
"Create transfer operator");
1312 this->
mg_setup_timer.enter_subsection(
"Create level triangulations");
1314 MGTransferGlobalCoarseningTools::create_geometric_coarsening_sequence(
1316 this->
mg_setup_timer.leave_subsection(
"Create level triangulations");
1320 std::vector<std::shared_ptr<const Triangulation<dim>>> temp;
1331 (mg_min_level + 1) <=
1334 "The mg min level specified is higher than the finest mg level."));
1336 int mg_level_min_cells =
1338 .mg_level_min_cells;
1341 mg_level_min_cells <=
1342 static_cast<int>(
this
1345 ->n_global_active_cells()),
1347 "The mg level min cells specified are larger than the cells of the finest mg level."));
1350 auto ptr = std::find_if(
1352 this->coarse_grid_triangulations.end() - 1,
1353 [&mg_min_level, &mg_level_min_cells](
const auto &tria) {
1354 if (mg_min_level != -1)
1356 if ((mg_min_level + 1) <=
1357 static_cast<int>(tria->n_global_levels()))
1360 else if (mg_level_min_cells != -1)
1362 if (
static_cast<int>(tria->n_global_active_cells()) >=
1375 temp.push_back(*(ptr++));
1380 const auto mg_coarsening_type =
1382 .mg_coarsening_type;
1384 auto polynomial_coarsening_sequence =
1385 MGTransferGlobalCoarseningTools::create_polynomial_coarsening_sequence(
1387 this->simulation_parameters.linear_solver
1389 .mg_p_coarsening_type);
1395 .mg_p_min_coarsening_degree;
1397 std::erase(polynomial_coarsening_sequence, p);
1399 std::vector<std::pair<unsigned int, unsigned int>> levels;
1401 if (mg_coarsening_type ==
1405 for (
const auto i : polynomial_coarsening_sequence)
1406 levels.emplace_back(0, i);
1411 levels.emplace_back(i, polynomial_coarsening_sequence.back());
1413 else if (mg_coarsening_type ==
1417 for (
unsigned int i = 0;
1420 levels.emplace_back(i, polynomial_coarsening_sequence.front());
1423 for (
const auto i : polynomial_coarsening_sequence)
1426 else if (mg_coarsening_type ==
1430 for (
const auto i : polynomial_coarsening_sequence)
1433 else if (mg_coarsening_type ==
1439 levels.emplace_back(i, polynomial_coarsening_sequence.back());
1443 AssertThrow(
false, ExcNotImplemented());
1448 this->
maxlevel = levels.size() - 1;
1453 MGLevelObject<AffineConstraints<MGNumber>> constraints;
1462 "Create DoFHandlers and distribute DoFs");
1475 .mg_use_fe_q_iso_q1 &&
1476 l == this->minlevel)
1479 mg_coarsening_type ==
1481 ExcNotImplemented());
1484 QGaussLobatto<1>(levels[l].second + 1).get_points();
1487 FESystem<dim>(FE_Q_iso_Q1<dim>(points), dim + 1));
1493 FESystem<dim>(FE_Q<dim>(levels[l].second), dim + 1));
1499 "Create DoFHandlers and distribute DoFs");
1505 this->
pcout << std::endl;
1506 this->
pcout <<
" -Levels of MG preconditioner:" << std::endl;
1509 this->
pcout <<
" Level " << level <<
": "
1512 ->n_global_active_cells()
1513 <<
" cells" << std::endl;
1514 this->
pcout << std::endl;
1521 this->
pcout <<
" -MG vertical communication efficiency: "
1522 << MGTools::vertical_communication_efficiency(
1526 this->
pcout <<
" -MG workload imbalance: "
1527 << MGTools::workload_imbalance(
1541 std::shared_ptr<Mapping<dim>> level_mapping;
1549 this->
mappings[level] = std::make_shared<MappingQCache<dim>>(
1561 .rotor_rotation_angle->value(Point<dim>()),
1562 this->simulation_parameters.mortar_parameters
1563 .center_of_rotation,
1564 this->simulation_parameters.mortar_parameters
1565 .rotation_axis_direction);
1570 *mapping, this->
dof_handlers[level].get_triangulation());
1573 ExcMessage(
"Invalid mortar interface type."));
1575 level_mapping = this->
mappings[level];
1578 level_mapping = mapping;
1582 const auto &level_dof_handler = this->
dof_handlers[level];
1583 auto &level_constraint = constraints[level];
1585 this->
mg_setup_timer.enter_subsection(
"Set boundary conditions");
1587 level_constraint.clear();
1589 const IndexSet locally_relevant_dofs =
1590 DoFTools::extract_locally_relevant_dofs(level_dof_handler);
1592 level_constraint.reinit(level_dof_handler.locally_owned_dofs(),
1593 locally_relevant_dofs);
1595 DoFTools::make_hanging_node_constraints(level_dof_handler,
1598 FEValuesExtractors::Vector velocities(0);
1599 FEValuesExtractors::Scalar
pressure(dim);
1601 for (
auto const &[
id, type] :
1606 std::set<types::boundary_id> no_normal_flux_boundaries;
1607 no_normal_flux_boundaries.insert(
id);
1609 VectorTools::compute_no_normal_flux_constraints(
1612 no_normal_flux_boundaries,
1620 const auto &periodic_boundary =
1622 .periodic_boundaries.at(
id);
1623 DoFTools::make_periodicity_constraints(
1626 periodic_boundary.neighbor_id,
1627 periodic_boundary.direction,
1653 "Partial slip boundary conditions are not supported by the matrix free application."));
1671 VectorTools::interpolate_boundary_values(
1675 dealii::Functions::ZeroFunction<dim, MGNumber>(dim + 1),
1677 fe->component_mask(velocities));
1689 "The boundary condition specified is not supported."));
1694 .fix_pressure_constant &&
1695 level == this->minlevel)
1697 types::global_dof_index min_index = numbers::invalid_unsigned_int;
1699 std::vector<types::global_dof_index> dof_indices;
1702 for (
const auto &cell : level_dof_handler.active_cell_iterators())
1704 if (cell->is_locally_owned())
1706 const auto &fe = cell->get_fe();
1708 dof_indices.resize(fe.n_dofs_per_cell());
1709 cell->get_dof_indices(dof_indices);
1711 for (
unsigned int i = 0; i < dof_indices.size(); ++i)
1712 if (fe.system_to_component_index(i).first == dim)
1713 min_index = std::min(min_index, dof_indices[i]);
1719 Utilities::MPI::min(min_index,
1722 if (locally_relevant_dofs.is_element(min_index))
1723 level_constraint.add_line(min_index);
1729 .get_number_of_solids() > 0)
1731 level_dof_handler.locally_owned_dofs(),
1736 level_constraint.close();
1738 this->
mg_setup_timer.leave_subsection(
"Set boundary conditions");
1744 Quadrature<dim> quadrature_mg = QGauss<dim>(levels[level].second + 1);
1747 .mg_use_fe_q_iso_q1 &&
1748 level == this->minlevel)
1751 mg_coarsening_type ==
1753 ExcNotImplemented());
1756 QGaussLobatto<1>(level_dof_handler.get_fe().degree + 1)
1759 quadrature_mg = QIterated<dim>(QGauss<1>(2), points);
1768 const bool coarsest_level_uses_q1_interpolation =
1770 (levels[level].second == 1 ||
1773 .mg_use_fe_q_iso_q1);
1775 const bool enable_mortar_on_level =
1777 !coarsest_level_uses_q1_interpolation;
1785 physical_properties_manager,
1787 numbers::invalid_unsigned_int,
1789 this->simulation_parameters.boundary_conditions,
1790 this->simulation_parameters.linear_solver
1792 .mg_enable_hessians_jacobian,
1794 enable_mortar_on_level);
1799 if (enable_mortar_on_level)
1801 this->
mg_setup_timer.enter_subsection(
"Set up mortar operators");
1808 std::make_shared<MortarManagerCircle<dim>>(
1817 std::make_shared<MortarManagerLinear<dim>>(
1824 ExcMessage(
"Invalid mortar interface type."));
1827 this->
mg_operators[level]->mortar_coupling_evaluator_mf =
1832 physical_properties_manager->get_rheology()
1833 ->get_kinematic_viscosity());
1836 this->
mg_operators[level]->mortar_coupling_operator_mf =
1837 std::make_shared<CouplingOperator<dim, double>>(
1841 this->
mg_operators[level]->mortar_coupling_evaluator_mf,
1846 .stator_boundary_id,
1849 this->
mg_setup_timer.leave_subsection(
"Set up mortar operators");
1854 this->
mg_setup_timer.enter_subsection(
"Create transfer operator");
1859 constraints[level + 1],
1860 constraints[level]);
1863 this->
transfers, [&](
const auto l,
auto &vec) {
1867 this->
mg_setup_timer.leave_subsection(
"Create transfer operator");
1870 AssertThrow(
false, ExcNotImplemented());
1872 mg_smoother_preconditioners.resize(this->minlevel, this->maxlevel);
1880 this->
mg_setup_timer.enter_subsection(
"Set up and initialize smoother");
1882 const auto &linear_solver_parameters =
1885 const auto smoother_preconditioner_type =
1886 linear_solver_parameters.mg_smoother_preconditioner_type;
1888 const bool use_chebyshev =
1889 smoother_preconditioner_type ==
1895 for (
unsigned int level = this->
minlevel; level <= this->
maxlevel; ++level)
1897 if (smoother_preconditioner_type ==
1903 this->
mg_operators[level]->compute_inverse_diagonal(diagonal_vector);
1905 std::make_shared<MyDiagonalMatrix<MGVectorType>>(diagonal_vector);
1907 else if (smoother_preconditioner_type ==
1909 additive_schwarz_method)
1913 std::make_shared<PreconditionASM<MGVectorType>>();
1918 ->get_system_matrix_free()
1923 ->get_system_matrix_free()
1924 .get_affine_constraints(),
1927 ->get_system_matrix_free()
1943 MGLevelObject<typename ChebyshevSmootherType::AdditionalData>
1949 smoother_data[level].preconditioner =
1951 smoother_data[level].degree =
1952 linear_solver_parameters.mg_smoother_chebyshev_degree;
1953 smoother_data[level].smoothing_range =
1954 linear_solver_parameters.mg_smoother_chebyshev_smoothing_range;
1955 smoother_data[level].eig_cg_n_iterations =
1956 linear_solver_parameters.mg_smoother_chebyshev_eig_cg_n_iterations;
1957 smoother_data[level].constraints.copy_from(
1959 ->get_system_matrix_free()
1960 .get_affine_constraints());
1963 smoother->initialize(this->
mg_operators, smoother_data);
1965 if (linear_solver_parameters.eig_estimation_verbose !=
1975 smoother->smoothers[level].estimate_eigenvalues(vec);
1977 this->
pcout << std::endl;
1978 this->
pcout <<
" -Eigenvalue estimation level "
1979 << level - this->
minlevel <<
":" << std::endl;
1980 this->
pcout <<
" Minimum eigenvalue: "
1981 << evs.min_eigenvalue_estimate << std::endl;
1982 this->
pcout <<
" Maximum eigenvalue: "
1983 << evs.max_eigenvalue_estimate << std::endl;
1984 this->
pcout << std::endl;
1992 auto smoother = std::make_shared<
1993 MGSmootherPrecondition<OperatorType, SmootherType, MGVectorType>>();
1995 MGLevelObject<typename SmootherType::AdditionalData> smoother_data(
2001 smoother_data[level].preconditioner =
2004 smoother_data[level].n_iterations =
2005 linear_solver_parameters.mg_smoother_iterations;
2007 if (linear_solver_parameters.mg_smoother_eig_estimation)
2011 smoother_data[level].relaxation = 0.0;
2012 smoother_data[level].smoothing_range =
2013 linear_solver_parameters.eig_estimation_smoothing_range;
2014 smoother_data[level].eig_cg_n_iterations =
2015 linear_solver_parameters.eig_estimation_cg_n_iterations;
2016 smoother_data[level].eigenvalue_algorithm = SmootherType::
2017 AdditionalData::EigenvalueAlgorithm::power_iteration;
2018 smoother_data[level].constraints.copy_from(
2020 ->get_system_matrix_free()
2021 .get_affine_constraints());
2024 smoother_data[level].relaxation =
2025 linear_solver_parameters.mg_smoother_relaxation;
2028 smoother->initialize(this->
mg_operators, smoother_data);
2030 if (linear_solver_parameters.mg_smoother_eig_estimation &&
2031 linear_solver_parameters.eig_estimation_verbose !=
2041 smoother->smoothers[level].estimate_eigenvalues(vec);
2043 this->
pcout << std::endl;
2044 this->
pcout <<
" -Eigenvalue estimation level "
2045 << level - this->
minlevel <<
":" << std::endl;
2046 this->
pcout <<
" Relaxation parameter: "
2047 << smoother->smoothers[level].get_relaxation()
2049 this->
pcout <<
" Minimum eigenvalue: "
2050 << evs.min_eigenvalue_estimate << std::endl;
2051 this->
pcout <<
" Maximum eigenvalue: "
2052 << evs.max_eigenvalue_estimate << std::endl;
2053 this->
pcout << std::endl;
2060 this->
mg_setup_timer.leave_subsection(
"Set up and initialize smoother");
2063 this->
mg_setup_timer.enter_subsection(
"Create coarse-grid solver");
2066 .mg_coarse_grid_solver ==
2069 const int max_iterations =
2071 .mg_gmres_max_iterations;
2072 const double tolerance =
2074 .mg_gmres_tolerance;
2075 const double reduce =
2079 max_iterations, tolerance, reduce,
false,
false);
2080 SolverGMRES<TrilinosVectorType>::AdditionalData solver_parameters;
2081 solver_parameters.max_n_tmp_vectors =
2083 .mg_gmres_max_krylov_vectors;
2086 std::make_shared<SolverGMRES<TrilinosVectorType>>(
2091 .mg_gmres_preconditioner ==
2096 this->
mg_coarse = std::make_shared<MGCoarseGridIterativeSolver<
2098 SolverGMRES<TrilinosVectorType>,
2099 TrilinosWrappers::SparseMatrix,
2107 .mg_gmres_preconditioner ==
2112 this->
mg_coarse = std::make_shared<MGCoarseGridIterativeSolver<
2114 SolverGMRES<TrilinosVectorType>,
2115 TrilinosWrappers::SparseMatrix,
2124 .mg_coarse_grid_solver ==
2129 this->
mg_coarse = std::make_shared<CoarseGridSolverApply>(
2134 .mg_coarse_grid_solver ==
2139 this->
mg_coarse = std::make_shared<CoarseGridSolverApply>(
2144 .mg_coarse_grid_solver ==
2147 TrilinosWrappers::SolverDirect::AdditionalData data;
2149 std::make_shared<SolverControl>(100, 1.e-10);
2151 auto precondition_direct =
2152 std::make_shared<TrilinosWrappers::SolverDirect>(
2155 precondition_direct->initialize(
2159 std::make_shared<PreconditionAdapter<MGVectorType, TrilinosVectorType>>(
2160 precondition_direct);
2162 this->
mg_coarse = std::make_shared<CoarseGridSolverApply>(
2168 .mg_coarse_grid_solver ==
2171 .mg_coarse_grid_solver ==
2174 .mg_coarse_grid_solver ==
2177 .mg_coarse_grid_solver ==
2180 "This coarse-grid solver is not supported. Supported options are <gmres|amg|ilu|direct>."));
2182 this->
mg_setup_timer.leave_subsection(
"Create coarse-grid solver");
2197 std::make_shared<Multigrid<MGVectorType>>(*this->
mg_matrix,
2205 if (this->
dof_handler.get_triangulation().has_hanging_nodes())
2211 std::make_shared<PreconditionMG<dim, MGVectorType, LSTransferType>>(
2216 .mg_gmres_max_iterations;
2219 .mg_gmres_tolerance;
2225 std::make_shared<ReductionControl>(
2226 max_iterations, tolerance, reduce,
false,
false);
2229 std::make_shared<SolverGMRES<MGVectorType>>(
2233 std::make_shared<MGCoarseGridIterativeSolver<
2235 SolverGMRES<MGVectorType>,
2237 PreconditionMG<dim, MGVectorType, LSTransferType>>>(
2244 this->
mg = std::make_shared<Multigrid<MGVectorType>>(
2254 if (this->
dof_handler.get_triangulation().has_hanging_nodes())
2259 std::make_shared<PreconditionMG<dim, MGVectorType, LSTransferType>>(
2271 std::make_shared<Multigrid<MGVectorType>>(*this->
mg_matrix,
2281 std::make_shared<PreconditionMG<dim, MGVectorType, GCTransferType>>(
2286 .mg_gmres_max_iterations;
2289 .mg_gmres_tolerance;
2295 std::make_shared<ReductionControl>(
2296 max_iterations, tolerance, reduce,
false,
false);
2299 std::make_shared<SolverGMRES<MGVectorType>>(
2303 std::make_shared<MGCoarseGridIterativeSolver<
2305 SolverGMRES<MGVectorType>,
2307 PreconditionMG<dim, MGVectorType, GCTransferType>>>(
2310 *this->gc_multigrid_preconditioner_intermediate);
2314 this->
mg = std::make_shared<Multigrid<MGVectorType>>(
2323 Multigrid<MGVectorType>::Cycle::v_cycle);
2327 std::make_shared<PreconditionMG<dim, MGVectorType, GCTransferType>>(
2332 const auto create_mg_timer_function = [&](
const std::string &label) {
2333 return [label,
this](
const bool flag,
const unsigned int level) {
2334 const std::string label_full =
2336 (
"gmg::vmult::level_" + std::to_string(level)) :
2337 (
"gmg::vmult::level_" + std::to_string(level) +
"::" + label);
2346 this->
mg->connect_pre_smoother_step(
2347 create_mg_timer_function(
"0_pre_smoother_step"));
2348 this->
mg->connect_residual_step(create_mg_timer_function(
"1_residual_step"));
2349 this->
mg->connect_restriction(create_mg_timer_function(
"2_restriction"));
2350 this->
mg->connect_coarse_solve(create_mg_timer_function(
""));
2351 this->
mg->connect_prolongation(create_mg_timer_function(
"3_prolongation"));
2352 this->
mg->connect_edge_prolongation(
2353 create_mg_timer_function(
"4_edge_prolongation"));
2354 this->
mg->connect_post_smoother_step(
2355 create_mg_timer_function(
"5_post_smoother_step"));
2360 create_mg_timer_function(
"0_pre_smoother_step"));
2362 create_mg_timer_function(
"1_residual_step"));
2364 create_mg_timer_function(
"2_restriction"));
2365 this->
mg_intermediate->connect_coarse_solve(create_mg_timer_function(
""));
2367 create_mg_timer_function(
"3_prolongation"));
2369 create_mg_timer_function(
"4_edge_prolongation"));
2371 create_mg_timer_function(
"5_post_smoother_step"));
2374 const auto create_mg_precon_timer_function = [&](
const std::string &label) {
2375 return [label,
this](
const bool flag) {
2376 const std::string label_full =
"gmg::vmult::" + label;
2389 create_mg_precon_timer_function(
"transfer_to_mg"));
2391 create_mg_precon_timer_function(
"transfer_to_global"));
2399 create_mg_precon_timer_function(
"transfer_to_mg"));
2401 create_mg_precon_timer_function(
"transfer_to_global"));
2415 AssertThrow(
false, ExcNotImplemented());
2434 this->
pcout <<
" -Coarse grid solver took: 0 iterations" << std::endl;
2438 this->
pcout <<
" -Coarse grid solver took: "
2440 for (
unsigned int i = 1; i < this->coarse_grid_iterations.size(); i++)
2442 this->
pcout <<
" + " << this->coarse_grid_iterations[i];
2443 total += this->coarse_grid_iterations[i];
2445 this->
pcout <<
" = " << total <<
" iterations" << std::endl;
2447 this->coarse_grid_iterations.clear();
2473 TrilinosWrappers::PreconditionAMG::AdditionalData amg_data;
2476 const TrilinosWrappers::SparseMatrix &min_level_matrix =
2480 .mg_amg_use_default_parameters)
2482 amg_data.elliptic =
false;
2484 amg_data.higher_order_elements =
true;
2491 amg_data.aggregation_threshold =
2493 .amg_aggregation_threshold;
2494 amg_data.smoother_sweeps =
2496 .amg_smoother_sweeps;
2497 amg_data.smoother_overlap =
2499 .amg_smoother_overlap;
2500 amg_data.output_details =
false;
2501 amg_data.smoother_type =
"ILU";
2502 amg_data.coarse_type =
"ILU";
2504 std::vector<std::vector<bool>> constant_modes;
2505 ComponentMask components(dim + 1,
true);
2513 constant_modes = DoFTools::extract_level_constant_modes(
2515 ->get_system_matrix_free()
2518 ->get_system_matrix_free()
2533 amg_data.constant_modes = constant_modes;
2535 Teuchos::ParameterList parameter_ml;
2536 std::unique_ptr<Epetra_MultiVector> distributed_constant_modes;
2537 amg_data.set_parameters(parameter_ml,
2538 distributed_constant_modes,
2541 const double ilu_fill =
2543 .amg_precond_ilu_fill;
2544 const double ilu_atol =
2546 .amg_precond_ilu_atol;
2547 const double ilu_rtol =
2549 .amg_precond_ilu_rtol;
2550 parameter_ml.set(
"smoother: ifpack level-of-fill", ilu_fill);
2551 parameter_ml.set(
"smoother: ifpack absolute threshold", ilu_atol);
2552 parameter_ml.set(
"smoother: ifpack relative threshold", ilu_rtol);
2554 parameter_ml.set(
"coarse: ifpack level-of-fill", ilu_fill);
2555 parameter_ml.set(
"coarse: ifpack absolute threshold", ilu_atol);
2556 parameter_ml.set(
"coarse: ifpack relative threshold", ilu_rtol);
2558 auto precondition_amg =
2559 std::make_shared<TrilinosWrappers::PreconditionAMG>();
2561 precondition_amg->initialize(min_level_matrix, parameter_ml);
2564 std::make_shared<PreconditionAdapter<MGVectorType, TrilinosVectorType>>(
2569 auto precondition_amg =
2570 std::make_shared<TrilinosWrappers::PreconditionAMG>();
2573 std::make_shared<PreconditionAdapter<MGVectorType, TrilinosVectorType>>(
2582 int current_preconditioner_fill_level =
2585 const double ilu_atol =
2588 const double ilu_rtol =
2591 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
2592 current_preconditioner_fill_level, ilu_atol, ilu_rtol, 0);
2594 auto precondition_ilu = std::make_shared<TrilinosWrappers::PreconditionILU>();
2596 precondition_ilu->initialize(
2598 preconditionerOptions);
2601 std::make_shared<PreconditionAdapter<MGVectorType, TrilinosVectorType>>(
2608 const unsigned int level)
2611 .is_non_newtonian())
2616 std::make_shared<NavierStokesStabilizedOperator<dim, MGNumber>>();
2632 const std::shared_ptr<SimulationControl> &simulation_control,
2635 const VectorType &time_derivative_previous_solutions)
2637 const bool transient =
2642 MGLevelObject<MGVectorType> mg_time_derivative_previous_solutions(
2645 for (
unsigned int level = this->
minlevel; level <= this->
maxlevel; ++level)
2647 this->
mg_operators[level]->initialize_dof_vector(mg_solution[level]);
2650 mg_time_derivative_previous_solutions[level]);
2653 this->
mg_setup_timer.enter_subsection(
"Execute relevant transfers");
2667 mg_time_derivative_previous_solutions,
2668 time_derivative_previous_solutions);
2685 mg_time_derivative_previous_solutions,
2686 time_derivative_previous_solutions);
2689 std::make_shared<mg::Matrix<MGVectorType>>(this->
mg_operators);
2692 this->
mg_setup_timer.leave_subsection(
"Execute relevant transfers");
2695 for (
unsigned int level = this->
minlevel; level <= this->
maxlevel; ++level)
2697 mg_solution[level].update_ghost_values();
2702 ->get_system_matrix_free()
2706 this->simulation_parameters.mortar_parameters.rotation_axis_direction,
2707 this->simulation_parameters.mortar_parameters.rotor_angular_velocity);
2709 this->
mg_operators[level]->evaluate_non_linear_term_and_calculate_tau(
2710 mg_solution[level]);
2714 mg_time_derivative_previous_solutions[level].update_ghost_values();
2716 ->evaluate_time_derivative_previous_solutions(
2717 mg_time_derivative_previous_solutions[level]);
2731 const DoFHandler<dim> &temperature_dof_handler,
2732 const VectorType &temperature_present_solution)
2737 AssertThrow(
false, ExcNotImplemented());
2744 const unsigned int min_level = this->
minlevel;
2745 const unsigned int max_level = this->
maxlevel;
2749 for (
unsigned int l = min_level; l <= max_level; l++)
2754 temperature_dof_handler.get_fe());
2760 for (
unsigned int l = min_level; l < max_level; l++)
2773 temperature_dof_handler, [&](
const auto l,
auto &vec) {
2775 DoFTools::extract_locally_active_dofs(
2780 MGLevelObject<MGVectorType> mg_temperature_solution(this->
minlevel,
2784 temperature_dof_handler,
2785 mg_temperature_solution,
2786 temperature_present_solution);
2788 for (
unsigned int l = min_level; l <= max_level; l++)
2790 mg_temperature_solution[l].update_ghost_values();
2803 fluid_dynamics_formulation)
2809 "Matrix free Navier-Stokes does not support different orders for the velocity and the pressure!"));
2819 "Matrix free Navier-Stokes does not support the <pressure scaling factor> parameter of the <stabilization> subsection. Set it to 1, or use the matrix-based solver (lethe-fluid) if the pressure has to be rescaled."));
2821 this->
fe = std::make_shared<FESystem<dim>>(
2826 std::make_shared<TrilinosWrappers::MPI::Vector>();
2839 "Matrix free Non-Newtonian Navier-Stokes only supports SUPG/PSPG stabilization."));
2843 std::make_shared<NavierStokesStabilizedOperator<dim, double>>();
2865 const double a_ii = stage_data.
a_ij[stage];
2873 for (
unsigned int p = 0; p < stage; ++p)
2877 stage_data.
a_ij[p] / a_ii,
2878 this->sdirk_vectors.previous_k_j_solutions[p]);
2883 "Calculate time derivative previous solutions");
2891 "Calculate time derivative previous solutions");
2900 const unsigned int stage,
2902 const double time_step)
2906 const double a_ii = stage_data.
a_ij[stage];
2926 const double b_i = stage_data.
b_i;
2968 this->simulation_parameters.manifolds_parameters,
2969 this->simulation_parameters.restart_parameters.restart,
2970 this->simulation_parameters.boundary_conditions.periodic_boundaries,
2971 this->simulation_parameters.mortar_parameters);
2981 this->simulation_parameters.manifolds_parameters,
2982 this->simulation_parameters.restart_parameters.restart,
2983 this->simulation_parameters.boundary_conditions.periodic_boundaries);
2991 this->simulation_parameters.restart_parameters.restart);
2994 if (this->
multiphysics->get_active_physics().size() > 1)
3016 "Calculate time derivative previous solutions");
3024 "Calculate time derivative previous solutions");
3031 if (this->
multiphysics->get_active_physics().size() > 1)
3071 DoFRenumbering::Cuthill_McKee(*this->
dof_handler);
3082 .mg_use_fe_q_iso_q1)
3087 QGaussLobatto<1>(this->
dof_handler->get_fe().degree + 1)
3091 FESystem<dim>(FE_Q_iso_Q1<dim>(points), dim + 1));
3099 DoFTools::extract_locally_relevant_dofs(*this->
dof_handler);
3110 for (
auto const &[
id, type] :
3118 "The following boundary conditions are not supported by the lethe-fluid-matrix-free application: partial slip."));
3129 unsigned int mg_level = numbers::invalid_unsigned_int;
3139 this->simulation_control,
3140 this->simulation_parameters.boundary_conditions,
3142 .enable_hessians_jacobian,
3144 .enable_hessians_residual,
3145 this->simulation_parameters.mortar_parameters.enable);
3168 for (
auto &solution : this->
sdirk_vectors.previous_k_j_solutions)
3186 double global_volume =
3189 this->
pcout <<
" Number of active cells: "
3190 << this->
triangulation->n_global_active_cells() << std::endl
3191 <<
" Number of degrees of freedom: "
3193 this->
pcout <<
" Volume of triangulation: " << global_volume
3205 std::make_shared<std::vector<TrilinosWrappers::MPI::Vector>>(
3215 if (this->
multiphysics->get_active_physics().size() > 1)
3226 TimerOutput::Scope t(this->
computing_timer,
"Update mortar configuration");
3233 !this->simulation_control->is_refinement_step(
3234 this->simulation_parameters.mesh_adaptation) ||
3235 this->simulation_parameters.mesh_adaptation.type ==
3264 TimerOutput::Scope t(this->
computing_timer,
"Reinit mortar operators");
3270 std::make_shared<MortarManagerCircle<dim>>(
3278 std::make_shared<MortarManagerLinear<dim>>(
3279 *this->cell_quadrature,
3284 AssertThrow(
false, ExcMessage(
"Invalid mortar interface type."));
3288 std::make_shared<NavierStokesCouplingEvaluationSIPG<dim, double>>(
3292 ->get_kinematic_viscosity());
3295 std::make_shared<CouplingOperator<dim, double>>(
3314 this->
pcout <<
"************************" << std::endl;
3315 this->
pcout <<
"---> Simulation Restart " << std::endl;
3316 this->
pcout <<
"************************" << std::endl;
3319 else if (initial_condition_type ==
3326 else if (initial_condition_type ==
3334 std::shared_ptr<RheologicalModel> original_viscosity_model =
3339 std::shared_ptr<Newtonian> temporary_rheology =
3340 std::make_shared<Newtonian>(
3348 const auto original_assembly_method =
3364 else if (initial_condition_type ==
3367 this->
pcout <<
"*********************************" << std::endl;
3368 this->
pcout <<
" Initial condition using ramp " << std::endl;
3369 this->
pcout <<
"*********************************" << std::endl;
3381 const auto original_assembly_method =
3385 std::shared_ptr<RheologicalModel> viscosity_model =
3389 const double original_viscosity =
3390 viscosity_model->get_kinematic_viscosity();
3393 const int n_iter_viscosity =
3396 double kinematic_viscosity =
3397 n_iter_viscosity > 0 ?
3399 .kinematic_viscosity_init :
3401 const double alpha_viscosity =
3406 for (
int i = 0; i < n_iter_viscosity; ++i)
3408 this->
pcout <<
"********* Solution for kinematic viscosity = " +
3409 std::to_string(kinematic_viscosity) +
" *********"
3413 viscosity_model->set_kinematic_viscosity(kinematic_viscosity);
3420 solve_governing_system();
3424 kinematic_viscosity +=
3425 alpha_viscosity * (original_viscosity - kinematic_viscosity);
3430 viscosity_model->set_kinematic_viscosity(original_viscosity);
3440 this->
pcout <<
"*********************************" << std::endl;
3441 this->
pcout <<
" Time spent in ramp: " << timer.wall_time() <<
"s"
3443 this->
pcout <<
"*********************************" << std::endl;
3448 throw std::runtime_error(
3449 "Type of initial condition is not supported by MF Navier-Stokes");
3478 this->simulation_parameters.mortar_parameters.rotation_axis_direction,
3479 this->simulation_parameters.mortar_parameters.rotor_angular_velocity);
3500 this->
system_rhs.compress(VectorOperation::add);
3517 "Update multiphysics average solution");
3521 TrilinosWrappers::MPI::Vector temp_average_velocities(
3524 temp_average_velocities,
3528#ifndef LETHE_USE_LDV
3531 std::make_shared<TrilinosWrappers::MPI::Vector>(
3555 const double a_ii = stage_data.
a_ij[0];
3556 const auto time_steps_vector =
3558 const double dt = time_steps_vector[0];
3568 const Vector<double> &bdf_coefs =
3605 this->temperature_present_solution);
3632 int current_preconditioner_fill_level =
3635 const double ilu_atol =
3638 const double ilu_rtol =
3641 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
3642 current_preconditioner_fill_level, ilu_atol, ilu_rtol, 0);
3647 preconditionerOptions);
3658 this->
pcout << std::defaultfloat;
3669 this->
system_operator->timer.print_wall_time_statistics(MPI_COMM_WORLD);
3672 for (
unsigned int level = mg_operators.min_level();
3673 level <= mg_operators.max_level();
3677 "Operator level " + std::to_string(level) +
" times");
3678 mg_operators[level]->timer.print_wall_time_statistics(MPI_COMM_WORLD);
3681 mg_operators[level]->timer.reset();
3684 auto mg_smoother_preconditioners =
3686 for (
unsigned int level = mg_operators.min_level();
3687 level <= mg_operators.max_level();
3691 "Preconditioner level " + std::to_string(level) +
3693 mg_smoother_preconditioners[level]->timer_print();
3696 mg_smoother_preconditioners[level]->timer_reset();
3703 this->
pcout << std::scientific;
3712 "Update solutions for multiphysics");
3729#ifndef LETHE_USE_LDV
3742 std::vector<TrilinosWrappers::MPI::Vector> temp_previous_solutions;
3745 for (
auto &solution : temp_previous_solutions)
3757#ifndef LETHE_USE_LDV
3771 "Update solutions for fluid dynamics");
3776 const auto &heat_solution =
3779#ifndef LETHE_USE_LDV
3780 const auto &heat_dof_handler =
3784 TrilinosWrappers::MPI::Vector temp_heat_solution;
3785 temp_heat_solution.reinit(heat_dof_handler.locally_owned_dofs(),
3786 this->mpi_communicator);
3787 temp_heat_solution = heat_solution;
3791 heat_dof_handler.locally_owned_dofs(),
3792 DoFTools::extract_locally_active_dofs(heat_dof_handler),
3793 this->mpi_communicator);
3797 temp_heat_solution);
3816 this->simulation_parameters.mortar_parameters.rotation_axis_direction,
3817 this->simulation_parameters.mortar_parameters.rotor_angular_velocity);
3819 this->
computing_timer.enter_subsection(
"Evaluate non linear term and tau");
3824 this->
computing_timer.leave_subsection(
"Evaluate non linear term and tau");
3833 (this->simulation_parameters.linear_solver
3847 "This linear solver does not support this preconditioner. Only <ilu|lsmg|gcmg> preconditioners are supported."));
3854 const double absolute_residual =
3857 const double relative_residual =
3873 AssertThrow(
false, ExcMessage(
"This solver is not allowed"));
3887 const double relative_residual)
3889 const AffineConstraints<double> &
zero_constraints = this->zero_constraints;
3891 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
3892 const double linear_solver_tolerance =
3893 std::max(relative_residual * current_residual, absolute_residual);
3897 this->
pcout <<
" -Tolerance of iterative solver is : "
3898 << linear_solver_tolerance << std::endl;
3900 const double non_rescaled_linear_solver_tolerance =
3901 linear_solver_tolerance * rescale_metric;
3908 non_rescaled_linear_solver_tolerance,
3912 SolverGMRES<VectorType>::AdditionalData solver_parameters;
3914 solver_parameters.max_n_tmp_vectors =
3916 .max_krylov_vectors;
3917 solver_parameters.right_preconditioning =
true;
3919 SolverGMRES<VectorType> solver(solver_control, solver_parameters);
3931 "This linear solver does not support this preconditioner. Only <ilu|lsmg|gcmg> preconditioners are supported."));
3953 (this->simulation_parameters.linear_solver
3977 catch (
const std::exception &e)
3981 .force_linear_solver_continuation)
3983 this->
pcout <<
" GMRES solver failed." << std::endl;
3984 if (
const auto *nc =
3985 dynamic_cast<const SolverControl::NoConvergence *
>(&e))
3986 this->
pcout <<
" It stopped at iteration " << nc->last_step
3987 <<
" with a residual of "
3988 << nc->last_residual / rescale_metric
3989 <<
" (tolerance " << linear_solver_tolerance <<
")."
3996 <<
" GMRES solver failed! Continuing the Newton step as requested by the <force linear solver continuation> parameter."
4004 this->
pcout <<
" -Iterative solver took : " << solver_control.last_step()
4005 <<
" steps to reach a residual norm of "
4006 << solver_control.last_value() / rescale_metric << std::endl;
4010 "Distribute constraints after linear solver");
4015 "Distribute constraints after linear solver");
4021 const double absolute_residual,
4022 const double relative_residual)
4024 const AffineConstraints<double> &
zero_constraints = this->zero_constraints;
4026 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
4027 const double linear_solver_tolerance =
4028 std::max(relative_residual * current_residual, absolute_residual);
4032 this->
pcout <<
" -Tolerance of iterative solver is : "
4033 << linear_solver_tolerance << std::endl;
4035 const double non_rescaled_linear_solver_tolerance =
4036 linear_solver_tolerance * rescale_metric;
4043 non_rescaled_linear_solver_tolerance,
4047 SolverBicgstab<VectorType> solver(solver_control);
4059 "This linear solver does not support this preconditioner. Only <ilu|lsmg|gcmg> preconditioners are supported."));
4081 (this->simulation_parameters.linear_solver
4105 catch (
const std::exception &e)
4109 .force_linear_solver_continuation)
4111 this->
pcout <<
" BiCGStab solver failed." << std::endl;
4112 if (
const auto *nc =
4113 dynamic_cast<const SolverControl::NoConvergence *
>(&e))
4115 this->
pcout <<
" It stopped at iteration " << nc->last_step
4116 <<
" with a residual of "
4117 << nc->last_residual / rescale_metric
4118 <<
" (tolerance " << linear_solver_tolerance <<
")."
4121 if (!std::isfinite(nc->last_residual))
4123 <<
" The residual is not finite, which indicates a breakdown of the BiCGStab iteration or of the preconditioner."
4127 <<
" The iteration budget was exhausted. BiCGStab restarts silently when it breaks down, so this may be either slow convergence or a breakdown."
4135 <<
" BiCGStab solver failed! Continuing the Newton step as requested by the <force linear solver continuation> parameter."
4143 this->
pcout <<
" -Iterative solver took : " << solver_control.last_step()
4144 <<
" steps to reach a residual norm of "
4145 << solver_control.last_value() / rescale_metric << std::endl;
4149 "Distribute constraints after linear solver");
4154 "Distribute constraints after linear solver");
4160 const double absolute_residual,
4161 const double relative_residual)
4163 const AffineConstraints<double> &
zero_constraints = this->zero_constraints;
4165 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
4166 const double linear_solver_tolerance =
4167 std::max(relative_residual * current_residual, absolute_residual);
4168 const double non_rescaled_linear_solver_tolerance =
4169 linear_solver_tolerance * rescale_metric;
4174 non_rescaled_linear_solver_tolerance,
4178 TrilinosWrappers::SolverDirect solver(solver_control);
4190 "Distribute constraints after linear solver");
4195 "Distribute constraints after linear solver");
unsigned int number_of_previous_solutions(const Parameters::SimulationControl::TimeSteppingMethod method)
Get the number of previous time steps for a specific BDF scheme.
Dynamic flow controller that drives the average velocity of the flow towards a target value.
Tensor< 1, dim > get_beta() const
Get the beta force of the current time step.
A solver for the incompressible Navier-Stokes equations implemented in a matrix-free fashion.
virtual void initialize_GMG()
Intialize the geometric multigrid preconditioner.
virtual void solve()
Solve the problem defined by simulation parameters by iterating through time or through the mesh refi...
void reinit_mortar_operators_mf()
Initialize mortar coupling manager, operator, and evaluator for the matrix-free solver.
TrilinosWrappers::MPI::Vector multiphysics_average_velocities
Trilinos vector storing the average velocities that are provided to other physics.
void solve_system_GMRES(const double absolute_residual, const double relative_residual)
GMRES solver with preconditioning.
void setup_ILU()
Setup the implicit LU preconditioner and call the solve function of the linear solver....
void print_mg_setup_times()
Prints the setup times for the geometric multigrid preconditioner.
std::shared_ptr< PhysicalPropertiesManager > physical_properties_manager
Pointer to the physical properties object.
std::shared_ptr< std::vector< TrilinosWrappers::MPI::Vector > > multiphysics_previous_solutions
Vector storing trilinos vectors containing the previous solutions that are provided to other physics.
virtual void update_solutions_for_fluid_dynamics() override
Provide present multiphysics solutions from the multiphysics interface to the fluid dynamics.
DoFHandler< dim > dof_handler_fe_q_iso_q1
Describes the layout of DoFs for FE_Q_iso_Q1 elements.
void update_forcing_and_boundary_conditions() override
Set the time of the forcing function and of the time-dependent boundary conditions to the current tim...
virtual void set_initial_condition_fd(Parameters::FluidDynamicsInitialConditionType initial_condition_type, bool restart=false) override
VectorType temperature_present_solution
Vector storing the present temperature solution from the heat transfer solver.
VectorType time_derivative_previous_solutions
Vector to store the time derivatives of the previous solutions at the end of each time step for time-...
void setup_preconditioner() override
Set up appropriate preconditioner.
virtual void update_solutions_for_multiphysics() override
Provide present and previous flow solutions to the multiphysics interface. These solutions can be acc...
virtual void update_multiphysics_time_average_solution() override
Update the average velocity field solution in the multiphyscics interface.
virtual void update_mortar_configuration() override
Update mortar configuration.
std::shared_ptr< TrilinosWrappers::MPI::Vector > multiphysics_present_solution
Trilinos vector storing the present solution that is provided to other physics.
virtual void assemble_system_rhs() override
Assemble the system right hand side associated with the solver.
std::shared_ptr< NavierStokesOperatorBase< dim, double > > system_operator
Matrix-free operator in used for all the matrix-vector multiplications calls (vmult).
void solve_system_direct(const double absolute_residual, const double relative_residual)
Direct solver using TrilinosWrappers::SolverDirect.
std::shared_ptr< MFNavierStokesPreconditionGMGBase< dim > > gmg_preconditioner
Geometric multigrid preconditioner.
void multi_stage_preresolution(unsigned int stage, Parameters::SimulationControl::TimeSteppingMethod method) override
Update the sum_over_previous_stages variable to use it in the solver.
void solve_system_BiCGStab(const double absolute_residual, const double relative_residual)
BiCGStab solver with preconditioning.
void calculate_time_derivative_previous_solutions()
Calculate and store time derivatives of previous solutions according to time-stepping scheme to use t...
virtual void create_GMG()
Create the geometric multigrid preconditioner.
FluidDynamicsMatrixFree(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
Constructor that sets the finite element degree and system operator according to simulation parameter...
void setup_GMG()
Setup the geometric multigrid preconditioner.
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
Implicit LU preconditioner.
virtual void update_multi_stage_solution(double time_step) override
~FluidDynamicsMatrixFree()
Destructor.
virtual void setup_dofs_fd() override
Setup the degrees of freedom, system constraints, system operator and solution vectors.
virtual void assemble_system_matrix() override
Assemble the matrix associated with the solver. Only required for compilation and it is not used for ...
void solve_linear_system() override
Solve the linear system of equations using the method specified in the simulation parameters.
virtual void multi_stage_postresolution(unsigned int stage, Parameters::SimulationControl::TimeSteppingMethod method, double time_step) override
Calculate from Update .
LinearAlgebra::distributed::Vector< double > VectorType
void assemble_L2_projection()
Assemble a L2 projection matrix for the velocity and the pressure, which can be used to set the initi...
A geometric multigrid preconditioner compatible with the matrix-free solver.
bool use_manifold_for_normal
MGLevelObject< std::shared_ptr< PreconditionBase< MGVectorType > > > mg_smoother_preconditioners
Preconditioners associated to smoothers.
std::shared_ptr< SolverControl > coarse_grid_solver_control_intermediate
Solver control for the coarse grid solver (intermediate level).
MGLevelObject< std::shared_ptr< OperatorType > > mg_operators
Level operators for the geometric multigrid.
MGLevelObject< DoFHandler< dim > > temperature_dof_handlers
std::shared_ptr< PreconditionMG< dim, MGVectorType, GCTransferType > > gc_multigrid_preconditioner
Global coarsening multigrid preconditioner object.
PreconditionChebyshev< OperatorType, MGVectorType, SmootherPreconditionerType > ChebyshevSmootherType
SimulationParameters< dim > simulation_parameters
Simulation parameters.
void setup_AMG()
Set up AMG object needed for coarse-grid solver or preconditioning.
TimerOutput mg_vmult_timer
Internal timer for vmult timings.
unsigned int maxlevel
Max level of the multigrid hierarchy.
std::shared_ptr< PreconditionAdapter< MGVectorType, TrilinosVectorType > > coarse_grid_precondition
Coarse grid solver (algebraic multigrid, ILU, direct solver).
void setup_ILU()
Set up ILU object needed for coarse-grid solver or preconditioning.
std::shared_ptr< Multigrid< MGVectorType > > mg
Multigrid method.
std::shared_ptr< mg::Matrix< MGVectorType > > mg_interface_matrix_in
Interface edge matrix needed only for local smoothing.
std::shared_ptr< SolverControl > direct_solver_control
Solver control for the direct solver.
TimerOutput mg_setup_timer
Timer for specific geometric multigrid components.
LinearAlgebra::distributed::Vector< Number > VectorType
void initialize()
Initialize smoother, coarse grid solver and multigrid object needed for the geometric multigrid preco...
std::shared_ptr< MGCoarseGridBase< MGVectorType > > mg_coarse_intermediate
Multigrid wrapper for the coarse grid solver (intermediate level).
std::shared_ptr< MGCoarseGridBase< MGVectorType > > mg_coarse
Multigrid wrapper for the coarse grid solver.
std::shared_ptr< SolverGMRES< MGVectorType > > coarse_grid_solver_intermediate
GMRES as coarse grid solver (intermediate level).
std::shared_ptr< SolverControl > coarse_grid_solver_control
Solver control for the coarse grid solver.
const DoFHandler< dim > & dof_handler
Describes the layout of DoFs and the type of FE.
std::shared_ptr< LSTransferType > mg_transfer_ls
Transfer operator for local smoothing.
std::shared_ptr< mg::Matrix< MGVectorType > > mg_matrix
Multigrid level object storing all operators.
LinearAlgebra::distributed::Vector< MGNumber > MGVectorType
MFNavierStokesPreconditionGMGBase(const SimulationParameters< dim > &simulation_parameters, const DoFHandler< dim > &dof_handler, const DoFHandler< dim > &dof_handler_fe_q_iso_q1)
Construct a new precondition GMG object. Sets constraints, operators and transfer objects.
std::shared_ptr< PreconditionMG< dim, MGVectorType, GCTransferType > > gc_multigrid_preconditioner_intermediate
Global coarsening multigrid preconditioner object (intermediate level).
std::shared_ptr< GCTransferType > mg_transfer_gc_temperature
Transfer operator for global coarsening for the temperature.
unsigned int minlevel
Min level of the multigrid hierarchy.
void vmult(VectorType &dst, const VectorType &src) const
Calls the v cycle function of the multigrid object.
const MGLevelObject< std::shared_ptr< OperatorType > > & get_mg_operators() const
Getter function for all level operators.
void reinit(const std::shared_ptr< Mapping< dim > > &mapping, const std::shared_ptr< Quadrature< dim > > &cell_quadrature, const std::shared_ptr< Function< dim > > &forcing_function, const std::shared_ptr< SimulationControl > &simulation_control, const std::shared_ptr< PhysicalPropertiesManager > &physical_properties_manager, const std::shared_ptr< FESystem< dim > > &fe)
Initializes geometric multigrid preconditioner and pre-calculate terms that are constant.
std::vector< std::shared_ptr< const Triangulation< dim > > > coarse_grid_triangulations
Triangulations for the global coarsening case.
MGLevelObject< MGTwoLevelTransfer< dim, MGVectorType > > transfers_temperature
DoFHandler< dim > dof_handler_fe_q_iso_q1
Describes the layout of DoFs for FE_Q_iso_Q1 elements.
void print_relevant_info() const
Prints relevant multigrid information.
NavierStokesOperatorBase< dim, MGNumber > OperatorType
std::vector< unsigned int > coarse_grid_iterations
Vector holding number of coarse grid iterations.
MGLevelObject< MatrixFreeOperators::MGInterfaceOperator< OperatorType > > ls_mg_operators
const MGLevelObject< std::shared_ptr< PreconditionBase< MGVectorType > > > & get_mg_smoother_preconditioners() const
Getter function for all level smoother preconditioners.
MGLevelObject< MGTwoLevelTransfer< dim, MGVectorType > > transfers
Transfers for each of the levels of the global coarsening algorithm.
MGLevelObject< MatrixFreeOperators::MGInterfaceOperator< OperatorType > > ls_mg_interface_in
std::shared_ptr< GCTransferType > mg_transfer_gc
Transfer operator for global coarsening.
std::shared_ptr< Multigrid< MGVectorType > > mg_intermediate
Multigrid method (intermediate level).
MGLevelObject< MGConstrainedDoFs > mg_constrained_dofs
ConditionalOStream pcout
Conditional Ostream.
std::shared_ptr< MGSmootherBase< MGVectorType > > mg_smoother
std::shared_ptr< PreconditionMG< dim, MGVectorType, LSTransferType > > ls_multigrid_preconditioner
Local smoothing multigrid preconditioner object.
MGLevelObject< std::shared_ptr< MappingQCache< dim > > > mappings
MappingQCache for each of the levels of the global coarsening algorithm.
std::shared_ptr< PreconditionMG< dim, MGVectorType, LSTransferType > > ls_multigrid_preconditioner_intermediate
Local smoothing multigrid preconditioner object (intermediate level).
unsigned int intlevel
Intermediate level of the multigrid hierarchy.
std::shared_ptr< SolverGMRES< TrilinosVectorType > > coarse_grid_solver
GMRES as coarse grid solver.
virtual void create_level_operator(const unsigned int level)=0
Creates the operator for a given level.
MGLevelObject< DoFHandler< dim > > dof_handlers
DoF handlers for each of the levels of the global coarsening algorithm.
A geometric multigrid preconditioner implementation for incompressible flow.
void create_level_operator(const unsigned int level) override
Creates the operator for a given level.
MFNavierStokesPreconditionGMG(const SimulationParameters< dim > &simulation_parameters, const DoFHandler< dim > &dof_handler, const DoFHandler< dim > &dof_handler_fe_q_iso_q1)
typename MFNavierStokesPreconditionGMGBase< dim >::VectorType VectorType
void initialize(const std::shared_ptr< SimulationControl > &simulation_control, FlowControl< dim > &flow_control, const VectorType &present_solution, const VectorType &time_derivative_previous_solutions)
void initialize_auxiliary_physics(const DoFHandler< dim > &temperature_dof_handler, const VectorType &temperature_present_solution)
Transfer the current temperature solution to the different multigrid levels and compute the thermal b...
void restrict_and_add(const unsigned int from_level, VectorType &dst, const VectorType &src) const override
MGTransferMatrixFreeWrapper(const unsigned int min_h_level)
MGTransferMatrixFree< dim, MGNumber > ls
const unsigned int min_h_level
LinearAlgebra::distributed::Vector< MGNumber > VectorType
void build(const MGLevelObject< MGTwoLevelTransfer< dim, VectorType > > &transfers, const DoFHandler< dim > &dof_handler, const MGConstrainedDoFs &mg_constrained_dofs, const std::vector< std::shared_ptr< const Utilities::MPI::Partitioner > > &external_partitioners_in)
void interpolate_to_mg(const DoFHandler< dim > &dof_handler, MGLevelObject< VectorType > &dst, const InVectorType &src) const
void prolongate(const unsigned int to_level, VectorType &dst, const VectorType &src) const override
void copy_from_mg(const DoFHandler< dim, spacedim > &dof_handler, OutVector &dst, const MGLevelObject< VectorType > &src) const
MGTransferGlobalCoarsening< dim, VectorType > gc
void copy_to_mg(const DoFHandler< dim, spacedim > &dof_handler, MGLevelObject< VectorType > &dst, const InVector &src) const
DiagonalMatrix< VectorType > diagonal_matrix
DiagonalMatrix class from deal.II.
void vmult(VectorType &dst, const VectorType &src) const override
Apply preconditioner.
MyDiagonalMatrix(const VectorType &diagonal)
Constructor.
void box_refine_mesh(const bool restart)
std::shared_ptr< FESystem< dim > > fe
void connect_mortar_weight_signals()
std::shared_ptr< Quadrature< dim > > cell_quadrature
double get_residual_rescale_metric() const override
virtual void set_initial_condition(const Parameters::FluidDynamicsInitialConditionType initial_condition_type, const bool restart=false)
MPI_Comm mpi_communicator
IndexSet locally_owned_dofs
void define_zero_constraints()
SDIRKVectors sdirk_vectors
void rescale_pressure_dofs_in_newton_update()
std::shared_ptr< LinearAlgebra::distributed::Vector< double > > present_solution
LinearAlgebra::distributed::Vector< double > system_rhs
LinearAlgebra::distributed::Vector< double > newton_update
virtual void refine_mesh()
Allow the refinement of the mesh according to one of the 2 methods proposed.
void define_non_zero_constraints()
std::shared_ptr< Mapping< dim > > get_mapping()
virtual void finish_time_step()
void rotate_rotor_mapping(const bool is_first)
virtual void dynamic_flow_control()
SimulationParameters< dim > simulation_parameters
TimerOutput computing_timer
std::shared_ptr< std::vector< LinearAlgebra::distributed::Vector< double > > > previous_solutions
LinearAlgebra::distributed::Vector< double > evaluation_point
std::shared_ptr< MappingQCache< dim > > mapping_cache
std::shared_ptr< Function< dim > > forcing_function
std::shared_ptr< SimulationControl > simulation_control
LinearAlgebra::distributed::Vector< double > local_evaluation_point
FlowControl< dim > flow_control
std::shared_ptr< MultiphysicsInterface< dim > > multiphysics
NavierStokesBase(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
AffineConstraints< double > zero_constraints
virtual void update_forcing_and_boundary_conditions()
Set the time of the forcing function and of the time-dependent boundary conditions to the current tim...
std::shared_ptr< AverageVelocities< dim, LinearAlgebra::distributed::Vector< double >, IndexSet > > average_velocities
virtual void setup_dofs()
std::shared_ptr< Mapping< dim > > mapping
IndexSet locally_relevant_dofs
std::shared_ptr< DoFHandler< dim > > dof_handler
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
virtual void postprocess(bool first_iteration)
const unsigned int velocity_fem_degree
Implements the matrix-free operator to solve steady/transient non-Newtonian Navier-Stokes equations u...
A class that serves as base for all the matrix-free Navier-Stokes operators.
PhysicsSolver(const Parameters::NonLinearSolver non_linear_solver_parameters)
void solve_governing_system()
An Additive Schwarz preconditioner.
VectorType dst_internal
Internal destination vector with correct ghosting.
void initialize(const DoFHandler< dim > &dof_handler, const GlobalSparseMatrixType &global_sparse_matrix, const GlobalSparsityPattern &global_sparsity_pattern, const AffineConstraints< Number > &constraints, const std::shared_ptr< const Utilities::MPI::Partitioner > &partitioner, const unsigned int mg_level)
Initialize inverses of blocks.
std::vector< std::vector< unsigned int > > patches
DoF indices of patches.
VectorType src_internal
Internal source vector with correct ghosting.
typename VectorType::value_type Number
Value type.
const WeightingType weighting_type
Weighting type.
PreconditionASM()
Constructor.
WeightingType
Weighting type.
VectorType weights
Weights.
void vmult(VectorType &dst, const VectorType &src) const override
Apply preconditioner.
std::vector< LAPACKFullMatrix< Number > > blocks
Inverse of patch matrices.
A wrapper class around a preconditioner to be able to handle vector types that are not supported by t...
const std::function< void(VectorTypePrecondition &, const VectorTypePrecondition &)> fu_preconditioner
Preconditioner.
void vmult(U &dst, const U &src) const
Apply preconditioner.
void vmult(VectorType &dst, const VectorType &src) const override
Apply preconditioner.
VectorTypePrecondition dst_
Destination vector supported by the preconditioner.
PreconditionAdapter(const std::shared_ptr< PreconditionType > &preconditioner)
VectorTypePrecondition src_
Source vector supported by the preconditioner.
A base class of preconditioners used by the smoother.
virtual void vmult(VectorType &dst, const VectorType &src) const =0
Apply preconditioner.
void timer_reset() const
Reset timers.
PreconditionBase()
Constructor.
void timer_print() const
Print timers.
std::vector< double > a_ij
Parameters::Mortar< dim > mortar_parameters
Parameters::Stabilization stabilization
Parameters::FEM fem_parameters
ObserverPointer< const PreconditionerType, MGCoarseGridApplyPreconditioner< VectorType, PreconditionerType > > preconditioner
MGCoarseGridApplyPreconditioner()
void initialize(const PreconditionerType &precondition)
virtual void operator()(const unsigned int level, VectorType &dst, const VectorType &src) const override
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...
void read_mesh_and_manifolds_for_stator_and_rotor(parallel::DistributedTriangulationBase< dim, spacedim > &triangulation, const Parameters::Mesh< dim, spacedim > &mesh_parameters, const Parameters::Manifolds &manifolds_parameters, bool restart, const Parameters::PeriodicBoundaries &periodic_boundaries, const Parameters::Mortar< dim > &mortar_parameters)
Completely sets up a mesh and its manifolds for rotor-stator domains.
void read_mesh_and_manifolds(parallel::DistributedTriangulationBase< dim, spacedim > &triangulation, const Parameters::Mesh< dim, spacedim > &mesh_parameters, const Parameters::Manifolds &manifolds_parameters, bool restart, const Parameters::PeriodicBoundaries &periodic_boundaries)
Completely sets up a mesh and its manifolds.
Identifiers for multiphysics modules and their solution fields.
@ pressure
Pressure scalar field from fluid dynamics.
FluidDynamicsFormulation
Formulation of the fluid dynamics equations solved by a Navier-Stokes solver.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ heat_transfer
Heat transfer (Temperature).
FluidDynamicsBoundaryType
FluidDynamicsInitialConditionType
void read_checkpoint(TimerOutput &computing_timer, const DEMSolverParameters< dim > ¶meters, std::shared_ptr< SimulationControl > &simulation_control, PVDHandler &particles_pvdhandler, PVDHandler &grid_pvdhandler, parallel::distributed::Triangulation< dim > &triangulation, Particles::ParticleHandler< dim > &particle_handler, std::shared_ptr< Insertion< dim, PropertiesIndex > > &insertion_object, std::vector< std::shared_ptr< SerialSolid< dim - 1, dim > > > &solid_surfaces, CheckpointControl &checkpoint_controller)
Read a DEM simulation checkpoint, allowing the simulation to restart from where it stopped.
SDIRKTable sdirk_table(const Parameters::SimulationControl::TimeSteppingMethod method)
Construct the Butcher tableau (A, b, c) for a given SDIRK method.
void establish_solid_domain(const dealii::DoFHandler< dim > &dof_handler, const DofsType &locally_owned_dofs, const bool non_zero_constraints, dealii::AffineConstraints< double > &constraints)
Turn regions of the mesh where the material_id>0 into a solid block by injecting velocity and pressur...
void establish_solid_domain_lsmg(const dealii::DoFHandler< dim > &dof_handler, const unsigned int level, const dealii::IndexSet &locally_owned_mg_dofs, const bool non_zero_constraints, dealii::AffineConstraints< double > &constraints)
Multigrid-level variant of establish_solid_domain for the local smoothing multigrid (LSMG) preconditi...
unsigned int velocity_degree
unsigned int pressure_degree
MultigridSmootherPreconditionerType
Type of preconditioner for the MG smoother.
@ amg
Algebraic Multigrid.
@ lsmg
Local-Smoothing Geometric Multigrid.
@ ilu
Incomplete LU Factorization.
@ gcmg
Global-Coarsening Multigrid.
double pressure_scaling_factor
Structure representing a Butcher tableau for a SDIRK method.
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
void convert_vector_trilinos_to_dealii(dealii::LinearAlgebra::distributed::Vector< number > &out, const dealii::TrilinosWrappers::MPI::Vector &in)
Helper function that allows to convert Trilinos vectors to deal.II vectors.
void convert_vector_dealii_to_trilinos(dealii::TrilinosWrappers::MPI::Vector &out, const dealii::LinearAlgebra::distributed::Vector< number > &in)
Helper function that allows to convert deal.II vectors to Trilinos vectors.