9#include <deal.II/grid/grid_generator.h>
11#include <deal.II/lac/sparsity_tools.h>
13#include <deal.II/multigrid/mg_tools.h>
26template <
int dim,
int spacedim>
29 const Quadrature<dim> &quadrature)
31 const auto compute_scalar_bool_dof_mask = [&quadrature](
const auto &fe) {
32 Table<2, bool> bool_dof_mask(fe.dofs_per_cell, fe.dofs_per_cell);
33 MappingQ1<dim, spacedim> mapping;
34 FEValues<dim> fe_values(mapping, fe, quadrature, update_values);
36 Triangulation<dim, spacedim> tria;
37 GridGenerator::hyper_cube(tria);
39 fe_values.reinit(tria.begin());
40 for (
unsigned int i = 0; i < fe.dofs_per_cell; ++i)
41 for (
unsigned int j = 0; j < fe.dofs_per_cell; ++j)
44 for (
unsigned int q = 0; q < quadrature.size(); ++q)
45 sum += fe_values.shape_value(i, q) * fe_values.shape_value(j, q);
47 bool_dof_mask(i, j) =
true;
53 Table<2, bool> bool_dof_mask(fe.dofs_per_cell, fe.dofs_per_cell);
55 if (fe.n_components() == 1)
57 bool_dof_mask = compute_scalar_bool_dof_mask(fe);
61 const auto scalar_bool_dof_mask =
62 compute_scalar_bool_dof_mask(fe.base_element(0));
64 for (
unsigned int i = 0; i < fe.n_dofs_per_cell(); ++i)
65 for (
unsigned int j = 0; j < fe.n_dofs_per_cell(); ++j)
66 if (scalar_bool_dof_mask[fe.system_to_component_index(i).second]
67 [fe.system_to_component_index(j).second])
68 bool_dof_mask[i][j] =
true;
77template <
int dim,
typename number>
79 :
pcout(std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
80 ,
timer(this->
pcout, TimerOutput::never, TimerOutput::wall_times)
83template <
int dim,
typename number>
85 const Mapping<dim> &mapping,
86 const DoFHandler<dim> &dof_handler,
88 const Quadrature<dim> &quadrature,
90 const std::shared_ptr<PhysicalPropertiesManager> &physical_properties_manager,
92 const unsigned int mg_level,
99 :
pcout(std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
100 ,
timer(this->
pcout, TimerOutput::never, TimerOutput::wall_times)
107 physical_properties_manager,
117template <
int dim,
typename number>
120 const Mapping<dim> &mapping,
121 const DoFHandler<dim> &dof_handler,
123 const Quadrature<dim> &quadrature,
125 const std::shared_ptr<PhysicalPropertiesManager> &physical_properties_manager,
127 const unsigned int mg_level,
144 typename MatrixFree<dim, number>::AdditionalData additional_data;
145 additional_data.mapping_update_flags =
146 (update_values | update_gradients | update_JxW_values |
147 update_quadrature_points | update_hessians);
148 additional_data.mg_level = mg_level;
160 additional_data.mapping_update_flags_boundary_faces =
161 update_values | update_gradients | update_quadrature_points |
162 update_JxW_values | update_normal_vectors;
167 additional_data.mapping_update_flags_boundary_faces =
168 update_values | update_quadrature_points | update_JxW_values |
169 update_normal_vectors;
175 additional_data.mapping_update_flags_boundary_faces =
176 update_values | update_quadrature_points | update_JxW_values |
177 update_normal_vectors;
182 mapping, dof_handler, this->constraints, quadrature, additional_data);
184 this->
fe_degree = dof_handler.get_fe().degree;
198 throw std::runtime_error(
199 "Only SUPG/PSPG and GLS stabilization is supported at the moment.");
221 for (
auto i : this->
matrix_free.get_constrained_dofs())
225 if (this->
matrix_free.get_mg_level() != numbers::invalid_unsigned_int)
227 std::vector<types::global_dof_index> interface_indices;
228 IndexSet refinement_edge_indices;
231 interface_indices = refinement_edge_indices.get_index_vector();
236 const IndexSet &locally_owned =
237 this->
matrix_free.get_dof_handler().locally_owned_mg_dofs(
240 for (
const auto i : interface_indices)
241 if (locally_owned.is_element(i))
246 dof_handler.get_mpi_communicator()) > 0;
256 temp.local_element(i) = 1.0;
258 temp.update_ghost_values();
262 for (
unsigned int cell = 0; cell <
matrix_free.n_cell_batches();
265 integrator.reinit(cell);
266 integrator.read_dof_values(temp);
268 for (
unsigned int i = 0; i < integrator.dofs_per_cell; ++i)
269 if ((integrator.begin_dof_values()[i] ==
270 VectorizedArray<number>()) ==
false)
280template <
int dim,
typename number>
288 const auto time_steps_vector =
290 data.
dt = time_steps_vector[0];
306 const auto time_steps_vector =
308 data.
dt = time_steps_vector[0];
322template <
int dim,
typename number>
326 const unsigned int n_cells =
330 for (
unsigned int cell = 0; cell < n_cells; ++cell)
334 VectorizedArray<number> mask(0.0);
336 for (
unsigned int lane = 0;
337 lane <
matrix_free.n_active_entries_per_cell_batch(cell);
341 (
matrix_free.get_cell_iterator(cell, lane)->material_id() == 0) ?
350template <
int dim,
typename number>
354 const unsigned int n_cells =
358 for (
unsigned int cell = 0; cell < n_cells; ++cell)
361 lane <
matrix_free.n_active_entries_per_cell_batch(cell);
365 matrix_free.get_cell_iterator(cell, lane)->measure();
372template <
int dim,
typename number>
378 const unsigned int n_cells =
385 for (
unsigned int cell = 0; cell < n_cells; ++cell)
387 integrator.reinit(cell);
388 for (
const auto q : integrator.quadrature_point_indices())
390 const Point<dim, VectorizedArray<number>> point_batch =
391 integrator.quadrature_point(q);
400template <
int dim,
typename number>
404 const DoFHandler<dim> &temperature_dof_handler)
406 const auto thermal_expansion_model =
409 const double reference_temperature =
412 const unsigned int n_cells =
415 FEValues<dim> fe_values(*(this->
matrix_free.get_mapping_info().mapping),
416 temperature_dof_handler.get_fe(),
417 this->matrix_free.get_quadrature(),
422 std::vector<number> cell_temperature_solution(fe_values.n_quadrature_points);
423 std::vector<double> thermal_expansion(fe_values.n_quadrature_points);
425 for (
unsigned int cell = 0; cell < n_cells; ++cell)
428 lane <
matrix_free.n_active_entries_per_cell_batch(cell);
433 ->as_dof_handler_iterator(temperature_dof_handler));
435 fe_values.get_function_values(temperature_solution,
436 cell_temperature_solution);
438 thermal_expansion_model->vector_value({}, thermal_expansion);
440 for (
const auto q : fe_values.quadrature_point_indices())
444 1 - thermal_expansion[q] *
445 (cell_temperature_solution[q] - reference_temperature);
450 for (
int c = 0; c < dim; ++c)
459template <
int dim,
typename number>
460types::global_dof_index
463 if (this->
matrix_free.get_mg_level() != numbers::invalid_unsigned_int)
467 return this->
matrix_free.get_dof_handler().n_dofs();
470template <
int dim,
typename number>
474 Assert(
false, ExcNotImplemented());
478template <
int dim,
typename number>
485template <
int dim,
typename number>
493template <
int dim,
typename number>
494const std::shared_ptr<const Utilities::MPI::Partitioner> &
500template <
int dim,
typename number>
505 this->
timer.enter_subsection(
"operator::vmult");
513 const_cast<LinearAlgebra::distributed::Vector<number> &
>(src)
520 src.update_ghost_values();
538 this->
timer.enter_subsection(
"operator::vmult_mortar");
540 dst.compress(VectorOperation::add);
541 src.zero_out_ghost_values();
542 this->
timer.leave_subsection(
"operator::vmult_mortar");
548 dst.local_element(constrained_index) = src.local_element(constrained_index);
554 const_cast<LinearAlgebra::distributed::Vector<number> &
>(src)
561 this->
timer.leave_subsection(
"operator::vmult");
564template <
int dim,
typename number>
569 this->
vmult(dst, src);
572template <
int dim,
typename number>
593 dst.local_element(i) = src.local_element(i);
598template <
int dim,
typename number>
604 this->
timer.enter_subsection(
"operator::vmult_interface_up");
610 this->
timer.leave_subsection(
"operator::vmult_interface_up");
619 src_cpy.reinit(src,
false);
622 src_cpy.local_element(i) = src.local_element(i);
642 this->
timer.leave_subsection(
"operator::vmult_interface_up");
647template <
int dim,
typename number>
648const DynamicSparsityPattern &
656template <
int dim,
typename number>
657const TrilinosWrappers::SparseMatrix &
660 this->
timer.enter_subsection(
"operator::get_system_matrix");
664 const auto &dof_handler = this->
matrix_free.get_dof_handler();
666 const unsigned int mg_level = this->
matrix_free.get_mg_level();
668 IndexSet locally_relevant_dofs;
669 IndexSet locally_owned_dofs;
671 if (mg_level != numbers::invalid_unsigned_int)
673 locally_relevant_dofs =
674 DoFTools::extract_locally_relevant_level_dofs(dof_handler,
676 locally_owned_dofs = dof_handler.locally_owned_mg_dofs(mg_level);
680 locally_owned_dofs = dof_handler.locally_owned_dofs();
681 locally_relevant_dofs =
682 DoFTools::extract_locally_relevant_dofs(dof_handler);
685 this->
dsp.reinit(locally_relevant_dofs.size(),
686 locally_relevant_dofs.size(),
687 locally_relevant_dofs);
689 if (mg_level != numbers::invalid_unsigned_int)
694 std::vector<types::global_dof_index> dofs_on_this_cell;
696 for (
const auto &cell : dof_handler.cell_iterators_on_level(mg_level))
697 if (cell->is_locally_owned_on_level())
699 const unsigned int dofs_per_cell =
700 dof_handler.get_fe().n_dofs_per_cell();
701 dofs_on_this_cell.resize(dofs_per_cell);
702 cell->get_mg_dof_indices(dofs_on_this_cell);
704 constraints.add_entries_local_to_global(dofs_on_this_cell,
715 std::vector<types::global_dof_index> dofs_on_this_cell;
717 for (
const auto &cell : dof_handler.active_cell_iterators())
718 if (cell->is_locally_owned())
720 const unsigned int dofs_per_cell =
721 cell->get_fe().n_dofs_per_cell();
722 dofs_on_this_cell.resize(dofs_per_cell);
723 cell->get_dof_indices(dofs_on_this_cell);
725 constraints.add_entries_local_to_global(dofs_on_this_cell,
736 SparsityTools::distribute_sparsity_pattern(
739 dof_handler.get_triangulation().get_mpi_communicator(),
740 locally_relevant_dofs);
746 dof_handler.get_triangulation().get_mpi_communicator());
755 const auto &lexicographic_numbering =
756 matrix_free.get_shape_info().lexicographic_numbering;
758 unsigned int cell = numbers::invalid_unsigned_int;
759 unsigned int face = numbers::invalid_unsigned_int;
760 unsigned int column = numbers::invalid_unsigned_int;
766 boundary_function = [&](
auto &integrator) {
767 if (face != integrator.get_current_cell_index())
769 face = integrator.get_current_cell_index();
776 for (
unsigned int i = 0; i < lexicographic_numbering.size(); ++i)
779 [lexicographic_numbering[column]])
780 integrator.begin_dof_values()[i] = 0.0;
789 compute_matrix<dim, -1, 0, dim + 1, number, VectorizedArray<number>>(
793 [&](
auto &integrator) {
794 if (cell != integrator.get_current_cell_index())
796 cell = integrator.get_current_cell_index();
803 for (
unsigned int i = 0; i < lexicographic_numbering.size(); ++i)
805 [lexicographic_numbering[column]])
806 integrator.begin_dof_values()[i] = 0.0;
816 this->
timer.enter_subsection(
"operator::get_system_matrix_mortar");
820 this->
timer.leave_subsection(
"operator::get_system_matrix_mortar");
828 const auto global_row =
835 const auto global_row =
842 this->
timer.leave_subsection(
"operator::get_system_matrix");
844 return this->system_matrix;
847template <
int dim,
typename number>
848const MatrixFree<dim, number> &
854template <
int dim,
typename number>
855const AlignedVector<VectorizedArray<number>>
861template <
int dim,
typename number>
868 this->
timer.enter_subsection(
869 "operator::evaluate_prescribed_neumann_traction");
870 const unsigned int n_inner_faces =
matrix_free.n_inner_face_batches();
871 const unsigned int n_boundary_faces =
877 face_integrator.n_q_points);
879 for (
unsigned int face = n_inner_faces;
880 face < n_inner_faces + n_boundary_faces;
883 face_integrator.reinit(face);
885 for (
const auto q : face_integrator.quadrature_point_indices())
888 face_integrator.boundary_id()) ==
892 Point<dim, VectorizedArray<number>> point_batch =
893 face_integrator.quadrature_point(q);
910 .at(face_integrator.boundary_id())
916 this->
timer.leave_subsection(
917 "operator::evaluate_prescribed_neumann_traction");
921template <
int dim,
typename number>
926 this->
timer.enter_subsection(
"operator::evaluate_non_linear_term");
928 const unsigned int n_cells =
matrix_free.n_cell_batches();
929 const unsigned int n_inner_faces =
matrix_free.n_inner_face_batches();
930 const unsigned int n_boundary_faces =
matrix_free.n_boundary_face_batches();
932 const double kinematic_viscosity =
958 const bool transient =
964 const auto time_steps_vector =
966 const double dt = time_steps_vector[0];
970 for (
unsigned int cell = 0; cell < n_cells; ++cell)
972 integrator.reinit(cell);
973 integrator.read_dof_values_plain(newton_step);
976 integrator.evaluate(EvaluationFlags::values |
977 EvaluationFlags::gradients |
978 EvaluationFlags::hessians);
980 integrator.evaluate(EvaluationFlags::values |
981 EvaluationFlags::gradients);
986 for (
const auto q : integrator.quadrature_point_indices())
991 integrator.get_value(q);
1001 integrator.get_hessian_diagonal(q);
1006 VectorizedArray<number> u_mag_squared = 1e-12;
1007 for (
int k = 0; k < dim; ++k)
1008 u_mag_squared += Utilities::fixed_power<2>(
1012 1. / std::sqrt(Utilities::fixed_power<2>(sdt) +
1013 4. * u_mag_squared / h / h +
1014 9. * Utilities::fixed_power<2>(
1015 4. * kinematic_viscosity / (h * h)));
1018 std::sqrt(u_mag_squared) * h * 0.5;
1025 typename FECellIntegrator::gradient_type
shear_rate;
1026 typename FECellIntegrator::value_type grad_shear_rate = {};
1027 VectorizedArray<number> shear_rate_magnitude;
1029 for (
const auto q : integrator.quadrature_point_indices())
1031 typename FECellIntegrator::gradient_type gradient =
1032 integrator.get_gradient(q);
1034 typename FECellIntegrator::hessian_type hessian =
1035 integrator.get_hessian(q);
1038 for (
int i = 0; i < dim; ++i)
1040 for (
int j = 0; j < dim; ++j)
1042 shear_rate[i][j] = gradient[i][j] + gradient[j][i];
1052 shear_rate_magnitude = std::max(sqrt(0.5 * shear_rate_magnitude),
1053 VectorizedArray<number>(1e-12));
1057 shear_rate_magnitude;
1062 for (
int d = 0; d < dim; ++d)
1064 grad_shear_rate[d] = 0.;
1065 for (
int i = 0; i < dim; ++i)
1067 for (
int k = 0; k < dim; ++k)
1069 grad_shear_rate[d] +=
1070 VectorizedArray<number>(0.5) *
1071 (gradient[i][k] + gradient[k][i]) *
1072 (hessian[i][d][k] + hessian[k][d][i]) /
1073 shear_rate_magnitude;
1081 VectorizedArray<number> viscosity;
1082 VectorizedArray<number> grad_viscosity_shear_rate;
1084 for (
unsigned int v = 0; v < VectorizedArray<number>::size(); ++v)
1087 std::map<field, double> fields;
1093 grad_viscosity_shear_rate[v] =
1099 grad_viscosity_shear_rate;
1102 grad_shear_rate * grad_viscosity_shear_rate;
1108 VectorizedArray<number> u_mag_squared = 1e-12;
1109 for (
int k = 0; k < dim; ++k)
1111 Utilities::fixed_power<2>(integrator.get_value(q)[k]);
1116 Utilities::fixed_power<2>(sdt) + 4. * u_mag_squared / h / h +
1117 9. * Utilities::fixed_power<2>(4. * viscosity / (h * h)));
1131 face_integrator.n_q_points);
1137 for (
unsigned int face = n_inner_faces;
1138 face < n_inner_faces + n_boundary_faces;
1141 face_integrator.reinit(face);
1148 face_integrator.boundary_id())) ==
false)
1153 face_integrator.boundary_id()) ==
1156 face_integrator.read_dof_values_plain(newton_step);
1157 face_integrator.evaluate(
1158 EvaluationFlags::EvaluationFlags::values);
1161 for (
const auto q : face_integrator.quadrature_point_indices())
1164 face_integrator.boundary_id()) ==
1167 Point<dim, VectorizedArray<number>> point_batch =
1168 face_integrator.quadrature_point(q);
1170 Tensor<1, dim, VectorizedArray<number>> target_velocity_value;
1174 .at(face_integrator.boundary_id())
1180 .at(face_integrator.boundary_id())
1184 if constexpr (dim == 3)
1187 .at(face_integrator.boundary_id())
1192 target_velocity_value;
1195 face_integrator.boundary_id()) ==
1199 face_integrator.get_value(q);
1203 face_integrator.boundary_id()) ==
1207 Point<dim, VectorizedArray<number>> point_batch =
1208 face_integrator.quadrature_point(q);
1214 .at(face_integrator.boundary_id())
1222 VectorizedArray<number> cell_size = 1.0;
1224 const auto [cell_it, _] =
matrix_free.get_face_iterator(face, 0);
1232 beta / std::pow(cell_size,
static_cast<number
>(
fe_degree + 1));
1236 this->
timer.leave_subsection(
"operator::evaluate_non_linear_term");
1239template <
int dim,
typename number>
1243 const VectorType &time_derivative_previous_solutions)
1245 this->
timer.enter_subsection(
1246 "operator::evaluate_time_derivative_previous_solutions");
1248 const unsigned int n_cells =
matrix_free.n_cell_batches();
1253 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1255 integrator.reinit(cell);
1256 integrator.read_dof_values_plain(time_derivative_previous_solutions);
1257 integrator.evaluate(EvaluationFlags::values);
1258 for (
const auto q : integrator.quadrature_point_indices())
1262 this->
timer.leave_subsection(
1263 "operator::evaluate_time_derivative_previous_solutions");
1266template <
int dim,
typename number>
1269 const Mapping<dim> &mapping,
1270 const Point<dim> center_of_rotation,
1271 const unsigned int rotation_axis_direction,
1272 const std::shared_ptr<Functions::ParsedFunction<dim>> &rotor_angular_velocity)
1274 this->
timer.enter_subsection(
"operator::evaluate_velocity_ale");
1276 const unsigned int n_cells =
1288 rotor_angular_velocity->set_time(
1290 const double rotor_angular_velocity_value =
1291 rotor_angular_velocity->value(Point<dim>());
1293 for (
unsigned int cell = 0; cell < n_cells; ++cell)
1295 integrator.reinit(cell);
1296 for (
auto lane = 0u;
1297 lane <
matrix_free.n_active_entries_per_cell_batch(cell);
1303 if (
matrix_free.get_cell_iterator(cell, lane)->material_id() == 1)
1304 omega = rotor_angular_velocity_value;
1310 matrix_free.get_cell_iterator(cell, lane)->material_id() < 2,
1312 "The material id in a cell was identified as equal or greater than 2, however the mortar implementation is not defined for more than two materials."));
1315 for (
const auto q : integrator.quadrature_point_indices())
1319 for (
int i = 0; i < dim; i++)
1320 p[i] = integrator.quadrature_point(q)[i][lane] -
1321 center_of_rotation[i];
1325 omega, p, rotation_axis_direction);
1327 for (
int i = 0; i < dim; i++)
1333 this->
timer.leave_subsection(
"operator::evaluate_velocity_ale");
1336template <
int dim,
typename number>
1341 for (
unsigned int v = 0; v < VectorizedArray<number>::size(); ++v)
1343 for (
int d = 0; d < dim; ++d)
1348template <
int dim,
typename number>
1353 this->
timer.enter_subsection(
"operator::evaluate_residual");
1368 this->
timer.leave_subsection(
"operator::evaluate_residual");
1371template <
int dim,
typename number>
1376 this->
timer.enter_subsection(
"operator::compute_inverse_diagonal");
1381 boundary_function = [&](
auto &integrator) {
1387 compute_diagonal<dim, -1, 0, dim + 1, number, VectorizedArray<number>>(
1397 this->
timer.enter_subsection(
"operator::compute_inverse_diagonal_mortar");
1399 this->
timer.leave_subsection(
"operator::compute_inverse_diagonal_mortar");
1403 diagonal.local_element(i) = 0.0;
1405 for (
auto &i : diagonal)
1406 i = (std::abs(i) > 1.0e-10) ? (1.0 / i) : 1.0;
1408 this->
timer.leave_subsection(
"operator::compute_inverse_diagonal");
1411template <
int dim,
typename number>
1417 const std::pair<unsigned int, unsigned int> &range)
const
1421 for (
unsigned int cell = range.first; cell < range.second; ++cell)
1423 integrator.reinit(cell);
1425 integrator.read_dof_values(src);
1429 integrator.distribute_local_to_global(dst);
1433template <
int dim,
typename number>
1439 const std::pair<unsigned int, unsigned int> &range)
const
1449template <
int dim,
typename number>
1450template <
bool assemble_res
idual>
1456 const std::pair<unsigned int, unsigned int> &range)
const
1460 for (
auto cell = range.first; cell < range.second; ++cell)
1464 if (assemble_residual)
1465 phi.read_dof_values_plain(src);
1467 phi.read_dof_values(src);
1471 phi.distribute_local_to_global(dst);
1485template <
int dim,
typename number>
1486template <
bool assemble_res
idual>
1502 const VectorizedArray<number> zero = 0.0;
1504 for (
unsigned int i = 0; i < integrator.dofs_per_cell; ++i)
1505 integrator.begin_dof_values()[i] = zero;
1509 const auto face = integrator.get_current_cell_index();
1510 const unsigned int face_index = face -
matrix_free.n_inner_face_batches();
1512 const double kinematic_viscosity =
1520 integrator.evaluate(EvaluationFlags::EvaluationFlags::values |
1521 EvaluationFlags::EvaluationFlags::gradients);
1523 for (
const auto q : integrator.quadrature_point_indices())
1525 typename FEFaceIntegrator::value_type value_result = {};
1526 typename FEFaceIntegrator::gradient_type gradient_result = {};
1528 const auto normal_vector = integrator.normal_vector(q);
1530 auto value = integrator.get_value(q);
1531 const auto gradient = integrator.get_gradient(q);
1536 if constexpr (assemble_residual)
1537 for (
int d = 0; d < dim; ++d)
1540 for (
int d = 0; d < dim; ++d)
1543 value_result[d] += penalty_parameter * value[d];
1546 for (
int i = 0; i < dim; ++i)
1548 kinematic_viscosity * gradient[d][i] * normal_vector[i];
1550 for (
int i = 0; i < dim; ++i)
1551 gradient_result[d][i] -=
1552 kinematic_viscosity * value[d] * normal_vector[i];
1554 integrator.submit_value(value_result, q);
1555 integrator.submit_gradient(gradient_result, q);
1558 integrator.integrate(EvaluationFlags::EvaluationFlags::values |
1559 EvaluationFlags::EvaluationFlags::gradients);
1567 integrator.evaluate(EvaluationFlags::values);
1569 for (
const auto q : integrator.quadrature_point_indices())
1571 typename FEFaceIntegrator::value_type value_result = {};
1572 for (
int d = 0; d < dim; ++d)
1579 if constexpr (assemble_residual)
1585 value_result[d] = 0;
1587 integrator.submit_value(value_result, q);
1590 integrator.integrate(EvaluationFlags::EvaluationFlags::values);
1597 integrator.evaluate(EvaluationFlags::values);
1599 for (
const auto q : integrator.quadrature_point_indices())
1601 typename FEFaceIntegrator::value_type value_result = {};
1603 const auto normal_vector = integrator.normal_vector(q);
1605 auto value = integrator.get_value(q);
1607 Tensor<1, dim, VectorizedArray<number>>
velocity;
1608 if constexpr (assemble_residual)
1610 for (
int d = 0; d < dim; ++d)
1616 for (
int d = 0; d < dim; ++d)
1621 VectorizedArray<number> normal_outflux =
velocity * normal_vector;
1624 std::min(VectorizedArray<number>(0.0), normal_outflux);
1627 for (
int d = 0; d < dim; ++d)
1628 value_result[d] -= penalty_parameter * normal_outflux * value[d];
1630 integrator.submit_value(value_result, q);
1633 integrator.integrate(EvaluationFlags::EvaluationFlags::values);
1639 integrator.evaluate(EvaluationFlags::EvaluationFlags::values |
1640 EvaluationFlags::EvaluationFlags::gradients);
1642 for (
const auto q : integrator.quadrature_point_indices())
1644 typename FEFaceIntegrator::value_type value_result = {};
1646 const auto normal_vector = integrator.normal_vector(q);
1647 auto gradient = integrator.get_gradient(q);
1649 for (
int d = 0; d < dim; ++d)
1653 if constexpr (assemble_residual)
1656 for (
int i = 0; i < dim; ++i)
1658 kinematic_viscosity * gradient[d][i] * normal_vector[i];
1668 for (
int i = 0; i < dim; ++i)
1670 kinematic_viscosity * gradient[d][i] * normal_vector[i];
1673 integrator.submit_value(value_result, q);
1676 integrator.integrate(EvaluationFlags::EvaluationFlags::values);
1681template <
int dim,
typename number>
1686 const unsigned int level =
matrix_free.get_mg_level();
1688 std::vector<IndexSet> refinement_edge_indices;
1689 refinement_edge_indices.clear();
1690 const unsigned int nlevels =
1691 matrix_free.get_dof_handler().get_triangulation().n_global_levels();
1692 refinement_edge_indices.resize(nlevels);
1693 for (
unsigned int l = 0; l < nlevels; l++)
1694 refinement_edge_indices[l] =
1695 IndexSet(
matrix_free.get_dof_handler().n_dofs(l));
1697 MGTools::extract_inner_interface_dofs(
matrix_free.get_dof_handler(),
1698 refinement_edge_indices);
1699 return refinement_edge_indices[level];
1707template <
int dim,
typename number>
1728template <
int dim,
typename number>
1734 integrator.evaluate(EvaluationFlags::values | EvaluationFlags::gradients |
1735 EvaluationFlags::hessians);
1737 integrator.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);
1739 const unsigned int cell = integrator.get_current_cell_index();
1744 VectorizedArray<number> cell_mask(1.0);
1757 const double a_ii = time_stepping_data.
a_ii;
1758 const double dt = time_stepping_data.
dt;
1759 const bool is_bdf = time_stepping_data.
is_bdf;
1760 const bool is_sdirk = time_stepping_data.
is_sdirk;
1761 const bool transient = time_stepping_data.
is_transient;
1764 const double kinematic_viscosity =
1767 for (
const auto q : integrator.quadrature_point_indices())
1769 Tensor<1, dim, VectorizedArray<number>> source_value;
1782 typename FECellIntegrator::value_type value = integrator.get_value(q);
1783 typename FECellIntegrator::gradient_type gradient =
1784 integrator.get_gradient(q);
1785 typename FECellIntegrator::gradient_type hessian_diagonal;
1788 hessian_diagonal = integrator.get_hessian_diagonal(q);
1791 typename FECellIntegrator::value_type value_result;
1792 typename FECellIntegrator::gradient_type gradient_result;
1793 typename FECellIntegrator::hessian_type hessian_result;
1798 auto previous_hessian_diagonal =
1800 auto previous_advective_values =
1803 Tensor<1, dim + 1, VectorizedArray<number>> previous_time_derivatives;
1805 previous_time_derivatives =
1813 for (
int i = 0; i < dim; ++i)
1816 gradient_result[i] = kinematic_viscosity * gradient[i];
1818 gradient_result[i][i] += -value[dim];
1820 value_result[dim] += gradient[i][i];
1822 for (
int k = 0; k < dim; ++k)
1825 value_result[i] += gradient[i][k] * previous_advective_values[k] +
1826 previous_gradient[i][k] * value[k];
1830 value_result[i] += (*bdf_coefficients)[0] * value[i];
1833 value_result[i] += (1.0 / (dt * a_ii)) * value[i];
1838 for (
int i = 0; i < dim; ++i)
1840 for (
int k = 0; k < dim; ++k)
1843 gradient_result[dim][i] +=
1844 tau * (-kinematic_viscosity * hessian_diagonal[i][k] +
1845 gradient[i][k] * previous_advective_values[k] +
1846 previous_gradient[i][k] * value[k]);
1850 gradient_result[dim][i] += tau * (*bdf_coefficients)[0] * value[i];
1853 gradient_result[dim][i] += tau * (1.0 / (dt * a_ii)) * value[i];
1856 gradient_result[dim] += tau * gradient[dim];
1859 for (
int i = 0; i < dim; ++i)
1861 for (
int k = 0; k < dim; ++k)
1864 for (
int l = 0; l < dim; ++l)
1867 gradient_result[i][k] +=
1868 tau * previous_advective_values[k] *
1869 (gradient[i][l] * previous_advective_values[l] +
1870 previous_gradient[i][l] * value[l] -
1871 kinematic_viscosity * hessian_diagonal[i][l]);
1874 gradient_result[i][k] +=
1875 tau * previous_advective_values[k] * (gradient[dim][i]);
1879 gradient_result[i][k] += tau * previous_advective_values[k] *
1880 ((*bdf_coefficients)[0] * value[i]);
1884 gradient_result[i][k] += tau * previous_advective_values[k] *
1885 ((1.0 / (dt * a_ii)) * value[i]);
1889 for (
int l = 0; l < dim; ++l)
1892 gradient_result[i][k] +=
1894 (previous_gradient[i][l] * previous_advective_values[l] -
1895 kinematic_viscosity * previous_hessian_diagonal[i][l]);
1898 gradient_result[i][k] +=
1899 tau * value[k] * (previous_gradient[dim][i] - source_value[i]);
1903 gradient_result[i][k] +=
1905 ((*bdf_coefficients)[0] * previous_values[i] +
1906 previous_time_derivatives[i]);
1909 gradient_result[i][k] +=
1911 ((1.0 / (dt * a_ii)) * previous_values[i] +
1912 previous_time_derivatives[i]);
1921 for (
int i = 0; i < dim; ++i)
1923 for (
int k = 0; k < dim; ++k)
1927 for (
int l = 0; l < dim; ++l)
1930 hessian_result[i][k][k] +=
1931 tau * -kinematic_viscosity *
1932 (gradient[i][l] * previous_advective_values[l] +
1933 previous_gradient[i][l] * value[l] -
1934 kinematic_viscosity * hessian_diagonal[i][l]);
1938 hessian_result[i][k][k] +=
1939 tau * -kinematic_viscosity * (gradient[dim][i]);
1943 hessian_result[i][k][k] +=
1944 tau * -kinematic_viscosity *
1945 ((*bdf_coefficients)[0] * value[i]);
1948 hessian_result[i][k][k] +=
1949 tau * -kinematic_viscosity *
1950 ((1.0 / (dt * a_ii)) * value[i]);
1956 gradient_result[i][i] += tau_lsic * gradient[k][k];
1963 gradient_result = gradient_result * cell_mask;
1964 value_result = value_result * cell_mask;
1966 hessian_result = hessian_result * cell_mask;
1969 integrator.submit_gradient(gradient_result, q);
1970 integrator.submit_value(value_result, q);
1973 integrator.submit_hessian(hessian_result, q);
1977 integrator.integrate(EvaluationFlags::values | EvaluationFlags::gradients |
1978 EvaluationFlags::hessians);
1980 integrator.integrate(EvaluationFlags::values | EvaluationFlags::gradients);
1997template <
int dim,
typename number>
2003 const std::pair<unsigned int, unsigned int> &range)
const
2007 const double kinematic_viscosity =
2010 for (
unsigned int cell = range.first; cell < range.second; ++cell)
2012 integrator.reinit(cell);
2013 integrator.read_dof_values_plain(src);
2016 integrator.evaluate(EvaluationFlags::values |
2017 EvaluationFlags::gradients |
2018 EvaluationFlags::hessians);
2020 integrator.evaluate(EvaluationFlags::values |
2021 EvaluationFlags::gradients);
2024 VectorizedArray<number> cell_mask(1.0);
2037 const double a_ii = time_stepping_data.
a_ii;
2038 const double dt = time_stepping_data.
dt;
2039 const bool is_bdf = time_stepping_data.
is_bdf;
2040 const bool is_sdirk = time_stepping_data.
is_sdirk;
2041 const bool transient = time_stepping_data.
is_transient;
2045 for (
const auto q : integrator.quadrature_point_indices())
2047 Tensor<1, dim, VectorizedArray<number>> source_value;
2060 typename FECellIntegrator::value_type value = integrator.get_value(q);
2061 typename FECellIntegrator::gradient_type gradient =
2062 integrator.get_gradient(q);
2063 typename FECellIntegrator::gradient_type hessian_diagonal;
2064 const auto advective_value =
2068 hessian_diagonal = integrator.get_hessian_diagonal(q);
2071 Tensor<1, dim + 1, VectorizedArray<number>> previous_time_derivatives;
2073 previous_time_derivatives =
2081 typename FECellIntegrator::value_type value_result;
2082 typename FECellIntegrator::gradient_type gradient_result;
2083 typename FECellIntegrator::hessian_type hessian_result;
2086 for (
int i = 0; i < dim; ++i)
2089 gradient_result[i] = kinematic_viscosity * gradient[i];
2091 gradient_result[i][i] += -value[dim];
2093 value_result[i] = -source_value[i];
2097 value_result[i] += (*bdf_coefficients)[0] * value[i] +
2098 previous_time_derivatives[i];
2101 value_result[i] += (1.0 / (dt * a_ii)) * value[i] +
2102 previous_time_derivatives[i];
2106 value_result[dim] += gradient[i][i];
2107 for (
int k = 0; k < dim; ++k)
2110 value_result[i] += gradient[i][k] * advective_value[k];
2115 for (
int i = 0; i < dim; ++i)
2117 for (
int k = 0; k < dim; ++k)
2120 gradient_result[dim][i] +=
2121 tau * (-kinematic_viscosity * hessian_diagonal[i][k] +
2122 gradient[i][k] * advective_value[k]);
2125 gradient_result[dim][i] += tau * (-source_value[i]);
2129 gradient_result[dim][i] +=
2130 tau * ((*bdf_coefficients)[0] * value[i] +
2131 previous_time_derivatives[i]);
2133 gradient_result[dim][i] +=
2134 tau * ((1.0 / (dt * a_ii)) * value[i] +
2135 previous_time_derivatives[i]);
2138 gradient_result[dim] += tau * gradient[dim];
2141 for (
int i = 0; i < dim; ++i)
2143 for (
int k = 0; k < dim; ++k)
2145 for (
int l = 0; l < dim; ++l)
2148 gradient_result[i][k] += -tau * kinematic_viscosity *
2149 advective_value[k] *
2150 hessian_diagonal[i][l];
2153 gradient_result[i][k] += tau * advective_value[k] *
2158 gradient_result[i][k] += tau * advective_value[k] *
2159 (gradient[dim][i] - source_value[i]);
2163 gradient_result[i][k] +=
2164 tau * advective_value[k] *
2165 ((*bdf_coefficients)[0] * value[i] +
2166 previous_time_derivatives[i]);
2169 gradient_result[i][k] += tau * advective_value[k] *
2170 ((1.0 / (dt * a_ii)) * value[i] +
2171 previous_time_derivatives[i]);
2179 for (
int i = 0; i < dim; ++i)
2181 for (
int k = 0; k < dim; ++k)
2185 for (
int l = 0; l < dim; ++l)
2188 hessian_result[i][k][k] +=
2189 tau * -kinematic_viscosity *
2190 (-kinematic_viscosity * hessian_diagonal[i][l] +
2191 gradient[i][l] * advective_value[l]);
2194 hessian_result[i][k][k] +=
2195 tau * -kinematic_viscosity *
2196 (gradient[dim][i] - source_value[i]);
2200 hessian_result[i][k][k] +=
2201 tau * -kinematic_viscosity *
2202 ((*bdf_coefficients)[0] * value[i] +
2203 previous_time_derivatives[i]);
2206 hessian_result[i][k][k] +=
2207 tau * -kinematic_viscosity *
2208 ((1.0 / (dt * a_ii)) * value[i] +
2209 previous_time_derivatives[i]);
2214 gradient_result[i][i] += tau_lsic * gradient[k][k];
2221 gradient_result = gradient_result * cell_mask;
2222 value_result = value_result * cell_mask;
2224 hessian_result = hessian_result * cell_mask;
2227 integrator.submit_gradient(gradient_result, q);
2228 integrator.submit_value(value_result, q);
2230 integrator.submit_hessian(hessian_result, q);
2234 integrator.integrate_scatter(EvaluationFlags::values |
2235 EvaluationFlags::gradients |
2236 EvaluationFlags::hessians,
2239 integrator.integrate_scatter(EvaluationFlags::values |
2240 EvaluationFlags::gradients,
2251template <
int dim,
typename number>
2272template <
int dim,
typename number>
2278 integrator.evaluate(EvaluationFlags::values | EvaluationFlags::gradients |
2279 EvaluationFlags::hessians);
2281 integrator.evaluate(EvaluationFlags::values | EvaluationFlags::gradients);
2283 const unsigned int cell = integrator.get_current_cell_index();
2286 VectorizedArray<number> cell_mask(1.0);
2299 const double a_ii = time_stepping_data.
a_ii;
2300 const double dt = time_stepping_data.
dt;
2301 const bool is_bdf = time_stepping_data.
is_bdf;
2302 const bool is_sdirk = time_stepping_data.
is_sdirk;
2303 const bool transient = time_stepping_data.
is_transient;
2306 for (
const auto q : integrator.quadrature_point_indices())
2308 Tensor<1, dim, VectorizedArray<number>> source_value;
2319 typename FECellIntegrator::value_type value = integrator.get_value(q);
2320 typename FECellIntegrator::gradient_type gradient =
2321 integrator.get_gradient(q);
2322 typename FECellIntegrator::gradient_type hessian_diagonal;
2325 hessian_diagonal = integrator.get_hessian_diagonal(q);
2328 typename FECellIntegrator::value_type value_result;
2329 typename FECellIntegrator::gradient_type gradient_result;
2330 typename FECellIntegrator::hessian_type hessian_result;
2335 auto previous_hessian_diagonal =
2337 auto previous_advective_values =
2340 Tensor<1, dim + 1, VectorizedArray<number>> previous_time_derivatives;
2342 previous_time_derivatives =
2354 const auto kinematic_viscosity =
2365 typename FECellIntegrator::gradient_type
shear_rate;
2366 for (
int i = 0; i < dim; ++i)
2368 for (
int j = 0; j < dim; ++j)
2370 shear_rate[i][j] = gradient[i][j] + gradient[j][i];
2376 VectorizedArray<number> shear_rate_previous_product =
2377 VectorizedArray<number>(0.);
2379 for (
int i = 0; i < dim; ++i)
2381 for (
int k = 0; k < dim; ++k)
2383 shear_rate_previous_product +=
2389 value_result[dim] = VectorizedArray<number>(0.);
2390 for (
int i = 0; i < dim; ++i)
2393 gradient_result[i][i] = -value[dim];
2395 value_result[dim] += gradient[i][i];
2397 gradient_result[i] += kinematic_viscosity *
shear_rate[i];
2398 for (
int k = 0; k < dim; ++k)
2403 shear_rate_previous_product *
2406 value_result[i] += gradient[i][k] * previous_advective_values[k] +
2407 previous_gradient[i][k] * value[k];
2411 value_result[i] += (*bdf_coefficients)[0] * value[i];
2414 value_result[i] += (1.0 / (dt * a_ii)) * value[i];
2419 for (
int i = 0; i < dim; ++i)
2421 for (
int k = 0; k < dim; ++k)
2424 gradient_result[dim][i] +=
2425 tau * (-kinematic_viscosity * hessian_diagonal[i][k] -
2427 gradient[i][k] * previous_advective_values[k] +
2428 previous_gradient[i][k] * value[k]);
2432 gradient_result[dim][i] += tau * (*bdf_coefficients)[0] * value[i];
2434 gradient_result[dim][i] += tau * (1.0 / (dt * a_ii)) * value[i];
2437 gradient_result[dim] += tau * gradient[dim];
2440 for (
int i = 0; i < dim; ++i)
2442 for (
int k = 0; k < dim; ++k)
2445 for (
int l = 0; l < dim; ++l)
2449 gradient_result[i][k] +=
2450 tau * previous_advective_values[k] *
2451 (gradient[i][l] * previous_advective_values[l] +
2452 previous_gradient[i][l] * value[l] -
2453 kinematic_viscosity * hessian_diagonal[i][l] -
2457 gradient_result[i][k] +=
2458 tau * previous_advective_values[k] * (gradient[dim][i]);
2462 gradient_result[i][k] += tau * previous_advective_values[k] *
2463 ((*bdf_coefficients)[0] * value[i]);
2466 gradient_result[i][k] += tau * previous_advective_values[k] *
2467 ((1.0 / (dt * a_ii)) * value[i]);
2471 for (
int l = 0; l < dim; ++l)
2474 gradient_result[i][k] +=
2476 (previous_gradient[i][l] * previous_advective_values[l] -
2477 kinematic_viscosity * previous_hessian_diagonal[i][l] -
2482 gradient_result[i][k] +=
2483 tau * value[k] * (previous_gradient[dim][i] - source_value[i]);
2487 gradient_result[i][k] +=
2489 ((*bdf_coefficients)[0] * previous_values[i] +
2490 previous_time_derivatives[i]);
2492 gradient_result[i][k] +=
2494 ((1.0 / (dt * a_ii)) * previous_values[i] +
2495 previous_time_derivatives[i]);
2501 gradient_result = gradient_result * cell_mask;
2502 value_result = value_result * cell_mask;
2504 hessian_result = hessian_result * cell_mask;
2507 integrator.submit_gradient(gradient_result, q);
2508 integrator.submit_value(value_result, q);
2511 integrator.submit_hessian(hessian_result, q);
2515 integrator.integrate(EvaluationFlags::values | EvaluationFlags::gradients |
2516 EvaluationFlags::hessians);
2518 integrator.integrate(EvaluationFlags::values | EvaluationFlags::gradients);
2533template <
int dim,
typename number>
2540 const std::pair<unsigned int, unsigned int> &range)
const
2544 for (
unsigned int cell = range.first; cell < range.second; ++cell)
2546 integrator.reinit(cell);
2547 integrator.read_dof_values_plain(src);
2550 integrator.evaluate(EvaluationFlags::values |
2551 EvaluationFlags::gradients |
2552 EvaluationFlags::hessians);
2554 integrator.evaluate(EvaluationFlags::values |
2555 EvaluationFlags::gradients);
2558 VectorizedArray<number> cell_mask(1.0);
2571 const double a_ii = time_stepping_data.
a_ii;
2572 const double dt = time_stepping_data.
dt;
2573 const bool is_bdf = time_stepping_data.
is_bdf;
2574 const bool is_sdirk = time_stepping_data.
is_sdirk;
2575 const bool transient = time_stepping_data.
is_transient;
2579 for (
const auto q : integrator.quadrature_point_indices())
2581 Tensor<1, dim, VectorizedArray<number>> source_value;
2592 typename FECellIntegrator::value_type value = integrator.get_value(q);
2593 typename FECellIntegrator::gradient_type gradient =
2594 integrator.get_gradient(q);
2595 typename FECellIntegrator::gradient_type hessian_diagonal;
2596 const auto advective_value =
2600 hessian_diagonal = integrator.get_hessian_diagonal(q);
2603 Tensor<1, dim + 1, VectorizedArray<number>> previous_time_derivatives;
2605 previous_time_derivatives =
2612 const auto kinematic_viscosity =
2620 typename FECellIntegrator::value_type value_result;
2621 typename FECellIntegrator::gradient_type gradient_result;
2622 typename FECellIntegrator::hessian_type hessian_result;
2625 typename FECellIntegrator::gradient_type
shear_rate;
2628 for (
int i = 0; i < dim; ++i)
2630 for (
int j = 0; j < dim; ++j)
2632 shear_rate[i][j] = gradient[i][j] + gradient[j][i];
2637 for (
int i = 0; i < dim; ++i)
2640 gradient_result[i] = kinematic_viscosity *
shear_rate[i];
2642 gradient_result[i][i] += -value[dim];
2644 value_result[i] = -source_value[i];
2648 value_result[i] += (*bdf_coefficients)[0] * value[i] +
2649 previous_time_derivatives[i];
2652 (1.0 / (dt * a_ii)) * value[i] + previous_time_derivatives[i];
2656 value_result[dim] += gradient[i][i];
2658 for (
int k = 0; k < dim; ++k)
2661 value_result[i] += gradient[i][k] * advective_value[k];
2666 for (
int i = 0; i < dim; ++i)
2668 for (
int k = 0; k < dim; ++k)
2671 gradient_result[dim][i] +=
2672 tau * (-kinematic_viscosity * hessian_diagonal[i][k] -
2674 gradient[i][k] * advective_value[k]);
2677 gradient_result[dim][i] += tau * (-source_value[i]);
2681 gradient_result[dim][i] +=
2682 tau * ((*bdf_coefficients)[0] * value[i] +
2683 previous_time_derivatives[i]);
2685 gradient_result[dim][i] +=
2686 tau * ((1.0 / (dt * a_ii)) * value[i] +
2687 previous_time_derivatives[i]);
2690 gradient_result[dim] += tau * gradient[dim];
2693 for (
int i = 0; i < dim; ++i)
2695 for (
int k = 0; k < dim; ++k)
2697 for (
int l = 0; l < dim; ++l)
2700 gradient_result[i][k] +=
2701 tau * advective_value[k] *
2702 (-kinematic_viscosity * hessian_diagonal[i][l] -
2706 gradient_result[i][k] += tau * advective_value[k] *
2711 gradient_result[i][k] += tau * advective_value[k] *
2712 (gradient[dim][i] - source_value[i]);
2715 if (is_bdf || is_sdirk)
2716 gradient_result[i][k] +=
2717 tau * advective_value[k] *
2718 ((*bdf_coefficients)[0] * value[i] +
2719 previous_time_derivatives[i]);
2725 gradient_result = gradient_result * cell_mask;
2726 value_result = value_result * cell_mask;
2728 hessian_result = hessian_result * cell_mask;
2731 integrator.submit_gradient(gradient_result, q);
2732 integrator.submit_value(value_result, q);
2734 integrator.submit_hessian(hessian_result, q);
2738 integrator.integrate_scatter(EvaluationFlags::values |
2739 EvaluationFlags::gradients |
2740 EvaluationFlags::hessians,
2743 integrator.integrate_scatter(EvaluationFlags::values |
2744 EvaluationFlags::gradients,
Vector< double > bdf_coefficients(const unsigned int p, const std::vector< double > &time_steps)
This class manages the boundary conditions forhe fluid dynamics solver It introduces the boundary fun...
Implements the matrix-free operator to solve steady/transient non-Newtonian Navier-Stokes equations u...
FEEvaluation< dim, -1, 0, dim+1, number > FECellIntegrator
void do_cell_integral_local(FECellIntegrator &integrator) const override
Perform cell integral on a cell batch without gathering and scattering the values,...
void local_evaluate_residual(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const override
Perform cell integral on a cell batch with gathering and scattering the values, and according to the ...
NavierStokesNonNewtonianStabilizedOperator()
LinearAlgebra::distributed::Vector< number > VectorType
A class that serves as base for all the matrix-free Navier-Stokes operators.
Table< 2, VectorizedArray< number > > face_target_pressure
Table with correct alignment for vectorization to store the values of the target pressure of a pressu...
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > nonlinear_previous_advective_values
Table with correct alignment for vectorization to store the values of the velocity within the advecti...
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > face_target_velocity
Table with correct alignment for vectorization to store the values of the target velocity of a weakly...
Table< 2, Tensor< 1, dim+1, Tensor< 1, dim, VectorizedArray< number > > > > nonlinear_previous_gradient
Table with correct alignment for vectorization to store the gradients of the previous newton step.
TrilinosWrappers::SparseMatrix system_matrix
Sparse trilinos matrix used when the matrix of certain level is computed and stored.
std::vector< unsigned int > constrained_indices
Vector with the constrained indices used for the local smoothing approach.
number el(unsigned int, unsigned int) const
Access a particular element in the matrix. Only required for compilation and it is not used.
Table< 2, bool > bool_dof_mask
DoF mask object needed for the sparsity pattern and computation of the system matrix of the coarse le...
void evaluate_velocity_ale(const Mapping< dim > &mapping, const Point< dim > center_of_rotation, const unsigned int rotation_axis_direction, const std::shared_ptr< Functions::ParsedFunction< dim > > &rotor_angular_velocity)
Store the values of the vector containing the ALE velocity to use them in the Jacobian and residual c...
virtual void local_evaluate_residual(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const =0
Interface to function in charge of computing the residual using a cell integral in a cell batch with ...
const DynamicSparsityPattern & get_sparsity_pattern() const
Return sparsity pattern used to set up the sparse matrix by get_system_matrix().
void do_boundary_face_integral_local(FEFaceIntegrator &integrator) const
Carry out the integration of boundary face integrals.
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > forcing_terms
Table with precomputed forcing term values.
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< number > &constraints, const Quadrature< dim > &quadrature, const std::shared_ptr< Function< dim > > &forcing_function, const std::shared_ptr< PhysicalPropertiesManager > &physical_properties_manager, const StabilizationType stabilization, const unsigned int mg_level, const std::shared_ptr< SimulationControl > &simulation_control, const BoundaryConditions::FluidDynamicsBoundaryConditions< dim > &boundary_conditions, const bool &enable_hessians_jacobian, const bool &enable_hessians_residual, const bool &enable_mortar)
Initialize the main matrix free object that contains all data and is needed to perform loops over cel...
bool has_edge_constrained_indices
Variable to identify whether there are edge constrained indices for the local smoothing approach.
virtual void evaluate_non_linear_term_and_calculate_tau(const VectorType &newton_step)
Store relevant values of the vector of the last newton step to use it in the Jacobian and pre-calcula...
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > velocity_ale
Table with correct alignment for vectorization to store the values of the ALE velocity used in mortar...
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > nonlinear_previous_values
Table with correct alignment for vectorization to store the values of the previous newton step.
std::shared_ptr< CouplingOperator< dim, double > > mortar_coupling_operator_mf
void update_beta_force(const Tensor< 1, dim > &beta_force)
Store the values of the source term calculated if dynamic control is enabled in the appropriate struc...
std::shared_ptr< PhysicalPropertiesManager > properties_manager
Object pointing to the physical properties manager of the matrix free class.
std::vector< unsigned int > edge_constrained_indices
Vector with the constrained edge indices for the local smoothing approach.
std::vector< std::pair< number, number > > constrained_values
Vector with the constrained values used for the local smoothing approach.
void compute_thermal_buoyancy_term(const VectorType &temperature_solution, const DoFHandler< dim > &temperature_dof_handler)
Precompute thermal buoyancy term for heat-transfer coupling.
void evaluate_prescribed_neumann_traction()
Store the values of the prescribed Neumann traction boundary condition to use it ....
Table< 2, Tensor< 1, dim, VectorizedArray< number > > > thermal_buoyancy_term
Table with precomputed thermal buoyancy term values.
bool enable_hessians_jacobian
Flag to turn hessian terms from jacobian on or off.
AffineConstraints< number > constraints
Object that stores constraints for the matrix free implementation.
bool enable_hessians_residual
Flag to turn hessian terms from residual on or off.
void clear()
Clear the matrix-free object.
void vmult_interface_down(VectorType &dst, VectorType const &src) const
Vmult operator for an interface. Required only if local smoothing multigrid is used and for meshes wi...
void vmult(VectorType &dst, const VectorType &src) const
Perform an operator evaluation dst = A*src by looping with the help of the MatrixFree object over all...
unsigned int fe_degree
Finite element degree for the operator.
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner() const
Get the vector partitioner object required for local smoothing multigrid preconditioner.
ConditionalOStream pcout
Conditional OStream for parallel output.
void do_boundary_face_integral_range(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const
Loop over all boundary face batches within certain range and perform a face integral with access to g...
BoundaryConditions::FluidDynamicsBoundaryConditions< dim > boundary_conditions
Boundary conditions object to impose the correct boundary conditions. This object is only used to imp...
void compute_element_size()
Compute the element size h of the cells required to calculate stabilization parameters.
Table< 2, VectorizedArray< number > > stabilization_parameter_lsic
Table with correct alignment for vectorization to store the values of the stabilization parameter tau...
Table< 1, VectorizedArray< number > > effective_beta_face
Table with correct alignment for vectorization to store the values of the face penalization term effe...
types::global_dof_index m() const
Get the total number of DoFs.
void compute_solid_cell_mask()
Compute a per-cell-batch mask that suppresses contributions from solid cells (material_id > 0)....
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > face_nonlinear_previous_values
Table with correct alignment for vectorization to store the values of the velocity at faces.
std::shared_ptr< Function< dim > > forcing_function
Force function or source function for the Navier-Stokes equations.
FEFaceEvaluation< dim, -1, 0, dim+1, number > FEFaceIntegrator
void evaluate_residual(VectorType &dst, const VectorType &src)
Evaluate right hand side using the matrix-free operator.
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > prescribed_neumann_traction
Table with correct alignment for vectorization to store the values of the prescribed Neumann traction...
TimeSteppingData initialize_time_stepping_data() const
Initialize time stepping data such as the time step size and BDF coefficients.
Table< 2, Tensor< 1, dim+1, Tensor< 1, dim, VectorizedArray< number > > > > previous_shear_rate
Table with correct alignment for vectorization to store the values of the shear_rate.
AlignedVector< VectorizedArray< number > > element_size
Aligned vector to store the element size of all the elements.
std::vector< number > edge_constrained_values
Vector with edge constrained values used for the local smoothing approach.
Table< 2, Tensor< 1, dim+1, Tensor< 2, dim, VectorizedArray< number > > > > nonlinear_previous_hessian
Table with correct alignment for vectorization to store the hessian of the previous newton step.
AlignedVector< VectorizedArray< number > > solid_cell_mask
Per-cell-batch mask used to suppress contributions from solid cells (material_id > 0) inside the cell...
void evaluate_time_derivative_previous_solutions(const VectorType &time_derivative_previous_solutions)
Store the values of the vector containing the time derivatives of previous solutions to use them in t...
void do_internal_face_integral_range(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const
Loop over all internal face batches within certain range and perform a face integral with access to g...
void do_cell_integral_range(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const
Loop over all cell batches within certain range and perform a cell integral with access to global vec...
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > time_derivatives_previous_solutions
Table with correct alignment for vectorization to store the time derivatives of previous solutions.
FEEvaluation< dim, -1, 0, dim+1, number > FECellIntegrator
Parameters::Stabilization::NavierStokesStabilization StabilizationType
void compute_inverse_diagonal(VectorType &diagonal) const
Compute the diagonal of the operator using an optimized MatrixFree function. Needed for preconditione...
virtual void do_cell_integral_local(FECellIntegrator &integrator) const =0
Interface to function that performs a cell integral in a cell batch without gathering and scattering ...
std::vector< bool > edge_constrained_cell
Vector used to mark edge constrained cells in order to verify constrained indices for the local smoot...
bool enable_mortar
Flag to turn the computation of mortar coupling terms on or off.
static IndexSet get_refinement_edges(const MatrixFree< dim, number > &matrix_free)
Get the refinement edges. Only needed if the local smoothing multigrid approach is used.
virtual void compute_forcing_term()
Precompute forcing term at the quadrature points. This is called when the operator is initialized and...
Table< 2, Tensor< 1, dim+1, VectorizedArray< number > > > kinematic_viscosity_gradient
Table with correct alignment for vectorization to store the values of the kinematic viscosity gradien...
TimerOutput timer
Timer for internal operator calls.
StabilizationType stabilization
Stabilization type needed to add or remove terms from operator.
std::shared_ptr< SimulationControl > simulation_control
Object storing the information regarding the time stepping method.
NavierStokesOperatorBase()
Default constructor.
const AlignedVector< VectorizedArray< number > > get_element_size() const
Get the element size object.
void initialize_dof_vector(VectorType &vec) const
Initialize a given vector by delegating it to the MatrixFree function in charge of this task.
bool has_solids
Flag indicating whether the simulation contains any solid region (material_id > 0)....
const MatrixFree< dim, number > & get_system_matrix_free() const
Get the system matrix free object.
Table< 2, Tensor< 1, dim+1, Tensor< 1, dim, VectorizedArray< number > > > > nonlinear_previous_hessian_diagonal
Table with correct alignment for vectorization to store the hessian diagonal of the previous newton s...
bool enable_face_terms
Flag to turn the calculation of face terms on or off. This is used for weakly imposed Dirichlet bound...
Tensor< 1, dim, VectorizedArray< number > > beta_force
Additional source term in the case of dynamic flow control.
Table< 2, VectorizedArray< number > > grad_kinematic_viscosity_shear_rate
Table with correct alignment for vectorization to store the values of the gradient of the kinematic v...
Table< 2, VectorizedArray< number > > kinematic_viscosity_vector
Table with correct alignment for vectorization to store the values of the kinematic viscosity.
Table< 2, VectorizedArray< number > > stabilization_parameter
Table with correct alignment for vectorization to store the values of the stabilization parameter tau...
void Tvmult(VectorType &dst, const VectorType &src) const
Perform the transposed operator evaluation.
void vmult_interface_up(VectorType &dst, VectorType const &src) const
Vmult operator for an interface. Required only if local smoothing multigrid is used and for meshes wi...
DynamicSparsityPattern dsp
Sparsity pattern used when the matrix of certain level is computed and stored.
LinearAlgebra::distributed::Vector< number > VectorType
const TrilinosWrappers::SparseMatrix & get_system_matrix() const
Calculate matrix if needed, e.g., by coarse-grid solver when a multigrid algorithm is used.
Table< 2, VectorizedArray< number > > previous_shear_rate_magnitude
Table with correct alignment for vectorization to store the values of the shear_rate_magnitude.
MatrixFree< dim, number > matrix_free
Object storing all the relevant data needed for the matrix free implementation.
Implements the matrix-free operator to solve steady/transient Navier-Stokes equations using stabiliza...
void local_evaluate_residual(const MatrixFree< dim, number > &matrix_free, VectorType &dst, const VectorType &src, const std::pair< unsigned int, unsigned int > &range) const override
Perform cell integral on a cell batch with gathering and scattering the values, and according to the ...
void do_cell_integral_local(FECellIntegrator &integrator) const override
Perform cell integral on a cell batch without gathering and scattering the values,...
LinearAlgebra::distributed::Vector< number > VectorType
NavierStokesStabilizedOperator()
FEEvaluation< dim, -1, 0, dim+1, number > FECellIntegrator
std::vector< double > a_ij
double compute_cell_diameter(const double cell_measure, const unsigned int fe_degree)
Computes equivalent cell diameter by comparing the area to a disk (2D) or the volume to a sphere (3D)...
const Table< 2, bool > create_bool_dof_mask(const FiniteElement< dim, spacedim > &fe, const Quadrature< dim > &quadrature)
Creates and fills a table that works as bool dof mask object needed for the sparsity pattern and comp...
bool boundary_condition_requires_face_assembly(BoundaryConditions::FluidDynamicsBoundaryType boundary_type)
Check if a boundary condition type requires face assembly in the matrix-free operator.
VectorizedArray< Number > evaluate_function(const Function< dim > &function, const Point< dim, VectorizedArray< Number > > &p_vectorized, const unsigned int component=0)
Evaluate the value of a function at a batch of points to obtain a vectorized array of numbers.
@ velocity
Velocity vector field from fluid dynamics.
FluidDynamicsBoundaryType
SDIRKTable sdirk_table(const Parameters::SimulationControl::TimeSteppingMethod method)
Construct the Butcher tableau (A, b, c) for a given SDIRK method.
Structure representing a Butcher tableau for a SDIRK method.
Data structure to store time-stepping data in the matrix-free operator. This is a very small structur...
bool is_transient
Boolean indicating if the method is transient.
bool is_bdf
Boolean indicating that the method is a BDF method.
const Vector< double > * bdf_coefficients
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.