13#include <deal.II/base/work_stream.h>
15#include <deal.II/dofs/dof_renumbering.h>
16#include <deal.II/dofs/dof_tools.h>
18#include <deal.II/grid/grid_tools.h>
20#include <deal.II/lac/affine_constraints.h>
21#include <deal.II/lac/dynamic_sparsity_pattern.h>
22#include <deal.II/lac/solver_control.h>
23#include <deal.II/lac/sparsity_tools.h>
24#include <deal.II/lac/trilinos_precondition.h>
25#include <deal.II/lac/trilinos_solver.h>
27#include <deal.II/meshworker/mesh_loop.h>
29#include <deal.II/numerics/error_estimator.h>
30#include <deal.II/numerics/vector_tools.h>
41 "The SDIRK scheme is not yet supported for this physics"));
58 std::make_shared<TracerAssemblerBoundaryNitsche<dim>>(
66 "Mortar coupling is not yet supported for the tracer physics when the DG formulation is used."));
74 auto reaction_constant_model =
76 .get_tracer_reaction_prefactor();
77 if (!std::dynamic_pointer_cast<NoneTracerReactionPrefactor>(
78 reaction_constant_model))
106 const DoFHandler<dim> &dof_handler_fluid =
112 *this->cell_quadrature,
113 *this->face_quadrature,
114 *this->get_mapping(),
115 dof_handler_fluid.get_fe(),
119 this->dof_handler->end(),
125 this->cell_quadrature->size()));
144 const DoFHandler<dim> &dof_handler_fluid =
150 *this->cell_quadrature,
151 *this->face_quadrature,
152 *this->get_mapping(),
153 dof_handler_fluid.get_fe(),
157 this->cell_quadrature->size());
162 const auto cell_worker =
163 [&](
const typename DoFHandler<dim>::active_cell_iterator &cell,
169 const auto boundary_worker =
170 [&](
const typename DoFHandler<dim>::active_cell_iterator &cell,
171 const unsigned int &face_no,
174 const auto boundary_index = cell->face(face_no)->boundary_id();
176 scratch_data.reinit_boundary_face(cell,
181 scratch_data.reinit_signed_distance_at_face(
182 cell, face_no, this->
multiphysics->get_immersed_solid_shape());
185 const DoFHandler<dim> &dof_handler_fluid =
188 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
189 &(*
triangulation), cell->level(), cell->index(), &dof_handler_fluid);
196 scratch_data.calculate_face_physical_properties();
201 const auto face_worker =
202 [&](
const typename DoFHandler<dim>::active_cell_iterator &cell,
203 const unsigned int &face_no,
204 const unsigned int &sub_face_no,
205 const typename DoFHandler<dim>::active_cell_iterator &neigh_cell,
206 const unsigned int &neigh_face_no,
207 const unsigned int &neigh_sub_face_no,
210 scratch_data.reinit_internal_face(cell,
218 scratch_data.reinit_signed_distance_at_face(
219 cell, face_no, this->
multiphysics->get_immersed_solid_shape());
224 auto ©_data_face = copy_data.
face_data.back();
225 copy_data_face.face_matrix.reinit(scratch_data.n_interface_dofs,
226 scratch_data.n_interface_dofs);
227 copy_data_face.joint_dof_indices =
228 scratch_data.fe_interface_values_tracer.get_interface_dof_indices();
231 const DoFHandler<dim> &dof_handler_fluid =
234 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
235 &(*
triangulation), cell->level(), cell->index(), &dof_handler_fluid);
242 scratch_data.calculate_face_physical_properties();
252 for (
const auto &cdf : copy_data.
face_data)
254 constraints_used.distribute_local_to_global(cdf.face_matrix,
255 cdf.joint_dof_indices,
260 MeshWorker::mesh_loop(this->
dof_handler->begin_active(),
261 this->dof_handler->end(),
266 MeshWorker::assemble_own_cells |
267 MeshWorker::assemble_boundary_faces |
268 MeshWorker::assemble_own_interior_faces_once |
269 MeshWorker::assemble_ghost_faces_both,
279 const typename DoFHandler<dim>::active_cell_iterator &cell,
284 if (!cell->is_locally_owned())
295 const DoFHandler<dim> &dof_handler_fluid =
298 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
299 &(*
triangulation), cell->level(), cell->index(), &dof_handler_fluid);
307 average_velocity_profile &&
308 !this->simulation_parameters.multiphysics.fluid_dynamics &&
310 this->simulation_parameters.post_processing
311 .initial_time_for_average_velocities)
317 this->simulation_parameters.ale,
318 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
325 this->simulation_parameters.ale,
326 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
335 average_velocity_profile &&
336 !this->simulation_parameters.multiphysics.fluid_dynamics &&
338 this->simulation_parameters.post_processing
339 .initial_time_for_average_velocities)
344 this->simulation_parameters.ale,
345 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
352 this->simulation_parameters.ale,
353 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
360 this->simulation_control->get_current_time());
367 assembler->assemble_matrix(scratch_data, copy_data);
383 constraints_used.distribute_local_to_global(copy_data.
local_matrix,
415 const DoFHandler<dim> &dof_handler_fluid =
421 *this->cell_quadrature,
422 *this->face_quadrature,
423 *this->get_mapping(),
424 dof_handler_fluid.get_fe(),
428 this->dof_handler->end(),
434 this->cell_quadrature->size()));
441 this->
system_rhs.compress(VectorOperation::add);
451 this->
system_rhs.compress(VectorOperation::add);
458 const DoFHandler<dim> &dof_handler_fluid =
464 *this->cell_quadrature,
465 *this->face_quadrature,
466 *this->get_mapping(),
467 dof_handler_fluid.get_fe(),
471 this->cell_quadrature->size());
473 const auto cell_worker =
474 [&](
const typename DoFHandler<dim>::active_cell_iterator &cell,
480 const auto boundary_worker =
481 [&](
const typename DoFHandler<dim>::active_cell_iterator &cell,
482 const unsigned int &face_no,
486 const auto boundary_index = cell->face(face_no)->boundary_id();
488 scratch_data.reinit_boundary_face(cell,
493 scratch_data.reinit_signed_distance_at_face(
494 cell, face_no, this->
multiphysics->get_immersed_solid_shape());
498 const DoFHandler<dim> &dof_handler_fluid =
501 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
502 &(*
triangulation), cell->level(), cell->index(), &dof_handler_fluid);
508 scratch_data.calculate_face_physical_properties();
513 const auto face_worker =
514 [&](
const typename DoFHandler<dim>::active_cell_iterator &cell,
515 const unsigned int &face_no,
516 const unsigned int &sub_face_no,
517 const typename DoFHandler<dim>::active_cell_iterator &neigh_cell,
518 const unsigned int &neigh_face_no,
519 const unsigned int &neigh_sub_face_no,
524 scratch_data.reinit_internal_face(cell,
532 scratch_data.reinit_signed_distance_at_face(
533 cell, face_no, this->
multiphysics->get_immersed_solid_shape());
536 auto ©_data_face = copy_data.
face_data.back();
537 copy_data_face.joint_dof_indices =
538 scratch_data.fe_interface_values_tracer.get_interface_dof_indices();
539 copy_data_face.face_rhs.reinit(scratch_data.n_interface_dofs);
543 const DoFHandler<dim> &dof_handler_fluid =
546 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
547 &(*
triangulation), cell->level(), cell->index(), &dof_handler_fluid);
553 scratch_data.calculate_face_physical_properties();
562 for (
const auto &cdf : c.face_data)
564 constraints_used.distribute_local_to_global(cdf.face_rhs,
565 cdf.joint_dof_indices,
570 MeshWorker::mesh_loop(this->
dof_handler->begin_active(),
571 this->dof_handler->end(),
576 MeshWorker::assemble_own_cells |
577 MeshWorker::assemble_boundary_faces |
578 MeshWorker::assemble_own_interior_faces_once |
579 MeshWorker::assemble_ghost_faces_both,
587 const typename DoFHandler<dim>::active_cell_iterator &cell,
592 if (!cell->is_locally_owned())
604 const DoFHandler<dim> &dof_handler_fluid =
607 typename DoFHandler<dim>::active_cell_iterator velocity_cell(
608 &(*
triangulation), cell->level(), cell->index(), &dof_handler_fluid);
616 average_velocity_profile &&
617 !this->simulation_parameters.multiphysics.fluid_dynamics &&
619 this->simulation_parameters.post_processing
620 .initial_time_for_average_velocities)
626 this->simulation_parameters.ale,
627 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
634 this->simulation_parameters.ale,
635 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
644 average_velocity_profile &&
645 !this->simulation_parameters.multiphysics.fluid_dynamics &&
647 this->simulation_parameters.post_processing
648 .initial_time_for_average_velocities)
653 this->simulation_parameters.ale,
654 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
661 this->simulation_parameters.ale,
662 this->simulation_parameters.tracer_drift_velocity.drift_velocity);
669 this->simulation_control->get_current_time());
676 assembler->assemble_rhs(scratch_data, copy_data);
691 constraints_used.distribute_local_to_global(copy_data.
local_rhs,
697std::vector<OutputStruct<dim, GlobalVectorType>>
700 std::vector<OutputStruct<dim, GlobalVectorType>> solution_output_structs;
701 std::vector<std::string> solution_names(1,
"tracer");
702 std::vector<DataComponentInterpretation::DataComponentInterpretation>
703 component_interpretation(1,
704 DataComponentInterpretation::component_is_scalar);
705 solution_output_structs.emplace_back(
710 component_interpretation);
711 return solution_output_structs;
718 auto mpi_communicator =
triangulation->get_mpi_communicator();
723 update_values | update_gradients |
724 update_quadrature_points | update_JxW_values);
728 std::vector<double> q_exact_solution(n_q_points);
729 std::vector<double> q_scalar_values(n_q_points);
736 for (
const auto &cell :
dof_handler->active_cell_iterators())
738 if (cell->is_locally_owned())
740 fe_values.reinit(cell);
744 exact_solution.value_list(fe_values.get_quadrature_points(),
747 for (
unsigned int q = 0; q < n_q_points; q++)
749 double sim = q_scalar_values[q];
750 double exact = q_exact_solution[q];
751 l2error += (sim - exact) * (sim - exact) * fe_values.JxW(q);
755 l2error = Utilities::MPI::sum(l2error, mpi_communicator);
763 auto mpi_communicator =
triangulation->get_mpi_communicator();
764 unsigned int this_mpi_process(
765 Utilities::MPI::this_mpi_process(mpi_communicator));
767 if (this_mpi_process == 0 &&
771 error_table.omit_column_from_convergence_rate_evaluation(
"cells");
777 ConvergenceTable::reduction_rate_log2);
788 this->
pcout << std::defaultfloat;
790 this->
pcout << std::scientific;
800 (*previous_solutions)[i] = (*previous_solutions)[i - 1];
816 error_table.add_value(
"error_tracer", tracer_error);
819 if (Utilities::MPI::this_mpi_process(
822 const std::string filename =
826 std::ofstream output(filename.c_str());
833 this->
pcout <<
"L2 error tracer: " << tracer_error << std::endl;
841 this->simulation_parameters.post_processing.output_frequency ==
849 TimerOutput::Scope t(this->
computing_timer,
"Calculate tracer flow rate");
857 std::map<types::boundary_id, double> tracer_flow_rates;
877 this->
pcout << std::defaultfloat;
879 this->
pcout << std::scientific;
887 auto mpi_communicator =
triangulation->get_mpi_communicator();
892 update_values | update_gradients |
893 update_quadrature_points | update_JxW_values);
896 std::vector<double> q_tracer_values(n_q_points);
898 double volume_integral = 0;
899 double max_tracer_value = DBL_MIN;
900 double min_tracer_value = DBL_MAX;
902 for (
const auto &cell :
dof_handler->active_cell_iterators())
904 if (cell->is_locally_owned())
906 fe_values.reinit(cell);
909 for (
unsigned int q = 0; q < n_q_points; q++)
911 volume_integral += q_tracer_values[q] * fe_values.JxW(q);
912 max_tracer_value = std::max(q_tracer_values[q], max_tracer_value);
913 min_tracer_value = std::min(q_tracer_values[q], min_tracer_value);
917 volume_integral = Utilities::MPI::sum(volume_integral, mpi_communicator);
918 double global_volume =
920 double tracer_average = volume_integral / global_volume;
922 double variance_integral = 0;
924 for (
const auto &cell :
dof_handler->active_cell_iterators())
926 if (cell->is_locally_owned())
928 fe_values.reinit(cell);
931 for (
unsigned int q = 0; q < n_q_points; q++)
933 variance_integral += (q_tracer_values[q] - tracer_average) *
934 (q_tracer_values[q] - tracer_average) *
940 variance_integral = Utilities::MPI::sum(variance_integral, mpi_communicator);
941 double tracer_variance = variance_integral / global_volume;
942 double tracer_std_deviation = std::sqrt(tracer_variance);
948 this->
pcout <<
"Tracer statistics: " << std::endl;
949 this->
pcout <<
"\t Min: " << min_tracer_value << std::endl;
950 this->
pcout <<
"\t Max: " << max_tracer_value << std::endl;
951 this->
pcout <<
"\t Average: " << tracer_average << std::endl;
952 this->
pcout <<
"\t Std-Dev: " << tracer_std_deviation << std::endl;
978template <
typename VectorType>
979std::map<types::boundary_id, double>
983 const MPI_Comm mpi_communicator = this->
dof_handler->get_mpi_communicator();
986 std::vector<double> tracer_values(n_q_points_face);
987 std::vector<Tensor<1, dim>> tracer_gradient(n_q_points_face);
988 FEFaceValues<dim> fe_face_values_tracer(*this->
get_mapping(),
990 *this->face_quadrature,
991 update_values | update_gradients |
993 update_normal_vectors |
994 update_quadrature_points);
997 const DoFHandler<dim> &dof_handler_fd =
999 const FEValuesExtractors::Vector velocities(0);
1000 std::vector<Tensor<1, dim>> velocity_values(n_q_points_face);
1001 FEFaceValues<dim> fe_face_values_fd(*this->
get_mapping(),
1002 dof_handler_fd.get_fe(),
1003 *this->face_quadrature,
1007 auto &properties_manager =
1009 std::map<field, std::vector<double>> fields;
1011 const auto diffusivity_model = properties_manager.get_tracer_diffusivity();
1013 std::vector<double> tracer_diffusivity(n_q_points_face);
1014 std::vector<Point<dim>> face_quadrature_points;
1016 std::map<types::boundary_id, double> tracer_flow_rate;
1019 for (
const auto &cell : this->
dof_handler->active_cell_iterators())
1021 if (cell->is_locally_owned() && cell->at_boundary())
1023 for (
const auto face : cell->face_indices())
1025 if (cell->face(face)->at_boundary())
1027 const auto boundary_id = cell->face(face)->boundary_id();
1030 fe_face_values_tracer.reinit(cell, face);
1031 fe_face_values_tracer.get_function_values(
1033 fe_face_values_tracer.get_function_gradients(
1041 std::vector<double> levelset_values(n_q_points_face);
1045 face_quadrature_points =
1046 fe_face_values_tracer.get_quadrature_points();
1048 ->value_list(face_quadrature_points, levelset_values);
1054 diffusivity_model->vector_value(fields, tracer_diffusivity);
1057 typename DoFHandler<dim>::active_cell_iterator cell_fd(
1064 fe_face_values_fd.reinit(cell_fd, face);
1065 fe_face_values_fd[velocities].get_function_values(
1066 current_solution_fd, velocity_values);
1069 for (
unsigned int q = 0; q < n_q_points_face; q++)
1071 Tensor<1, dim> normal_vector_tracer =
1072 -fe_face_values_tracer.normal_vector(q);
1074 tracer_flow_rate[boundary_id] +=
1075 (-tracer_diffusivity[q] * tracer_gradient[q] *
1076 normal_vector_tracer +
1077 tracer_values[q] * velocity_values[q] *
1078 normal_vector_tracer) *
1079 fe_face_values_tracer.JxW(q);
1088 for (
auto const &[
id, type] :
1090 tracer_flow_rate[id] =
1091 Utilities::MPI::sum(tracer_flow_rate[
id], mpi_communicator);
1093 return tracer_flow_rate;
1099 const std::map<types::boundary_id, double> &tracer_flow_rate_map)
1105 for (
auto const &[
id, value] : tracer_flow_rate_map)
1108 Utilities::int_to_string(
id, 2),
1111 "flow-rate-" + Utilities::int_to_string(
id, 2),
true);
1118 this->
pcout <<
"Tracer flow rate at the boundaries: " << std::endl;
1119 for (
auto const &[
id, value] : tracer_flow_rate_map)
1120 this->
pcout <<
"\t boundary " <<
id <<
": " << value << std::endl;
1123 auto mpi_communicator =
triangulation->get_mpi_communicator();
1125 this->simulation_parameters.post_processing.output_frequency ==
1127 Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
1129 std::string filename =
1133 std::ofstream output(filename.c_str());
1142 auto mpi_communicator =
triangulation->get_mpi_communicator();
1144 if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
1146 std::string filename =
1149 std::ofstream output(filename.c_str());
1173 auto mpi_communicator =
triangulation->get_mpi_communicator();
1194 (*previous_solutions)[i] = tmp_previous_solution;
1199std::vector<OutputStructTableHandler>
1202 std::vector<OutputStructTableHandler> table_output_structs;
1204 std::string prefix =
1206 std::string suffix =
".checkpoint";
1209 table_output_structs.emplace_back(
1212 "_tracer" + suffix);
1215 table_output_structs.emplace_back(
1221 table_output_structs.emplace_back(
1225 .tracer_flow_rate_output_name +
1228 return table_output_structs;
1235 auto mpi_communicator = this->
triangulation->get_mpi_communicator();
1236 std::vector<const GlobalVectorType *> sol_set_transfer;
1239 std::make_shared<SolutionTransfer<dim, GlobalVectorType>>(*dof_handler);
1244 sol_set_transfer.emplace_back(&previous_solution);
1250 const std::vector<OutputStructTableHandler> &table_output_structs =
1259 auto mpi_communicator =
triangulation->get_mpi_communicator();
1260 this->
pcout <<
"Reading tracer checkpoint" << std::endl;
1264 input_vectors[0] = &distributed_system;
1267 std::vector<GlobalVectorType> distributed_previous_solutions;
1271 distributed_previous_solutions.emplace_back(
1273 input_vectors[i + 1] = &distributed_previous_solutions[i];
1281 (*previous_solutions)[i] = distributed_previous_solutions[i];
1286 std::vector<OutputStructTableHandler> table_output_structs =
1299 DoFRenumbering::Cuthill_McKee(*this->
dof_handler);
1301 auto mpi_communicator =
triangulation->get_mpi_communicator();
1342 DoFTools::make_flux_sparsity_pattern(*this->
dof_handler,
1349 DoFTools::make_sparsity_pattern(*this->
dof_handler,
1360 SparsityTools::distribute_sparsity_pattern(dsp,
1369 this->
pcout <<
" Number of tracer degrees of freedom: "
1378 this->previous_solutions);
1394 DoFTools::make_hanging_node_constraints(*this->
dof_handler,
1397 for (
auto const &[
id, type] :
1405 VectorTools::interpolate_boundary_values(
1414 const auto &periodic_boundary =
1416 .periodic_boundaries.at(
id);
1417 DoFTools::make_periodicity_constraints(*this->
dof_handler,
1419 periodic_boundary.neighbor_id,
1420 periodic_boundary.direction,
1442 for (
auto const &[
id, type] :
1447 VectorTools::interpolate_boundary_values(
1450 Functions::ZeroFunction<dim>(),
1455 const auto &periodic_boundary =
1457 .periodic_boundaries.at(
id);
1458 DoFTools::make_periodicity_constraints(*this->
dof_handler,
1460 periodic_boundary.neighbor_id,
1461 periodic_boundary.direction,
1478 DoFTools::make_hanging_node_constraints(*this->
dof_handler,
1481 for (
auto const &[
id, type] :
1487 VectorTools::interpolate_boundary_values(
1496 const auto &periodic_boundary =
1498 .periodic_boundaries.at(
id);
1499 DoFTools::make_periodicity_constraints(*this->
dof_handler,
1501 periodic_boundary.neighbor_id,
1502 periodic_boundary.direction,
1529 const std::pair<const Variable, Parameters::MultipleAdaptationParameters>
1531 dealii::Vector<float> &estimated_error_per_cell)
1536 ivar.second.error_estimator ==
1539 "Only the Kelly error estimator is currently implemented for the "
1540 "<tracer> field."));
1543 ComponentMask tracer_mask =
1544 fe->component_mask(FEValuesExtractors::Scalar(0));
1552 const ComponentMask &component_mask)
1554 KellyErrorEstimator<dim>::estimate(
1558 typename std::map<types::boundary_id,
const Function<dim, double> *>(),
1560 estimated_error_per_cell,
1570 const unsigned int ilu_fill =
1572 const double ilu_atol =
1574 const double ilu_rtol =
1576 TrilinosWrappers::PreconditionILU::AdditionalData preconditionerOptions(
1577 ilu_fill, ilu_atol, ilu_rtol, 0);
1591 std::vector<std::vector<bool>> constant_modes;
1593 ComponentMask components(1,
true);
1595 DoFTools::extract_constant_modes(*this->
dof_handler, components);
1599 const bool elliptic =
false;
1600 bool higher_order_elements =
false;
1601 if (this->
fe->degree > 1)
1602 higher_order_elements =
true;
1603 const unsigned int n_cycles =
1605 const bool w_cycle =
1607 const double aggregation_threshold =
1609 .amg_aggregation_threshold;
1610 const unsigned int smoother_sweeps =
1612 .amg_smoother_sweeps;
1613 const unsigned int smoother_overlap =
1615 .amg_smoother_overlap;
1616 const bool output_details =
false;
1617 const char *smoother_type =
"ILU";
1618 const char *coarse_type =
"ILU";
1619 TrilinosWrappers::PreconditionAMG::AdditionalData preconditionerOptions(
1621 higher_order_elements,
1624 aggregation_threshold,
1632 Teuchos::ParameterList parameter_ml;
1633 std::unique_ptr<Epetra_MultiVector> distributed_constant_modes;
1634 preconditionerOptions.set_parameters(parameter_ml,
1635 distributed_constant_modes,
1637 const double ilu_fill =
1639 .amg_precond_ilu_fill;
1640 const double ilu_atol =
1642 .amg_precond_ilu_atol;
1643 const double ilu_rtol =
1645 .amg_precond_ilu_rtol;
1646 parameter_ml.set(
"smoother: ifpack level-of-fill", ilu_fill);
1647 parameter_ml.set(
"smoother: ifpack absolute threshold", ilu_atol);
1648 parameter_ml.set(
"smoother: ifpack relative threshold", ilu_rtol);
1650 parameter_ml.set(
"coarse: ifpack level-of-fill", ilu_fill);
1651 parameter_ml.set(
"coarse: ifpack absolute threshold", ilu_atol);
1652 parameter_ml.set(
"coarse: ifpack relative threshold", ilu_rtol);
1664 auto mpi_communicator =
triangulation->get_mpi_communicator();
1666 const AffineConstraints<double> &constraints_used = this->
zero_constraints;
1668 const double absolute_residual =
1670 const double relative_residual =
1674 const double current_residual =
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;
1689 SolverControl solver_control(
1691 non_rescaled_linear_solver_tolerance,
1695 TrilinosWrappers::SolverGMRES::AdditionalData solver_parameters(
1698 .max_krylov_vectors);
1701 TrilinosWrappers::SolverGMRES solver(solver_control, solver_parameters);
1703 const auto preconditioner_type =
1710 completely_distributed_solution,
1714 else if (preconditioner_type ==
1719 completely_distributed_solution,
1727 "This linear solver does not support this preconditioner. Only <ilu> and <amg> preconditioners are supported."));
1732 this->
pcout <<
" -Iterative solver took : " << solver_control.last_step()
1733 <<
" steps to reach a residual norm of "
1734 << solver_control.last_value() / rescale_metric << std::endl;
1737 constraints_used.distribute(completely_distributed_solution);
1748 TimerOutput::Scope t(this->
computing_timer,
"Reinit mortar operators");
1753 this->
mortar_manager = std::make_shared<MortarManagerCircle<dim>>(
1760 this->
mortar_manager = std::make_shared<MortarManagerLinear<dim>>(
1761 *this->cell_quadrature,
1766 AssertThrow(
false, ExcMessage(
"Invalid mortar interface type."));
1771 std::make_shared<ScalarCouplingEvaluationSIPG<dim, 1, double>>(
1775 std::make_shared<CouplingOperator<dim, double>>(
1798 const double rotation_angle =
1811 this->simulation_parameters.mortar_parameters.rotation_axis_direction);
1817 AssertThrow(
false, ExcMessage(
"Invalid mortar interface type."));
1827 TimerOutput::Scope t(this->
computing_timer,
"Update mortar configuration");
1829 auto mpi_communicator =
triangulation->get_mpi_communicator();
1836 !this->simulation_control->is_refinement_step(
1837 this->simulation_parameters.mesh_adaptation) ||
1838 this->simulation_parameters.mesh_adaptation.type ==
1861 DoFTools::make_flux_sparsity_pattern(
1869 DoFTools::make_sparsity_pattern(*this->
dof_handler,
1880 SparsityTools::distribute_sparsity_pattern(dsp,
Responsible for storing the information calculated using the discontinuous galerkin (DG) assembly of ...
std::vector< CopyDataFace > face_data
Class responsible for storing the information calculated using the assembly of stabilized scalar equa...
Vector< double > local_rhs
FullMatrix< double > local_matrix
void reset()
Resets the cell_matrix, cell_rhs, strong_residual and strong_jacobian to zero.
std::vector< types::global_dof_index > local_dof_indices
Class that assembles the transient time arising from BDF time integration for the Tracer equations....
Class that assembles the core of the Tracer equation. This class assembles the weak form of: with an...
Class that assembles the core (cells) of the Tracer equation for DG elements. This class assembles th...
Class that assembles the reaction source term of the Tracer equation. It assembles the term: Where C...
Class that stores the information required by the assembly procedure for a Tracer advection-diffusion...
void reinit_signed_distance(const typename DoFHandler< dim >::active_cell_iterator &cell, const std::shared_ptr< Shape< dim > > &immersed_solid_shape)
Reinitializes the signed distance vector of the scratch.
void calculate_physical_properties()
Calculates the physical properties. This function calculates the physical properties that may be requ...
void reinit_mortar(const typename DoFHandler< dim >::active_cell_iterator &cell, const Parameters::Mortar< dim > &mortar_parameters, const double &time)
Renitialize the content of the scratch data for mortar.
void reinit_velocity(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType &velocity_solution, const Parameters::ALE< dim > &ale, const std::shared_ptr< Functions::ParsedFunction< dim > > &drift_velocity)
Reinitialize the velocity, calculated by the fluid dynamics while also taking into account ALE.
void reinit(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const std::vector< VectorType > &previous_solutions, const Function< dim > *source_function)
Reinitializes the content of the scratch.
void solve_linear_system() override
Call for the solution of the linear system of equation using a strategy appropriate to the auxiliary ...
void assemble_system_rhs_cg()
Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream p...
std::vector< OutputStructTableHandler > gather_tables() override
Returns a vector of references to TableHandler objects that needs to be serialized/deserialized for t...
TimerOutput computing_timer
std::shared_ptr< MappingQCache< dim > > mapping_cache
void update_mortar_configuration()
Update mortar configuration.
void assemble_system_matrix_dg()
Assembles the matrix associated with the solver when DG elements are used. This uses the MeshWorker p...
ConvergenceTable error_table
std::shared_ptr< Quadrature< dim > > cell_quadrature
GlobalVectorType newton_update
GlobalVectorType system_rhs
void write_checkpoint() override
Prepares Tracer physics to write checkpoint.
void write_tracer_flow_rates(const std::map< types::boundary_id, double > &tracer_flow_rate_vector)
Writes the tracer flow rates to an output file.
MultiphysicsInterface< dim > * multiphysics
void compute_kelly(dealii::Vector< float > &estimated_error_per_cell, const ComponentMask &component_mask)
Compute the Kelly error estimator on the tracer variable for mesh refinement. See : https://www....
void assemble_system_rhs_dg()
Assembles the rhs associated with the solver when DG elements are used. This uses the MeshWorker para...
void define_non_zero_constraints()
Define the non-zero constraints used to solve the problem.
virtual void copy_local_rhs_to_global_rhs(const StabilizedMethodsCopyData ©_data)
Copy local cell rhs information to global rhs.
virtual void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, TracerScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data)
Assemble the local matrix for a given cell.
double calculate_L2_error()
Calculates the L2 error of the solution.
TrilinosWrappers::SparseMatrix system_matrix
void assemble_system_matrix_cg()
Assembles the matrix associated with the solver when CG elements are used. This uses the WorkStream p...
AffineConstraints< double > zero_constraints
void reinit_face_velocity_with_adequate_solution(const typename DoFHandler< dim >::active_cell_iterator &velocity_cell, const unsigned int &face_no, TracerScratchData< dim > &scratch_data)
Helper function to reinit the face velocity with the adequate solution. This prevents code duplicatio...
void pre_mesh_adaptation() override
pre_mesh_adaption Prepares the auxiliary physics variables for a mesh refinement/coarsening
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
IndexSet locally_owned_dofs
TableHandler statistics_table
void rotate_rotor_mapping()
Rotate rotor mapping in mortar method.
void assemble_system_matrix() override
Assembles the matrix associated with the solver.
std::shared_ptr< DoFHandler< dim > > dof_handler
std::shared_ptr< CouplingOperator< dim, double > > mortar_coupling_operator
double get_residual_rescale_metric() const override
Return the metric for residual rescaling. By default, should return 1. If the rescale_residual_by_vol...
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
ILU preconditioner used by the iterative linear solver.
void post_mesh_adaptation() override
post_mesh_adaption Interpolates the auxiliary physics variables to the new mesh
std::vector< std::shared_ptr< TracerAssemblerBase< dim > > > assemblers
TableHandler tracer_flow_rate_table
virtual void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, TracerScratchData< dim > &scratch_data, StabilizedMethodsCopyData ©_data)
Assemble the local rhs for a given cell.
std::shared_ptr< SolutionTransfer< dim, GlobalVectorType > > solution_transfer
void write_tracer_statistics()
Writes the tracer statistics to an output file.
virtual void setup_assemblers()
sets up the vector of assembler functions
void update_boundary_conditions() override
Update non zero constraints if the boundary is time-dependent.
void reinit_mortar_operators()
Initialize mortar coupling manager, operator, and evaluator.
void output_per_iteration_timer() override
Output the per iteration wallclock times.
std::shared_ptr< MortarManagerBase< dim > > mortar_manager
GlobalVectorType local_evaluation_point
void set_initial_conditions() override
Sets-up the initial conditions associated with the physics. Generally, physics only support imposing ...
GlobalVectorType evaluation_point
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
std::shared_ptr< TracerAssemblerSIPG< dim > > inner_face_assembler
void percolate_time_vectors() override
Rearrange vector solution correctly for transient simulations.
void compute_error_estimate(const std::pair< const Variable, Parameters::MultipleAdaptationParameters > &ivar, dealii::Vector< float > &estimated_error_per_cell) override
Compute the error estimator for mesh refinement.
void postprocess(bool first_iteration) override
Postprocess the auxiliary physics results. Post-processing this case implies the calculation of all d...
std::shared_ptr< SimulationControl > simulation_control
IndexSet locally_relevant_dofs
std::shared_ptr< Mapping< dim > > get_mapping()
Returns the mapping shared pointer. A MappingQCache is necessary for prescribed rotation in rotor-sta...
virtual void copy_local_matrix_to_global_matrix(const StabilizedMethodsCopyData ©_data)
Copy local cell information to global matrix.
std::shared_ptr< FiniteElement< dim > > fe
std::shared_ptr< Mapping< dim > > mapping
void assemble_system_rhs() override
Assemble the rhs associated with the solver.
void calculate_tracer_statistics()
Calculate tracer statistics : Max, min, average and standard-deviation.
std::shared_ptr< GlobalVectorType > present_solution
std::shared_ptr< ScalarCouplingEvaluationSIPG< dim, 1, double > > mortar_coupling_evaluator
void setup_ilu()
Set up the ILU preconditioner stored in ilu_preconditioner.
void finish_simulation() override
Carry out the operations required to finish a simulation correctly.
const SimulationParameters< dim > & simulation_parameters
void read_checkpoint() override
Allows tracer physics to set up solution vector from checkpoint file;.
virtual std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Gather and return vector of output structs that are particular to some applications.
std::shared_ptr< TrilinosWrappers::PreconditionAMG > amg_preconditioner
AMG preconditioner used by the iterative linear solver.
std::shared_ptr< TracerAssemblerBoundaryNitsche< dim > > boundary_face_assembler
void define_zero_constraints()
Define the zero constraints used to solve the problem.
std::vector< SolutionTransfer< dim, GlobalVectorType > > previous_solutions_transfer
void setup_amg()
Set up the AMG preconditioner stored in amg_preconditioner.
void setup_dofs() override
Sets-up the DofHandler and the degree of freedom associated with the physics.
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
std::map< types::boundary_id, double > postprocess_tracer_flow_rate(const GlobalVectorType ¤t_solution_fd)
AffineConstraints< double > nonzero_constraints
void verify_consistency_of_boundary_conditions()
Verify consistency of the input parameters for boundary conditions to ensure that for every boundary ...
void serialize_tables_vector(const std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Serializes all the TableHandler objects in table_output_structs.
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 deserialize_tables_vector(std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Deserializes all the TableHandler objects in table_output_structs.
@ tracer
Tracer scalar field.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
@ tracer
Passive scalar tracer (Tracer).
FluidDynamicsInitialConditionType
void set_field_vector(const field &id, const std::vector< double > &data, std::map< field, std::vector< double > > &fields)
std::pair< double, double > calculate_L2_error(const DoFHandler< dim > &dof_handler, const VectorType &evaluation_point, const Function< dim > *exact_solution, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
Calculates the L2 norm of the error on velocity and pressure.
Struct containing information about the solution output. It is used to pass all the information requi...
@ amg
Algebraic Multigrid.
@ ilu
Incomplete LU Factorization.
GlobalVectorType VectorType
bool time_stepping_is_bdf(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the bdf family.
bool time_stepping_is_sdirk(const Parameters::SimulationControl::TimeSteppingMethod method)
Determines if the time integration method is within the sdirk family.
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType