17#include <deal.II/base/exceptions.h>
18#include <deal.II/base/work_stream.h>
20#include <deal.II/dofs/dof_renumbering.h>
21#include <deal.II/dofs/dof_tools.h>
23#include <deal.II/grid/grid_tools.h>
25#include <deal.II/lac/full_matrix.h>
26#include <deal.II/lac/solver_bicgstab.h>
27#include <deal.II/lac/solver_cg.h>
28#include <deal.II/lac/solver_control.h>
29#include <deal.II/lac/solver_gmres.h>
30#include <deal.II/lac/sparse_direct.h>
31#include <deal.II/lac/sparse_ilu.h>
33#include <deal.II/numerics/vector_tools.h>
46 fluid_dynamics_formulation)
52 .amg_precond_ilu_fill :
84 DoFTools::extract_locally_relevant_dofs(*this->
dof_handler);
139 for (
auto &solution : this->
sdirk_vectors.previous_k_j_solutions)
153 DoFTools::make_sparsity_pattern(*this->
dof_handler,
162 SparsityTools::distribute_sparsity_pattern(
165 this->mpi_communicator,
166 this->locally_relevant_dofs);
174 .calculate_average_velocities ||
175 this->simulation_parameters.initial_condition->type ==
183 double global_volume =
186 this->
pcout <<
" Number of active cells: "
188 <<
" Number of degrees of freedom: "
190 this->
pcout <<
" Volume of triangulation: " << global_volume
202 this->previous_solutions);
212 TimerOutput::Scope t(this->
computing_timer,
"Update mortar configuration");
219 !this->simulation_control->is_refinement_step(
220 this->simulation_parameters.mesh_adaptation) ||
221 this->simulation_parameters.mesh_adaptation.type ==
250 DoFTools::make_sparsity_pattern(*this->
dof_handler,
258 SparsityTools::distribute_sparsity_pattern(
261 this->mpi_communicator,
262 this->locally_relevant_dofs);
276 .calculate_average_velocities ||
277 this->simulation_parameters.initial_condition->type ==
297 DoFTools::make_hanging_node_constraints(*this->
dof_handler,
300 const DoFHandler<dim> &dof_handler_ht =
307 const DoFHandler<dim> &dof_handler_cls =
315 AffineConstraints<double>::MergeConflictBehavior::right_object_wins);
323 stasis_constraint_struct.dofs_are_in_solid.clear();
324 stasis_constraint_struct.dofs_are_connected_to_fluid.clear();
338 AffineConstraints<double> constraints_extended;
339 constraints_extended.reinit(this->
dof_handler->locally_owned_dofs(),
340 this->locally_relevant_dofs);
342 types::global_dof_index min_index = numbers::invalid_unsigned_int;
344 std::vector<types::global_dof_index> dof_indices;
347 for (
const auto &cell : this->
dof_handler->active_cell_iterators())
349 if (cell->is_locally_owned())
351 const auto &
fe = cell->get_fe();
353 dof_indices.resize(
fe.n_dofs_per_cell());
354 cell->get_dof_indices(dof_indices);
356 for (
unsigned int i = 0; i < dof_indices.size(); ++i)
357 if (
fe.system_to_component_index(i).first == dim)
358 min_index = std::min(min_index, dof_indices[i]);
364 Utilities::MPI::min(min_index, this->
dof_handler->get_mpi_communicator());
367 constraints_extended.add_line(min_index);
371 constraints_extended,
372 AffineConstraints<double>::MergeConflictBehavior::no_conflicts_allowed,
375 constraints_extended,
376 AffineConstraints<double>::MergeConflictBehavior::no_conflicts_allowed,
389 !this->simulation_parameters.multiphysics.cahn_hilliard,
390 ExcMessage(
"SDIRK time-stepping methods are not supported "
391 "for multiphase flows (CLS or Cahn-Hilliard). "
392 "Use a BDF method instead."));
394 .density_is_constant(),
395 ExcMessage(
"SDIRK time-stepping methods are not supported "
396 "for flows with a variable density. Use a BDF "
456 .get_reference_temperature()));
464 .get_reference_temperature()));
481 PhaseChangePermeabilityModelDoesNotSupportCHN());
493 this->simulation_parameters.physical_properties_manager
494 .density_is_constant())
511 .surface_tension_force.enable)
514 .surface_tension_force.enable_marangoni_effect)
519 .surface_tension_force));
542 PhaseChangePermeabilityModelRequiresTemperature());
546 .get_phase_change_parameters_vector(),
547 this->simulation_parameters.velocity_sources
548 .enable_darcy_multiply_by_density));
552 .permeability_model ==
554 carman_kozeny_phase_change)
557 PhaseChangePermeabilityModelRequiresTemperature());
561 .fluid_with_phase_change,
562 this->simulation_parameters.velocity_sources
563 .carman_kozeny_permeability_area,
564 this->simulation_parameters.velocity_sources
565 .carman_kozeny_tolerance,
566 this->simulation_parameters.physical_properties_manager
567 .get_phase_change_parameters_vector()));
579 .density_is_constant())
596 !this->simulation_parameters.multiphysics.cahn_hilliard)
602 .density_is_constant())
639 PhaseChangePermeabilityModelRequiresTemperature());
642 .enable_darcy_multiply_by_density,
643 SingleFluidPhaseChangeDarcyModelDoesNotSupportDensityMultiplication());
648 .get_physical_properties_parameters()
650 .phase_change_parameters));
654 .permeability_model ==
656 carman_kozeny_phase_change)
659 PhaseChangePermeabilityModelRequiresTemperature());
663 .carman_kozeny_permeability_area[0],
664 this->simulation_parameters.velocity_sources
665 .carman_kozeny_tolerance[0],
666 this->simulation_parameters.physical_properties_manager
667 .get_physical_properties_parameters()
669 .phase_change_parameters.T_liquidus,
671 this->simulation_parameters.physical_properties_manager
672 .get_physical_properties_parameters()
674 .phase_change_parameters.T_solidus));
689 .use_default_stabilization ==
true) ||
690 this->simulation_parameters.stabilization.stabilization ==
694 .density_is_constant())
712 .density_is_constant())
727 throw std::runtime_error(
728 "Using the GLS solver with a stabilization other than the pspg_supg or gls "
729 "stabilization will lead to an unstable solver that is unable to converge");
747 *this->cell_quadrature,
748 *this->get_mapping(),
749 *this->face_quadrature);
753 const DoFHandler<dim> &dof_handler_cls =
755 scratch_data.enable_cls(
756 dof_handler_cls.get_fe(),
757 *this->cell_quadrature,
758 *this->get_mapping(),
759 this->simulation_parameters.multiphysics.cls_parameters.phase_filter);
762 .surface_tension_force.enable)
764 const DoFHandler<dim>
765 &projected_phase_indicator_gradient_dof_handler =
767 ->get_projected_phase_indicator_gradient_dof_handler();
768 const DoFHandler<dim> &curvature_dof_handler =
770 scratch_data.enable_projected_phase_indicator_gradient(
771 projected_phase_indicator_gradient_dof_handler.get_fe(),
772 *this->cell_quadrature,
773 *this->get_mapping());
774 scratch_data.enable_curvature(curvature_dof_handler.get_fe(),
775 *this->cell_quadrature,
776 *this->get_mapping());
781 const DoFHandler<dim> &dof_handler_cahn_hilliard =
783 scratch_data.enable_cahn_hilliard(
784 dof_handler_cahn_hilliard.get_fe(),
785 *this->cell_quadrature,
786 *this->get_mapping(),
787 this->simulation_parameters.multiphysics.cahn_hilliard_parameters);
792 const DoFHandler<dim> &dof_handler_ht =
794 scratch_data.enable_heat_transfer(dof_handler_ht.get_fe(),
795 *this->cell_quadrature,
796 *this->get_mapping());
800 scratch_data.enable_mortar();
804 this->dof_handler->end(),
810 this->cell_quadrature->size()));
827 const typename DoFHandler<dim>::active_cell_iterator &cell,
832 if (!cell->is_locally_owned())
840 this->forcing_function,
841 this->flow_control.get_beta(),
842 this->simulation_parameters.stabilization.pressure_scaling_factor);
846 const DoFHandler<dim> &dof_handler_cls =
848 typename DoFHandler<dim>::active_cell_iterator phase_cell(
861 .surface_tension_force.enable)
863 const DoFHandler<dim>
864 &projected_phase_indicator_gradient_dof_handler =
866 ->get_projected_phase_indicator_gradient_dof_handler();
868 typename DoFHandler<dim>::active_cell_iterator
869 projected_phase_indicator_gradient_cell(
873 &projected_phase_indicator_gradient_dof_handler);
876 projected_phase_indicator_gradient_cell,
878 ->get_projected_phase_indicator_gradient_solution());
882 const DoFHandler<dim> &curvature_dof_handler =
884 typename DoFHandler<dim>::active_cell_iterator curvature_cell(
888 &curvature_dof_handler);
890 curvature_cell, this->
multiphysics->get_curvature_solution());
895 const DoFHandler<dim> &dof_handler_cahn_hilliard =
897 typename DoFHandler<dim>::active_cell_iterator phase_cell(
901 &dof_handler_cahn_hilliard);
911 const DoFHandler<dim> &dof_handler_ht =
914 typename DoFHandler<dim>::active_cell_iterator temperature_cell(
938 .get_number_of_solids() < 1 ||
939 cell->material_id() == 0)
943 assembler->assemble_matrix(scratch_data, copy_data);
958 const AffineConstraints<double> &zero_constraints_used =
962 zero_constraints_used.distribute_local_to_global(copy_data.
local_matrix,
964 this->system_matrix);
981 *this->cell_quadrature,
982 *this->get_mapping(),
983 *this->face_quadrature);
987 const DoFHandler<dim> &dof_handler_cls =
989 scratch_data.enable_cls(
990 dof_handler_cls.get_fe(),
991 *this->cell_quadrature,
992 *this->get_mapping(),
993 this->simulation_parameters.multiphysics.cls_parameters.phase_filter);
996 .surface_tension_force.enable)
998 const DoFHandler<dim>
999 &projected_phase_indicator_gradient_dof_handler =
1001 ->get_projected_phase_indicator_gradient_dof_handler();
1002 const DoFHandler<dim> &curvature_dof_handler =
1005 scratch_data.enable_projected_phase_indicator_gradient(
1006 projected_phase_indicator_gradient_dof_handler.get_fe(),
1007 *this->cell_quadrature,
1008 *this->get_mapping());
1009 scratch_data.enable_curvature(curvature_dof_handler.get_fe(),
1010 *this->cell_quadrature,
1011 *this->get_mapping());
1017 const DoFHandler<dim> &dof_handler_cahn_hilliard =
1019 scratch_data.enable_cahn_hilliard(
1020 dof_handler_cahn_hilliard.get_fe(),
1021 *this->cell_quadrature,
1022 *this->get_mapping(),
1023 this->simulation_parameters.multiphysics.cahn_hilliard_parameters);
1028 const DoFHandler<dim> &dof_handler_ht =
1030 scratch_data.enable_heat_transfer(dof_handler_ht.get_fe(),
1031 *this->cell_quadrature,
1032 *this->get_mapping());
1036 scratch_data.enable_mortar();
1040 this->dof_handler->end(),
1046 this->cell_quadrature->size()));
1053 this->
system_rhs.compress(VectorOperation::add);
1063 this->
system_rhs.compress(VectorOperation::add);
1073 const typename DoFHandler<dim>::active_cell_iterator &cell,
1078 if (!cell->is_locally_owned())
1086 this->forcing_function,
1087 this->flow_control.get_beta(),
1088 this->simulation_parameters.stabilization.pressure_scaling_factor);
1092 const DoFHandler<dim> &dof_handler_cls =
1094 typename DoFHandler<dim>::active_cell_iterator phase_cell(
1107 .surface_tension_force.enable)
1109 const DoFHandler<dim>
1110 &projected_phase_indicator_gradient_dof_handler =
1112 ->get_projected_phase_indicator_gradient_dof_handler();
1113 typename DoFHandler<dim>::active_cell_iterator
1114 projected_phase_indicator_gradient_cell(
1118 &projected_phase_indicator_gradient_dof_handler);
1120 projected_phase_indicator_gradient_cell,
1122 ->get_projected_phase_indicator_gradient_solution());
1124 const DoFHandler<dim> &curvature_dof_handler =
1126 typename DoFHandler<dim>::active_cell_iterator curvature_cell(
1130 &curvature_dof_handler);
1132 curvature_cell, this->
multiphysics->get_curvature_solution());
1137 const DoFHandler<dim> &dof_handler_cahn_hilliard =
1139 typename DoFHandler<dim>::active_cell_iterator phase_cell(
1143 &dof_handler_cahn_hilliard);
1153 const DoFHandler<dim> &dof_handler_ht =
1156 typename DoFHandler<dim>::active_cell_iterator temperature_cell(
1180 .get_number_of_solids() < 1 ||
1181 cell->material_id() == 0)
1185 assembler->assemble_rhs(scratch_data, copy_data);
1203 const AffineConstraints<double> &zero_constraints_used =
1207 zero_constraints_used.distribute_local_to_global(copy_data.
local_rhs,
1223 this->
pcout <<
"************************" << std::endl;
1224 this->
pcout <<
"---> Simulation Restart " << std::endl;
1225 this->
pcout <<
"************************" << std::endl;
1228 else if (initial_condition_type ==
1237 else if (initial_condition_type ==
1243 else if (initial_condition_type ==
1247 std::shared_ptr<RheologicalModel> original_viscosity_model =
1251 std::shared_ptr<Newtonian> temporary_rheology =
1252 std::make_shared<Newtonian>(
1256 temporary_rheology);
1261 const auto original_assembly_method =
1273 original_viscosity_model);
1275 else if (initial_condition_type ==
1278 this->
pcout <<
"*********************************" << std::endl;
1279 this->
pcout <<
" Initial condition using ramp " << std::endl;
1280 this->
pcout <<
"*********************************" << std::endl;
1290 const auto original_assembly_method =
1294 std::shared_ptr<RheologicalModel> viscosity_model =
1298 const double n_end = viscosity_model->get_n();
1299 const double viscosity_end = viscosity_model->get_kinematic_viscosity();
1304 const int n_iter_n =
1306 const double alpha_n =
1310 const int n_iter_viscosity =
1313 double kinematic_viscosity =
1314 n_iter_viscosity > 0 ?
1316 .kinematic_viscosity_init :
1318 const double alpha_viscosity =
1322 viscosity_model->set_kinematic_viscosity(kinematic_viscosity);
1325 for (
int i = 0; i < n_iter_n; ++i)
1327 this->
pcout <<
"********* Solution for n = " + std::to_string(n) +
1328 " and viscosity = " +
1329 std::to_string(kinematic_viscosity) +
" *********"
1332 viscosity_model->set_n(n);
1339 n += alpha_n * (n_end - n);
1343 viscosity_model->set_n(n_end);
1346 for (
int i = 0; i < n_iter_viscosity; ++i)
1348 this->
pcout <<
"********* Solution for n = " + std::to_string(n_end) +
1349 " and viscosity = " +
1350 std::to_string(kinematic_viscosity) +
" *********"
1353 viscosity_model->set_kinematic_viscosity(kinematic_viscosity);
1360 kinematic_viscosity +=
1361 alpha_viscosity * (viscosity_end - kinematic_viscosity);
1365 viscosity_model->set_kinematic_viscosity(viscosity_end);
1375 this->
pcout <<
"*********************************" << std::endl;
1376 this->
pcout <<
" Time spent in ramp: " << timer.wall_time() <<
"s"
1378 this->
pcout <<
"*********************************" << std::endl;
1381 else if (initial_condition_type ==
1383 average_velocity_profile)
1386 "Initial condition using average velocity profile");
1388 std::string checkpoint_file_name =
1391 ->average_velocity_file_name;
1399 auto simulation_control_info =
1401 checkpoint_file_name);
1407 simulation_control_info[0],
1408 simulation_control_info[1]);
1416 throw std::runtime_error(
"GLSNS - Initial condition could not be set");
1429 update_values | update_quadrature_points |
1431 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
1433 FullMatrix<double> local_matrix(dofs_per_cell, dofs_per_cell);
1434 Vector<double> local_rhs(dofs_per_cell);
1435 std::vector<Vector<double>> initial_velocity(n_q_points,
1436 Vector<double>(dim + 1));
1437 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1438 const FEValuesExtractors::Vector velocities(0);
1439 const FEValuesExtractors::Scalar
pressure(dim);
1441 Tensor<1, dim> rhs_initial_velocity_pressure;
1442 double rhs_initial_pressure;
1444 std::vector<Tensor<1, dim>> phi_u(dofs_per_cell);
1445 std::vector<double> phi_p(dofs_per_cell);
1447 for (
const auto &cell : this->
dof_handler->active_cell_iterators())
1449 if (cell->is_locally_owned())
1451 fe_values.reinit(cell);
1455 fe_values.get_quadrature_points(), initial_velocity);
1456 for (
unsigned int q = 0; q < n_q_points; ++q)
1458 for (
unsigned int k = 0; k < dofs_per_cell; ++k)
1460 phi_p[k] = fe_values[
pressure].value(k, q);
1461 phi_u[k] = fe_values[velocities].value(k, q);
1465 for (
int i = 0; i < dim; ++i)
1467 const unsigned int component_i =
1468 this->
fe->system_to_component_index(i).first;
1469 rhs_initial_velocity_pressure[i] =
1470 initial_velocity[q](component_i);
1472 rhs_initial_pressure = initial_velocity[q](dim);
1474 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1477 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1479 local_matrix(i, j) +=
1480 (phi_u[j] * phi_u[i]) * fe_values.JxW(q);
1481 local_matrix(i, j) +=
1482 (phi_p[j] * phi_p[i]) * fe_values.JxW(q);
1484 local_rhs(i) += (phi_u[i] * rhs_initial_velocity_pressure +
1485 phi_p[i] * rhs_initial_pressure) *
1490 cell->get_dof_indices(local_dof_indices);
1500 this->
system_rhs.compress(VectorOperation::add);
1507 const double absolute_residual =
1510 const double relative_residual =
1534 "This linear solver is not supported. Only <gmres>, <bicgstab> and <direct> linear solvers are supported."));
1560 "This linear solver does not support this preconditioner. Only <ilu> and <amg> preconditioners are supported."));
1570 const double ilu_atol =
1573 const double ilu_rtol =
1576 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
1591 std::vector<std::vector<bool>> constant_modes;
1594 ComponentMask components(dim + 1,
true);
1596 DoFTools::extract_constant_modes(*this->
dof_handler, components);
1598 const bool elliptic =
false;
1599 bool higher_order_elements =
false;
1601 higher_order_elements =
true;
1602 const unsigned int n_cycles =
1605 const bool w_cycle =
1608 const double aggregation_threshold =
1610 .amg_aggregation_threshold;
1611 const unsigned int smoother_sweeps =
1613 .amg_smoother_sweeps;
1614 const unsigned int smoother_overlap =
1616 .amg_smoother_overlap;
1617 const bool output_details =
false;
1618 const char *smoother_type =
"ILU";
1619 const char *coarse_type =
"ILU";
1620 TrilinosWrappers::PreconditionAMG::AdditionalData preconditionerOptions(
1622 higher_order_elements,
1625 aggregation_threshold,
1633 Teuchos::ParameterList parameter_ml;
1634 std::unique_ptr<Epetra_MultiVector> distributed_constant_modes;
1635 preconditionerOptions.set_parameters(parameter_ml,
1636 distributed_constant_modes,
1639 const double ilu_atol =
1641 .amg_precond_ilu_atol;
1642 const double ilu_rtol =
1644 .amg_precond_ilu_rtol;
1645 parameter_ml.set(
"smoother: ifpack level-of-fill", ilu_fill);
1646 parameter_ml.set(
"smoother: ifpack absolute threshold", ilu_atol);
1647 parameter_ml.set(
"smoother: ifpack relative threshold", ilu_rtol);
1649 parameter_ml.set(
"coarse: ifpack level-of-fill", ilu_fill);
1650 parameter_ml.set(
"coarse: ifpack absolute threshold", ilu_atol);
1651 parameter_ml.set(
"coarse: ifpack relative threshold", ilu_rtol);
1659 const double absolute_residual,
1660 const double relative_residual)
1662 const unsigned int max_iter = 3;
1663 unsigned int iter = 0;
1664 bool success =
false;
1668 const AffineConstraints<double> &zero_constraints_used =
1674 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
1675 const double linear_solver_tolerance =
1676 std::max(relative_residual * current_residual, absolute_residual);
1680 this->
pcout <<
" -Tolerance of iterative solver is : "
1681 << linear_solver_tolerance << std::endl;
1683 const double non_rescaled_linear_solver_tolerance =
1684 linear_solver_tolerance * rescale_metric;
1691 non_rescaled_linear_solver_tolerance,
1694 bool extra_verbose =
false;
1697 extra_verbose =
true;
1699 TrilinosWrappers::SolverGMRES::AdditionalData solver_parameters(
1702 .max_krylov_vectors);
1711 "This linear solver does not support this preconditioner. Only <ilu> and <amg> preconditioners are supported."));
1719 while (success ==
false and iter < max_iter)
1726 TrilinosWrappers::SolverGMRES solver(solver_control,
1737 completely_distributed_solution,
1745 completely_distributed_solution,
1754 <<
" -Iterative solver took : " << solver_control.last_step()
1755 <<
" steps to reach a residual norm of "
1756 << solver_control.last_value() / rescale_metric << std::endl;
1761 "Distribute constraints after linear solver");
1763 zero_constraints_used.distribute(completely_distributed_solution);
1766 "Distribute constraints after linear solver");
1772 catch (
const std::exception &e)
1774 const bool last_attempt = (iter == max_iter - 1);
1778 .force_linear_solver_continuation)
1780 this->
pcout <<
" GMRES solver failed after " << max_iter
1781 <<
" attempts." << std::endl;
1782 if (
const auto *nc =
1783 dynamic_cast<const SolverControl::NoConvergence *
>(&e))
1784 this->
pcout <<
" Last attempt stopped at iteration "
1785 << nc->last_step <<
" with a residual of "
1786 << nc->last_residual / rescale_metric
1787 <<
" (tolerance " << linear_solver_tolerance <<
")."
1794 <<
" GMRES solver failed! Trying with a higher preconditioner fill level. New fill = "
1798 if (iter == max_iter - 1)
1802 .force_linear_solver_continuation)
1808 <<
" GMRES solver failed! Continuing the Newton step as requested by the <force linear solver continuation> parameter."
1823 <<
" The Newton update contains non-finite values; resetting it to zero."
1839 const double relative_residual)
1841 const unsigned int max_iter = 3;
1842 unsigned int iter = 0;
1843 bool success =
false;
1846 this->nonzero_constraints;
1848 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
1849 const double linear_solver_tolerance =
1850 std::max(relative_residual * current_residual, absolute_residual);
1854 this->
pcout <<
" -Tolerance of iterative solver is : "
1855 << linear_solver_tolerance << std::endl;
1857 const double non_rescaled_linear_solver_tolerance =
1858 linear_solver_tolerance * rescale_metric;
1866 non_rescaled_linear_solver_tolerance,
1869 bool extra_verbose =
false;
1872 extra_verbose =
true;
1874 TrilinosWrappers::SolverGMRES::AdditionalData solver_parameters(
1877 .max_krylov_vectors);
1886 "This linear solver does not support this preconditioner. Only <ilu> and <amg> preconditioners are supported."));
1894 while (success ==
false and iter < max_iter)
1901 TrilinosWrappers::SolverGMRES solver(solver_control,
1912 completely_distributed_solution,
1920 completely_distributed_solution,
1929 <<
" -Iterative solver took : " << solver_control.last_step()
1930 <<
" steps to reach a residual norm of "
1931 << solver_control.last_value() / rescale_metric << std::endl;
1936 "Distribute constraints after linear solver");
1941 "Distribute constraints after linear solver");
1947 catch (
const std::exception &e)
1949 const bool last_attempt = (iter == max_iter - 1);
1953 .force_linear_solver_continuation)
1956 <<
" GMRES solver failed while solving the L2 projection problem after "
1957 << max_iter <<
" attempts." << std::endl;
1958 if (
const auto *nc =
1959 dynamic_cast<const SolverControl::NoConvergence *
>(&e))
1960 this->
pcout <<
" Last attempt stopped at iteration "
1961 << nc->last_step <<
" with a residual of "
1962 << nc->last_residual / rescale_metric
1963 <<
" (tolerance " << linear_solver_tolerance <<
")."
1970 <<
" GMRES solver failed while solving the L2 projection problem! Trying with a higher preconditioner fill level. New fill = "
1987 const double absolute_residual,
1988 const double relative_residual)
1991 const unsigned int max_iter = 3;
1992 unsigned int iter = 0;
1993 bool success =
false;
1998 const AffineConstraints<double> &zero_constraints_used =
2004 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
2005 const double linear_solver_tolerance =
2006 std::max(relative_residual * current_residual, absolute_residual);
2010 this->
pcout <<
" -Tolerance of iterative solver is : "
2011 << linear_solver_tolerance << std::endl;
2013 const double non_rescaled_linear_solver_tolerance =
2014 linear_solver_tolerance * rescale_metric;
2018 bool extra_verbose =
false;
2021 extra_verbose =
true;
2022 TrilinosWrappers::SolverBicgstab::AdditionalData solver_parameters(
2028 non_rescaled_linear_solver_tolerance,
2031 TrilinosWrappers::SolverBicgstab solver(solver_control, solver_parameters);
2037 "This linear solver does not support this preconditioner. Only <ilu> preconditioner is supported."));
2039 while (success ==
false and iter < max_iter)
2054 completely_distributed_solution,
2063 <<
" -Iterative solver took : " << solver_control.last_step()
2064 <<
" steps to reach a residual norm of "
2065 << solver_control.last_value() / rescale_metric << std::endl;
2067 zero_constraints_used.distribute(completely_distributed_solution);
2072 catch (
const std::exception &e)
2074 const bool last_attempt = (iter == max_iter - 1);
2078 .force_linear_solver_continuation)
2080 this->
pcout <<
" BiCGStab solver failed after " << max_iter
2081 <<
" attempts." << std::endl;
2082 if (
const auto *nc =
2083 dynamic_cast<const SolverControl::NoConvergence *
>(&e))
2085 this->
pcout <<
" Last attempt stopped at iteration "
2086 << nc->last_step <<
" with a residual of "
2087 << nc->last_residual / rescale_metric
2088 <<
" (tolerance " << linear_solver_tolerance
2089 <<
")." << std::endl;
2091 if (!std::isfinite(nc->last_residual))
2093 <<
" The residual is not finite, which indicates a breakdown of the BiCGStab iteration or of the preconditioner."
2095 else if (nc->last_step < solver_control.max_steps())
2097 <<
" The iteration budget was not exhausted, which points to a BiCGStab breakdown rather than slow convergence."
2104 <<
" BiCGStab solver failed! Trying with a higher preconditioner fill level. New fill = "
2116 const double absolute_residual,
2117 const double relative_residual)
2121 const AffineConstraints<double> &zero_constraints_used =
2127 const double current_residual = this->
system_rhs.l2_norm() / rescale_metric;
2128 const double linear_solver_tolerance =
2129 std::max(relative_residual * current_residual, absolute_residual);
2130 const double non_rescaled_linear_solver_tolerance =
2131 linear_solver_tolerance * rescale_metric;
2139 non_rescaled_linear_solver_tolerance,
2142 TrilinosWrappers::SolverDirect solver(solver_control);
2145 solver.solve(completely_distributed_solution,
system_rhs);
2146 zero_constraints_used.distribute(completely_distributed_solution);
2158 auto &previous_k_j_solutions = this->
sdirk_vectors.previous_k_j_solutions;
2159 auto &sum_over_previous_stages = this->
sdirk_vectors.sum_over_previous_stages;
2160 auto &local_sum_over_previous_stages =
2162 auto &locally_owned_for_calculation =
2173 const double a_ii = stage_data.
a_ij[stage];
2177 local_sum_over_previous_stages = 0;
2184 for (
unsigned int p = 0; p < stage; ++p)
2186 locally_owned_for_calculation = previous_k_j_solutions[p];
2187 local_sum_over_previous_stages.add(stage_data.
a_ij[p] / a_ii,
2188 locally_owned_for_calculation);
2192 sum_over_previous_stages = local_sum_over_previous_stages;
2206 auto &local_sum_over_previous_stages =
2209 auto &locally_owned_for_calculation =
2212 auto &previous_k_j_solutions = this->
sdirk_vectors.previous_k_j_solutions;
2215 auto &local_sum_bi_ki = this->
sdirk_vectors.local_sum_bi_ki;
2219 const double a_ii = stage_data.
a_ij[stage];
2236 const double b_i = stage_data.
b_i;
2238 sum_bi_ki = local_sum_bi_ki;
2252 auto &local_sum_bi_ki = this->
sdirk_vectors.local_sum_bi_ki;
2255 local_sum_bi_ki = sum_bi_ki;
2275 this->simulation_parameters.manifolds_parameters,
2276 this->simulation_parameters.restart_parameters.restart,
2277 this->simulation_parameters.boundary_conditions.periodic_boundaries,
2278 this->simulation_parameters.mortar_parameters);
2288 this->simulation_parameters.manifolds_parameters,
2289 this->simulation_parameters.restart_parameters.restart,
2290 this->simulation_parameters.boundary_conditions.periodic_boundaries);
2299 this->simulation_parameters.restart_parameters.restart);
A solver class for the Navier-Stokes equation using GLS stabilization.
void define_dynamic_zero_constraints()
Define the zero constraints used to solved the problem that change with other physics' solutions.
virtual void solve()
solve Solves the Navier-Stokes problem
TrilinosWrappers::SparseMatrix system_matrix
void assemble_L2_projection()
Assembles an L2_projection matrix for the velocity and the pressure. This L2 projection matrix can be...
virtual void copy_local_rhs_to_global_rhs(const StabilizedMethodsTensorCopyData< dim > ©_data)
Copy local cell rhs information to global rhs.
virtual void update_multiphysics_time_average_solution() override
Updates the average velocity field solution in the multiphyscics interface.
std::shared_ptr< TrilinosWrappers::PreconditionAMG > amg_preconditioner
void solve_linear_system() override
Call for the assembly of the linear system of equation.
void setup_AMG()
Set-up AMG preconditioner.
virtual void setup_assemblers()
sets up the vector of assembler functions
void define_pressure_constraints()
Fix a constant pressure on the minimum dof index. This can be enabled in the simulation control param...
virtual void set_initial_condition_fd(Parameters::FluidDynamicsInitialConditionType initial_condition_type, bool restart=false) override
Sets the initial condition for the solver.
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
virtual void multi_stage_postresolution(unsigned int stage, Parameters::SimulationControl::TimeSteppingMethod method, double time_step) override
Calculate from Update .
virtual void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > ©_data)
Assemble the local rhs for a given cell.
virtual void update_mortar_configuration() override
Update mortar configuration.
void solve_system_BiCGStab(const double absolute_residual, const double relative_residual)
BiCGStab solver with ILU(N) preconditioning.
void solve_system_direct(const double absolute_residual, const double relative_residual)
Direct solver using TrilinosWrappers::SolverDirect The use of this solver should be avoided for 3D pr...
virtual void assemble_system_matrix() override
Assembles the matrix associated with the solver.
int initial_preconditioner_fill_level
void setup_preconditioner() override
Set-up the appropriate 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 setup_ILU()
Set-up ILU preconditioner.
~FluidDynamicsMatrixBased()
int current_preconditioner_fill_level
virtual void setup_dofs_fd() override
setup_dofs_fd Setup the degree of freedom, system matrix and solution vectors Navier-Stokes problem
void solve_L2_system(const double absolute_residual, const double relative_residual)
Solver for the L2 Projection linear system at the initial time step to apply this initial condition....
void solve_system_GMRES(const double absolute_residual, const double relative_residual)
GMRES solver with ILU(N) preconditioning or AMG preconditioning.
virtual void copy_local_matrix_to_global_matrix(const StabilizedMethodsTensorCopyData< dim > ©_data)
Copy local cell information to global matrix.
virtual void update_multi_stage_solution(double time_step) override
virtual void assemble_system_rhs() override
Assemble the rhs associated with the solver.
virtual void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > ©_data)
Assemble the local matrix for a given cell.
FluidDynamicsMatrixBased(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
Construct the matrix-based Navier-Stokes solver.
Class that assembles the transient time arising from BDF time integration for the isothermal compress...
Class that assembles the core of the isothermal compressible Navier-Stokes equations....
Class that assembles the core of the Navier-Stokes equation with free surface using CLS modeling....
Class that assembles the transient time arising from BDF time integration for the Navier Stokes equat...
Class that assembles the core of the Navier-Stokes equation. According to the following weak form: ...
Class that assembles the core of the Navier-Stokes equation using a Rheological model to predict non-...
Class that assembles the transient term arising from SDIRK time integration for the Navier Stokes equ...
Class that assembles the coriolis and the centrifugal if a simulation is carried out in a rotating fr...
Assembles the transient time arising from BDF time integration for the Navier-Stokes equation with fr...
Assembles the core of the Navier-Stokes equation with free surface using CLS modeling....
Assembles the Marangoni effect for the Navier-Stokes equations according to the following equation:
Assembles the core of the Navier-Stokes equation using a Rheological model to predict non-Newtonian b...
Assembles the Surface Tension Force (STF) for the Navier-Stokes equations according to the following ...
Class that assembles the transient time arising from BDF time integration for the Navier-Stokes equat...
Class that assembles the core of the Navier-Stokes equation with free surface using Cahn-Hilliard mod...
std::vector< StasisConstraintWithTemperature > stasis_constraint_structs
void constrain_stasis_with_temperature(const DoFHandler< dim > *dof_handler_ht)
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
AffineConstraints< double > nonzero_constraints
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 constrain_stasis_with_temperature_cls(const DoFHandler< dim > *dof_handler_cls, const DoFHandler< dim > *dof_handler_ht)
void rescale_pressure_dofs_in_newton_update()
std::shared_ptr< GlobalVectorType > present_solution
GlobalVectorType system_rhs
GlobalVectorType newton_update
virtual AffineConstraints< double > & get_nonzero_constraints() override
virtual void refine_mesh()
Allow the refinement of the mesh according to one of the 2 methods proposed.
void define_non_zero_constraints()
virtual void enable_dynamic_zero_constraints_fd()
std::shared_ptr< Mapping< dim > > get_mapping()
virtual void finish_time_step()
void rotate_rotor_mapping(const bool is_first)
AffineConstraints< double > dynamic_zero_constraints
virtual void dynamic_flow_control()
SimulationParameters< dim > simulation_parameters
bool check_existance_of_bc(BoundaryConditions::FluidDynamicsBoundaryType bc)
std::shared_ptr< CouplingOperator< dim, double > > mortar_coupling_operator
TimerOutput computing_timer
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
GlobalVectorType evaluation_point
std::shared_ptr< MappingQCache< dim > > mapping_cache
std::shared_ptr< SimulationControl > simulation_control
GlobalVectorType local_evaluation_point
std::vector< std::shared_ptr< NavierStokesAssemblerBase< dim > > > assemblers
std::shared_ptr< MultiphysicsInterface< dim > > multiphysics
virtual void set_solution_from_checkpoint(const std::string &checkpoint_file_prefix)
NavierStokesBase(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
AffineConstraints< double > zero_constraints
virtual void update_forcing_and_boundary_conditions()
std::shared_ptr< AverageVelocities< dim, GlobalVectorType, 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
void reinit_mortar_operators()
virtual void postprocess(bool first_iteration)
const unsigned int velocity_fem_degree
Assembles the momentum source due to evaporation for the Navier-Stokes equations.
Class that stores the information required by the assembly procedure for a Navier-Stokes equation....
void reinit_mortar(const typename DoFHandler< dim >::active_cell_iterator &cell, const Parameters::Mortar< dim > &mortar_parameters)
Renitialize the content of the scratch data for mortar.
void reinit_projected_phase_indicator_gradient(const typename DoFHandler< dim >::active_cell_iterator &projected_phase_indicator_gradient_cell, const VectorType ¤t_projected_phase_indicator_gradient_solution)
void calculate_physical_properties()
Calculates the physical properties. This function calculates the physical properties that may be requ...
void reinit(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const std::vector< VectorType > &previous_solutions, const VectorType &sum_over_previous_stages, const std::shared_ptr< Function< dim > > &forcing_function, const Tensor< 1, dim > &beta_force, const double pressure_scaling_factor)
Reinitializes the content of the scratch.
void reinit_heat_transfer(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const std::vector< VectorType > &previous_solutions)
Reinitialize the content of the scratch for the heat transfer auxiliary physic.
void reinit_ale(const Parameters::ALE< dim > &ale)
Renitialize the content of the scratch data for ALE.
void reinit_cahn_hilliard(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const VectorType ¤t_filtered_solution)
Reinitialize the content of the scratch for CH.
void reinit_cls(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const VectorType ¤t_filtered_solution, const std::vector< VectorType > &previous_solutions)
Reinitialize the content of the scratch for the cls.
void reinit_curvature(const typename DoFHandler< dim >::active_cell_iterator &curvature_cell, const VectorType ¤t_curvature_solution)
Class that assembles a Neumann traction boundary condition. According to the following weak form: a...
Class that assembles the weak formulation of an outlet boundary condition according to the following ...
Class that assembles the core of the Navier-Stokes equation. According to the following weak form: ...
Class that assembles the special case of partial slip condition using the weak formulation of a Diric...
Assembler of the non-linear Carman-Kozeny permeability model for simulations with phase change.
Assembler of the non-linear Carman-Kozeny permeability model for CLS simulations with phase change.
Class that assembles a phase change Darcy forcing term. This term adds to the right hand-side of the...
Assembles a phase change Darcy forcing term for a CLS two-fluid simulation. The term is added to the...
void solve_governing_system()
Solve the global system of equations according to a given strategy, either linear or not.
Class that assembles a Neumann boundary condition. According to the following weak form: (p-mu*grad_u...
std::vector< double > a_ij
Class responsible for storing the information calculated using the assembly of stabilized Tensor<1,...
FullMatrix< double > local_matrix
Vector< double > local_rhs
void reset()
Resets the cell_matrix, cell_rhs, strong_residual and strong_jacobian to zero.
std::vector< types::global_dof_index > local_dof_indices
Assembles the thermal buoyancy source term for CLS simulations. This assembler includes density expli...
Class that assembles a thermal buoyancy forcing term using the Boussinesq approximation....
Class that assembles the weak formulation of a Dirichlet boundary condition using the Nitsche method....
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).
@ cahn_hilliard
Cahn-Hilliard (Phase indicator, Potential).
FluidDynamicsInitialConditionType
@ average_velocity_profile
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.
@ amg
Algebraic Multigrid.
@ ilu
Incomplete LU Factorization.
@ none
No Darcy source term.
Structure representing a Butcher tableau for a SDIRK method.
Struct containing fluid id, temperature and phase indicator range information, and flag containers fo...
bool time_stepping_is_bdf(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the bdf family.
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType