22#include <deal.II/base/work_stream.h>
24#include <deal.II/fe/fe_q.h>
26#include <deal.II/grid/grid_tools.h>
28#include <deal.II/lac/full_matrix.h>
30#include <boost/signals2/connection.hpp>
100 std::vector<std::unordered_map<types::global_dof_index, bool>>
101 inside_outside_support_point_vector(
particles.size());
102 std::map<types::global_dof_index, Point<dim>> support_points =
112 const bool mapping_overconstrained_cells =
119 if (mapping_overconstrained_cells)
128 const auto &cell_iterator = this->
dof_handler->active_cell_iterators();
129 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
130 const unsigned int dofs_per_face = this->
fe->dofs_per_face;
132 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
133 std::vector<types::global_dof_index> local_face_dof_indices(dofs_per_face);
135 auto &v_x_fe = this->
fe->get_sub_fe(0, 1);
136 const unsigned int dofs_per_cell_local_v_x = v_x_fe.dofs_per_cell;
140 for (
const auto &cell : cell_iterator)
142 if (cell->is_locally_owned() || cell->is_ghost())
144 bool cell_is_cut =
false;
145 bool cell_is_inside =
false;
146 unsigned int particle_id_which_cuts_this_cell = 0;
147 unsigned int particle_id_in_which_this_cell_is_embedded = 0;
148 std::vector<unsigned int> particles_cutting_this_cell;
155 cell->get_dof_indices(local_dof_indices);
157 for (
unsigned int p = 0; p <
particles.size(); ++p)
164 if (
particles[p].shape->additional_info_on_shape ==
"iges")
171 if (particles_cutting_this_cell.size() == 0)
174 particle_id_which_cuts_this_cell = p;
176 particles_cutting_this_cell.push_back(p);
181 unsigned int nb_dof_inside = 0;
182 for (
unsigned int j = 0; j < local_dof_indices.size(); ++j)
187 if (0 == this->
fe->system_to_component_index(j).first)
194 support_points[local_dof_indices[j]], cell) <=
198 inside_outside_support_point_vector
199 [p][local_dof_indices[j]] =
true;
206 if (nb_dof_inside != 0)
210 if (nb_dof_inside == dofs_per_cell_local_v_x)
215 if (particles_cutting_this_cell.size() == 0)
218 particle_id_which_cuts_this_cell = 0;
219 cell_is_inside =
true;
220 particle_id_in_which_this_cell_is_embedded = p;
229 if (particles_cutting_this_cell.size() == 0)
232 particle_id_which_cuts_this_cell = p;
233 cell_is_inside =
false;
234 particle_id_in_which_this_cell_is_embedded = 0;
236 particles_cutting_this_cell.push_back(p);
237 if (particles_cutting_this_cell.size() > 1)
239 for (
const auto &dof_index : local_dof_indices)
249 if (particles_cutting_this_cell.size() == 0)
252 particle_id_which_cuts_this_cell = 0;
253 cell_is_inside =
false;
254 particle_id_in_which_this_cell_is_embedded = 0;
260 if (mapping_overconstrained_cells)
267 for (
const auto &
id : local_dof_indices)
275 size_t nb_faces = cell->n_faces();
276 for (
unsigned int f = 0; f < nb_faces; ++f)
278 const auto face = cell->face(f);
279 if (face->at_boundary())
281 face->get_dof_indices(local_face_dof_indices);
282 for (
const auto &
id : local_face_dof_indices)
291 particle_id_which_cuts_this_cell,
292 particles_cutting_this_cell};
294 particle_id_in_which_this_cell_is_embedded};
298 if (mapping_overconstrained_cells)
304 for (
const auto &cell : cell_iterator)
306 if (cell->is_locally_owned() || cell->is_ghost())
310 cell->get_dof_indices(local_dof_indices);
311 std::tie(cell_is_cut, std::ignore, std::ignore) =
314 if (!cell_is_cut && !cell_is_inside)
316 unsigned int number_of_vertices_in_cell =
317 local_dof_indices.size();
318 unsigned int number_of_vertices_cut = 0;
319 unsigned int particle_current_id =
320 std::numeric_limits<int>::max();
322 double particle_current_distance(
323 std::numeric_limits<double>::max());
324 double particle_candidate_distance(
325 std::numeric_limits<double>::max());
327 unsigned int global_dof_id;
329 for (
unsigned int j = 0; j < number_of_vertices_in_cell; ++j)
331 global_dof_id = local_dof_indices[j];
334 number_of_vertices_cut += 1;
340 if (number_of_vertices_in_cell == number_of_vertices_cut)
342 for (
unsigned int p = 0; p <
particles.size(); p++)
344 particle_candidate_distance =
345 particles[p].get_levelset(cell->barycenter(), cell);
346 if (abs(particle_candidate_distance) <
347 abs(particle_current_distance))
349 particle_current_id = p;
350 particle_current_distance =
351 particle_candidate_distance;
355 for (
const auto &local_dof_index : local_dof_indices)
362 true, particle_current_id, particle_current_distance};
379 bool update_precalculations_flag =
false;
380 bool remove_superfluous_data_flag =
false;
383 const boost::signals2::scoped_connection post_refinement_connection =
385 [&update_precalculations_flag]() { update_precalculations_flag =
true; });
389 if (initial_refinement)
396 ->time_extrapolation_of_refinement_zone ||
402 ->second.refinement_fraction;
405 ->second.coarsening_fraction;
407 ->second.refinement_fraction = 0;
409 ->second.coarsening_fraction = 0;
411 for (
unsigned int i = 0;
416 update_precalculations_flag =
false;
417 this->
pcout <<
"Initial refinement around IB particles - Step : "
424 if (update_precalculations_flag)
426 remove_superfluous_data_flag =
true;
431 ->second.refinement_fraction = temp_refine;
433 ->second.coarsening_fraction = temp_coarse;
435 if (initial_refinement ==
false)
437 update_precalculations_flag =
false;
440 if (update_precalculations_flag)
442 remove_superfluous_data_flag =
true;
446 if (remove_superfluous_data_flag || initial_refinement)
448 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
460 const typename DoFHandler<dim>::active_cell_iterator &cell,
461 std::map<types::global_dof_index, Point<dim>> &support_points,
471 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
472 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
473 cell->get_dof_indices(local_dof_indices);
474 bool cell_is_cut =
false;
475 Point<dim> centroid_of_cell = cell->barycenter();
476 Point<dim> projected_point;
477 particles[p].closest_surface_point(centroid_of_cell, projected_point, cell);
480 if (cell->point_inside(projected_point))
489 for (
unsigned int j = 0; j < local_dof_indices.size(); ++j)
492 if (0 == this->
fe->system_to_component_index(j).first)
495 support_points[local_dof_indices[j]], projected_point, cell);
497 if (cell->point_inside(projected_point))
502 if ((projected_point - support_points[local_dof_indices[j]])
503 .norm() < cell->diameter() * 0.1)
518 TimerOutput::Scope t(this->
computing_timer,
"Optmize cut cells mapping");
520 unsigned int max_children = GeometryInfo<dim>::max_children_per_cell;
522 std::set<typename DoFHandler<dim>::cell_iterator> all_candidate_cells;
523 std::set<typename DoFHandler<dim>::cell_iterator>
524 previous_all_candidate_cells;
528 for (
const auto &cell : this->
dof_handler->active_cell_iterators())
530 if (cell->is_locally_owned() || cell->is_ghost())
532 cut_cells_map[cell] = {
false, 0, std::vector<unsigned int>()};
542 for (
int p =
particles.size() - 1; p >= 0; --p)
545 unsigned int lvl_iter = 0;
548 unsigned int max_lvl_search =
549 this->
dof_handler->get_triangulation().n_levels() - 2;
550 if (max_lvl_search < 4)
551 max_lvl_search = this->
dof_handler->get_triangulation().n_levels();
555 while (empty || lvl_iter < max_lvl_search)
557 const auto &cell_iterator =
558 this->
dof_handler->cell_iterators_on_level(lvl_iter);
561 for (
const auto &cell : cell_iterator)
566 if (is_candidate.first)
568 all_candidate_cells.insert(cell);
570 if (is_candidate.second)
572 all_candidate_cells.insert(cell);
575 if (all_candidate_cells.size() > 0)
582 previous_all_candidate_cells = all_candidate_cells;
585 if (all_candidate_cells.size() != 0)
587 bool all_cells_are_active =
false;
590 while (!all_cells_are_active)
592 all_cells_are_active =
true;
593 all_candidate_cells.clear();
597 for (
auto cell : previous_all_candidate_cells)
602 if (is_candidate.first)
605 if (cell->is_active())
612 all_cells_are_active =
false;
613 for (
unsigned int j = 0; j < max_children; ++j)
617 all_candidate_cells.insert(cell->child(j));
622 if (is_candidate.second)
625 if (cell->is_active())
629 std::vector<unsigned int>()};
634 all_cells_are_active =
false;
635 for (
unsigned int j = 0; j < max_children; ++j)
639 all_candidate_cells.insert(cell->child(j));
644 previous_all_candidate_cells.clear();
645 previous_all_candidate_cells = all_candidate_cells;
655 const typename DoFHandler<dim>::cell_iterator &cell,
656 const unsigned int p_id)
658 bool cell_is_inside =
false;
659 bool cell_is_cut =
false;
661 double search_radius =
particles[p_id].radius * (1.0 - 1e-07);
662 auto position =
particles[p_id].position;
667 unsigned int nb_vertices_inside = 0;
668 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_cell; ++i)
670 if ((cell->vertex(i) - position).norm() < search_radius)
671 ++nb_vertices_inside;
675 if (nb_vertices_inside > 0)
679 if (nb_vertices_inside == GeometryInfo<dim>::vertices_per_cell)
681 cell_is_inside =
true;
687 cell_is_inside =
false;
690 return {cell_is_inside, cell_is_cut};
697 cell_is_inside =
true;
699 return {cell_is_inside, cell_is_cut};
709 std::vector<Point<dim>> manifold_points(
710 GeometryInfo<dim - 1>::vertices_per_cell);
713 for (
const auto face : cell->face_indices())
715 auto face_iter = cell->face(face);
716 auto &local_face_manifold = face_iter->get_manifold();
719 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_face; ++i)
722 manifold_points[i] = face_iter->vertex(i);
726 auto surrounding_face_points =
727 make_array_view(manifold_points.begin(), manifold_points.end());
730 for (
unsigned int i = 0; i < GeometryInfo<dim>::vertices_per_face; ++i)
733 Point<dim> projected_point =
734 local_face_manifold.project_to_manifold(surrounding_face_points,
737 bool projected_point_over_face =
true;
738 Tensor<1, dim> projected_point_tensor(projected_point);
743 projected_point_over_face = cell->point_inside(projected_point);
745 if ((position - projected_point).norm() < search_radius &&
746 projected_point_over_face)
748 cell_is_inside =
true;
750 return {cell_is_inside, cell_is_cut};
756 projected_point_over_face =
false;
759 for (
int d = 0; d != dim; d++)
761 if (projected_point_tensor[d] < 0 ||
762 projected_point_tensor[d] > 1)
764 projected_point_over_face =
false;
769 return {cell_is_inside, cell_is_cut};
779 ->load_particles_from_file ==
false)
783 for (
unsigned int i = 0;
789 if (
particles[i].integrate_motion ==
true)
800 for (
unsigned int i = 0; i <
particles.size(); ++i)
802 if (
particles[i].integrate_motion ==
true)
814 std::make_shared<Parameters::Lagrangian::BCDEM>(
816 this->mpi_communicator,
821 std::vector<std::shared_ptr<Shape<dim>>> all_shapes(
particles.size());
824 all_shapes[particle.particle_id] = particle.shape;
827 std::make_shared<CompositeShape<dim>>(all_shapes, Point<dim>(), Point<3>());
840 this->simulation_parameters.mesh_adaptation))
842 bool stationary_particles =
true;
843 for (
unsigned int p = 0; p <
particles.size(); ++p)
850 stationary_particles =
false;
854 if (stationary_particles)
859 "Refine around immersed boundary");
860 Point<dim> center_immersed;
861 std::map<types::global_dof_index, Point<dim>> support_points =
866 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
867 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
869 bool extrapolate_particle_position =
871 ->time_extrapolation_of_refinement_zone;
873 double smallest_cut_cell = std::numeric_limits<double>::max();
874 bool minimal_crown_refinement_enabled =
876 ->refinement_outside_distance_factor -
879 ->refinement_inside_distance_factor -
881 if (minimal_crown_refinement_enabled)
883 const auto &cell_iterator_smallest_cell =
885 for (
const auto &cell : cell_iterator_smallest_cell)
887 if (cell->is_locally_owned())
888 smallest_cut_cell = std::min(smallest_cut_cell, cell->diameter());
894 const auto &cell_iterator = this->
dof_handler->active_cell_iterators();
895 for (
const auto &cell : cell_iterator)
897 if (cell->is_locally_owned())
899 bool cell_can_be_coarsened =
902 cell->get_dof_indices(local_dof_indices);
903 for (
unsigned int p = 0; p <
particles.size(); ++p)
905 unsigned int count_small = 0;
910 Point<dim> particle_position;
911 Tensor<1, 3> particle_orientation;
912 if (extrapolate_particle_position)
914 particle_position =
particles[p].position;
915 particle_orientation =
particles[p].orientation;
923 if constexpr (dim == 3)
936 bool cell_as_ib_inside =
937 cell->point_inside(
particles[p].position + r);
938 bool cell_is_near_particle_for_coarsening =
false;
940 for (
unsigned int j = 0; j < local_dof_indices.size(); ++j)
943 if (this->
fe->system_to_component_index(j).first == 0)
951 bool is_inside_crown;
952 if (minimal_crown_refinement_enabled)
959 double factor = 1 / sqrt(dim);
960 is_inside_crown =
particles[p].is_inside_crown(
961 support_points[local_dof_indices[j]],
962 factor * smallest_cut_cell,
963 -factor * smallest_cut_cell,
970 is_inside_crown =
particles[p].is_inside_crown(
971 support_points[local_dof_indices[j]],
973 ->refinement_outside_distance_factor,
974 this->simulation_parameters.particlesParameters
975 ->refinement_inside_distance_factor,
981 if (cell_can_be_coarsened)
983 const double coarsening_distance =
984 particles[p].shape->value_with_cell_guess(
985 support_points[local_dof_indices[j]], cell);
986 const double coarsening_threshold =
989 ->coarsening_distance_factor -
992 if (coarsening_distance <= coarsening_threshold)
993 cell_is_near_particle_for_coarsening =
true;
1003 if (extrapolate_particle_position)
1005 particles[p].position = particle_position;
1006 particles[p].orientation = particle_orientation;
1011 if (cell_as_ib_inside || cell_is_near_particle_for_coarsening)
1012 cell_can_be_coarsened =
false;
1014 if (count_small > 0 || cell_as_ib_inside)
1016 cell->set_refine_flag();
1021 if (cell_can_be_coarsened && !cell->refine_flag_set())
1022 cell->set_coarsen_flag();
1037 "Evaluate force on immersed boundary");
1039 const FEValuesExtractors::Scalar
pressure(dim);
1040 const FEValuesExtractors::Vector velocities(0);
1042 std::vector<double> time_steps_vector =
1045 std::map<types::global_dof_index, Point<dim>> support_points =
1050 MappingQ<dim - 1, dim> local_face_map(
1053 this->simulation_parameters.fem_parameters.velocity_degree);
1055 FESystem<dim - 1, dim> local_face_fe(
1060 this->simulation_parameters.fem_parameters.pressure_degree),
1062 FEValues<dim - 1, dim> fe_face_projection_values(local_face_map,
1066 update_quadrature_points |
1069 update_normal_vectors);
1073 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
1074 const unsigned int dofs_per_face = this->
fe->dofs_per_face;
1077 .density_is_constant(),
1078 RequiresConstantDensity(
"FluidDynamicsSharp<dim>::force_on_ib"));
1080 unsigned int degree =
1082 auto density_model =
1084 std::map<field, double> field_values;
1086 double fluid_density = density_model->value(field_values);
1087 double length_ratio =
1090 std::vector<double> ib_coef = stencil.
coefficients(degree, length_ratio);
1093 double kinematic_viscosity;
1094 const auto rheological_model =
1097 const unsigned int vertices_per_face = GeometryInfo<dim>::vertices_per_face;
1100 std::vector<double> pressure_values(ib_coef.size());
1101 Tensor<1, dim> normal_vector;
1102 std::vector<Tensor<2, dim>> velocity_gradients(ib_coef.size());
1103 std::vector<std::vector<Tensor<1, dim>>> velocity_gradients_component(dim +
1105 for (
int i = 0; i < dim + 1; ++i)
1106 velocity_gradients_component[i].resize(ib_coef.size());
1107 Tensor<2, dim> fluid_viscous_stress;
1108 Tensor<2, dim> fluid_pressure;
1109 Tensor<2, dim> fluid_viscous_stress_at_ib;
1110 Tensor<2, dim> fluid_pressure_stress_at_ib;
1112 DoFHandler<dim - 1, dim> local_face_dof_handler;
1113 Triangulation<dim - 1, dim> local_face_projection_triangulation;
1115 std::vector<Point<dim>> vertices_of_face_projection(vertices_per_face);
1116 std::vector<CellData<dim - 1>> local_face_cell_data(1);
1118 typename Mapping<dim>::InternalDataBase mapping_data;
1123 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1124 std::vector<types::global_dof_index> local_dof_indices_2(dofs_per_cell);
1126 std::vector<types::global_dof_index> local_face_dof_indices(dofs_per_face);
1128 std::vector<Point<dim>> unite_cell_interpolation_points(ib_coef.size());
1129 std::vector<Point<dim>> cell_interpolation_points(ib_coef.size());
1130 std::vector<double> local_interp_sol(ib_coef.size());
1132 std::unordered_map<unsigned int, std::pair<Tensor<2, dim>, Tensor<2, dim>>>
1136 const auto &cell_iterator = this->
dof_handler->active_cell_iterators();
1139 for (
unsigned int i = 0; i <
particles.size(); ++i)
1148 for (
const auto &cell : cell_iterator)
1150 if (cell->is_locally_owned())
1153 unsigned int p_main;
1155 std::vector<unsigned int> p_count;
1157 std::tie(cell_is_cut, p_main, p_count) =
cut_cells_map[cell];
1162 for (
auto p : p_count)
1165 for (
const auto face : cell->face_indices())
1167 auto local_face = cell->face(face);
1168 cell->face(face)->get_dof_indices(local_face_dof_indices);
1171 unsigned int nb_dof_inside = 0;
1172 for (
const auto &dof_index : local_face_dof_indices)
1178 support_points[dof_index], cell) <= 0)
1185 if (nb_dof_inside == 0)
1189 Tensor<1, dim> approximate_surface_cell_normal;
1194 for (
unsigned int i = 0; i < vertices_per_face; ++i)
1196 Point<dim> vertex_projection;
1198 local_face->vertex(i), vertex_projection, cell);
1199 approximate_surface_cell_normal +=
1200 (local_face->vertex(i) - vertex_projection) /
1201 ((local_face->vertex(i) - vertex_projection)
1207 for (
int j = 0; j < dim; ++j)
1209 vertices_of_face_projection[i][j] =
1210 vertex_projection[j];
1214 local_face_cell_data[0].vertices[i] = i;
1216 approximate_surface_cell_normal =
1217 approximate_surface_cell_normal / vertices_per_face;
1219 local_face_cell_data[0].material_id = 0;
1221 local_face_projection_triangulation =
1222 Triangulation<dim - 1, dim>();
1226 local_face_projection_triangulation
1227 .create_triangulation(vertices_of_face_projection,
1228 local_face_cell_data,
1230 local_face_projection_triangulation
1231 .set_all_manifold_ids(0);
1232 local_face_projection_triangulation.set_manifold(
1233 0, *
particles[p].shape->get_shape_manifold());
1235 local_face_dof_handler.reinit(
1236 local_face_projection_triangulation);
1237 local_face_dof_handler.distribute_dofs(local_face_fe);
1242 std::vector<Tensor<2, dim>>
1243 local_face_viscous_stress_tensor(dofs_per_face);
1244 std::vector<Tensor<2, dim>>
1245 local_face_pressure_tensor(dofs_per_face);
1246 for (
unsigned int i = 0;
1247 i < local_face_dof_indices.size();
1250 const unsigned int component_i =
1251 this->
fe->face_system_to_component_index(i)
1256 if (force_eval.find(local_face_dof_indices[i]) ==
1259 [local_face_dof_indices[i]] ==
true)
1261 if (component_i == 0)
1268 auto [point, interpolation_points] =
1275 [local_face_dof_indices[i]],
1279 ib_done[local_face_dof_indices[i]]
1285 if (
ib_done[local_face_dof_indices[i]]
1288 [local_face_dof_indices[i]] ==
1293 auto point_to_find_cell =
1297 [local_face_dof_indices[i]],
1302 cell_2 = LetheGridTools::
1303 find_cell_around_point_with_neighbors<
1307 point_to_find_cell);
1315 cell_2->get_dof_indices(
1316 local_dof_indices_2);
1318 unite_cell_interpolation_points[0] =
1320 ->transform_real_to_unit_cell(cell_2,
1322 for (
unsigned int j = 1;
1326 unite_cell_interpolation_points[j] =
1328 ->transform_real_to_unit_cell(
1330 interpolation_points[j - 1]);
1333 fluid_viscous_stress_at_ib = 0;
1334 fluid_pressure_stress_at_ib = 0;
1338 Quadrature<dim> q_local(
1339 unite_cell_interpolation_points,
1341 FEValues<dim> fe_values_cell2(
1344 update_quadrature_points |
1345 update_gradients | update_values);
1350 fe_values_cell2.reinit(cell_2);
1351 fe_values_cell2[velocities]
1352 .get_function_gradients(
1354 velocity_gradients);
1356 .get_function_values(
1363 for (
unsigned int k = 0;
1368 for (
int d = 0; d < dim; ++d)
1370 fluid_pressure[d][d] =
1374 velocity_gradients[k] +
1375 transpose(velocity_gradients[k]);
1378 const double shear_rate_magnitude =
1382 std::map<field, double> field_values;
1384 shear_rate_magnitude;
1386 kinematic_viscosity =
1387 rheological_model->value(
1390 fluid_viscous_stress =
1393 fluid_viscous_stress_at_ib -=
1394 fluid_viscous_stress * ib_coef[k];
1396 fluid_pressure_stress_at_ib -=
1397 fluid_pressure * ib_coef[k];
1405 local_face_viscous_stress_tensor[i] =
1406 fluid_viscous_stress_at_ib;
1407 local_face_pressure_tensor[i] =
1408 fluid_pressure_stress_at_ib;
1411 force_eval[local_face_dof_indices[i]] =
1413 fluid_viscous_stress_at_ib,
1414 fluid_pressure_stress_at_ib);
1423 local_face_viscous_stress_tensor[i] =
1424 force_eval[local_face_dof_indices[i]].first;
1425 local_face_pressure_tensor[i] =
1426 force_eval[local_face_dof_indices[i]]
1433 auto local_face_viscous_stress_tensor_old =
1434 local_face_viscous_stress_tensor;
1435 auto local_face_pressure_tensor_old =
1436 local_face_pressure_tensor;
1438 local_face_viscous_stress_tensor.clear();
1439 local_face_pressure_tensor.clear();
1441 local_face_viscous_stress_tensor.resize(
1442 local_face_dof_indices.size());
1443 local_face_pressure_tensor.resize(
1444 local_face_dof_indices.size());
1446 for (
const auto &projection_cell_face :
1447 local_face_dof_handler.active_cell_iterators())
1449 fe_face_projection_values.reinit(
1450 projection_cell_face);
1451 std::vector<Point<dim>> q_points =
1452 fe_face_projection_values
1453 .get_quadrature_points();
1457 .velocity_degree > 1)
1459 FullMatrix<double> interpolation_matrix(
1460 local_face_dof_indices.size(),
1461 local_face_dof_indices.size());
1463 inv_interpolation_matrix(
1464 local_face_dof_indices.size(),
1465 local_face_dof_indices.size());
1469 for (
unsigned int i = 0;
1470 i < local_face_dof_indices.size();
1473 Point<dim> point_projection;
1476 [local_face_dof_indices[i]],
1480 auto projected_point_unit =
1482 .transform_real_to_unit_cell(
1483 projection_cell_face,
1486 for (
unsigned int j = 0;
1488 local_face_dof_indices.size();
1491 interpolation_matrix[i][j] = 0;
1494 ->face_system_to_component_index(
1498 ->face_system_to_component_index(
1501 interpolation_matrix[i][j] +=
1502 local_face_fe.shape_value(
1503 j, projected_point_unit);
1506 inv_interpolation_matrix.invert(
1507 interpolation_matrix);
1511 for (
unsigned int i = 0;
1512 i < local_face_dof_indices.size();
1515 for (
unsigned int j = 0;
1517 local_face_dof_indices.size();
1520 local_face_viscous_stress_tensor
1522 inv_interpolation_matrix[i][j] *
1523 local_face_viscous_stress_tensor_old
1525 local_face_pressure_tensor[i] +=
1526 inv_interpolation_matrix[i][j] *
1527 local_face_pressure_tensor_old
1534 local_face_viscous_stress_tensor =
1535 local_face_viscous_stress_tensor_old;
1536 local_face_pressure_tensor =
1537 local_face_pressure_tensor_old;
1542 local_face_viscous_stress_tensor =
1543 local_face_viscous_stress_tensor_old;
1544 local_face_pressure_tensor =
1545 local_face_pressure_tensor_old;
1547 for (
unsigned int q = 0; q < n_q_points_face; q++)
1554 fe_face_projection_values.normal_vector(q);
1557 approximate_surface_cell_normal) < 0)
1558 normal_vector = -normal_vector;
1560 fluid_viscous_stress = 0;
1564 for (
unsigned int i = 0;
1565 i < local_face_dof_indices.size();
1568 const unsigned int component_i =
1570 .system_to_component_index(i)
1572 if (component_i == 0)
1574 fluid_viscous_stress +=
1575 fe_face_projection_values
1576 .shape_value(i, q) *
1577 local_face_viscous_stress_tensor[i];
1580 fe_face_projection_values
1581 .shape_value(i, q) *
1582 local_face_pressure_tensor[i];
1586 auto viscous_force =
1587 fluid_viscous_stress * normal_vector *
1588 fe_face_projection_values.JxW(q);
1590 auto pressure_force =
1591 fluid_pressure * normal_vector *
1592 fe_face_projection_values.JxW(q);
1594 auto force = viscous_force + pressure_force;
1622 if constexpr (dim == 2)
1627 distance[0] * force[1] -
1628 distance[1] * force[0];
1630 else if constexpr (dim == 3)
1633 distance[1] * force[2] -
1634 distance[2] * force[1];
1636 distance[2] * force[0] -
1637 distance[0] * force[2];
1639 distance[0] * force[1] -
1640 distance[1] * force[0];
1652 for (
unsigned int i = 0; i <
particles.size(); ++i)
1655 Utilities::MPI::sum(
particles[i].fluid_viscous_forces,
1659 Utilities::MPI::sum(
particles[i].fluid_pressure_forces,
1675 "Output forces on immersed boundary");
1676 for (
unsigned int p = 0; p <
particles.size(); ++p)
1681 std::string filename =
1684 ->ib_force_output_file +
1685 "." + Utilities::int_to_string(p, 2) +
".dat";
1686 std::ofstream output(filename.c_str());
1688 table_p[p].write_text(output);
1696std::vector<OutputStruct<dim, GlobalVectorType>>
1699 std::vector<OutputStruct<dim, GlobalVectorType>> solution_output_structs;
1704 solution_output_structs.emplace_back(
1710 Vector<float> cell_cuts(this->
triangulation->n_active_cells());
1711 Vector<float> cell_overconstrained(this->
triangulation->n_active_cells());
1712 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
1713 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1717 ->enable_extra_sharp_interface_vtu_output_field)
1720 const auto &cell_iterator = this->
dof_handler->active_cell_iterators();
1723 for (
const auto &cell : cell_iterator)
1725 if (cell->is_locally_owned())
1732 std::tie(cell_is_cut, particle_id, std::ignore) =
1735 cell_cuts(i) = particle_id;
1744 bool cell_is_overconstrained;
1745 std::tie(cell_is_overconstrained, particle_id, std::ignore) =
1747 if (cell_is_overconstrained)
1748 cell_overconstrained(i) = particle_id;
1750 cell_overconstrained(i) = -1;
1754 solution_output_structs.emplace_back(
1755 std::in_place_type<OutputStructCellVector>, cell_cuts,
"cell_cut");
1756 solution_output_structs.emplace_back(
1757 std::in_place_type<OutputStructCellVector>,
1758 cell_overconstrained,
1762 std::make_shared<LevelsetGradientPostprocessor<dim>>(
combined_shapes);
1763 solution_output_structs.emplace_back(
1769 return solution_output_structs;
1788 const std::pair<double, double> error =
1796 this->
error_table.add_value(
"error_velocity", error.first);
1797 this->
error_table.add_value(
"error_pressure", error.second);
1801 double total_time = 0;
1802 for (
auto it = summary.begin(); it != summary.end(); ++it)
1804 total_time += summary[it->first];
1806 this->
error_table.add_value(
"total_time", total_time);
1812 this->
error_table.add_value(
"error_velocity", error.first);
1813 this->
error_table.add_value(
"error_pressure", error.second);
1819 double total_time = 0;
1820 for (
auto it = summary.begin(); it != summary.end(); ++it)
1822 total_time += summary[it->first];
1824 this->
error_table.add_value(
"total_time", total_time);
1830 this->
pcout <<
"L2 error velocity : " << error.first
1831 <<
" L2 error pressure: " << error.second << std::endl;
1838std::pair<double, double>
1843 FEValues<dim> fe_values(*this->
mapping,
1846 update_values | update_gradients |
1847 update_quadrature_points | update_JxW_values);
1848 FEFaceValues<dim> fe_face_values(*this->
mapping,
1851 update_values | update_gradients |
1852 update_quadrature_points |
1855 const FEValuesExtractors::Vector velocities(0);
1856 const FEValuesExtractors::Scalar
pressure(dim);
1858 const unsigned int dofs_per_cell =
1859 this->
fe->dofs_per_cell;
1860 std::vector<types::global_dof_index> local_dof_indices(
1863 const unsigned int n_q_points = quadrature_formula.size();
1866 std::vector<Vector<double>> q_exactSol(n_q_points, Vector<double>(dim + 1));
1868 std::vector<Tensor<1, dim>> local_velocity_values(n_q_points);
1869 std::vector<Tensor<1, dim>> local_face_velocity_values(n_q_points_face);
1870 std::vector<double> local_pressure_values(n_q_points);
1871 std::vector<double> div_phi_u(dofs_per_cell);
1872 std::vector<Tensor<2, dim>> present_velocity_gradients(n_q_points);
1876 std::map<types::global_dof_index, Point<dim>> support_points =
1879 double l2errorU = 0.;
1880 double l2errorU_boundary = 0.;
1881 double l2errorP = 0.;
1882 double total_velocity_divergence = 0.;
1883 double pressure_integral = 0;
1884 double exact_pressure_integral = 0;
1888 typename DoFHandler<dim>::active_cell_iterator cell = this->
dof_handler
1894 for (; cell != endc; ++cell)
1896 if (cell->is_locally_owned())
1901 std::tie(cell_is_cut, std::ignore, std::ignore) =
cut_cells_map[cell];
1902 bool cell_is_inside;
1904 bool cell_is_overconstrained;
1905 std::tie(cell_is_overconstrained, std::ignore, std::ignore) =
1908 if ((!cell_is_cut && !cell_is_inside) && !cell_is_overconstrained)
1911 fe_values.reinit(cell);
1914 local_pressure_values);
1916 l_exact_solution->vector_value_list(
1917 fe_values.get_quadrature_points(), q_exactSol);
1921 cell->get_dof_indices(local_dof_indices);
1923 for (
unsigned int q = 0; q < n_q_points; q++)
1925 pressure_integral +=
1926 local_pressure_values[q] * fe_values.JxW(q);
1927 exact_pressure_integral +=
1928 q_exactSol[q][dim] * fe_values.JxW(q);
1929 volume += fe_values.JxW(q);
1937 exact_pressure_integral =
1942 double average_pressure = pressure_integral / volume;
1943 double average_exact_pressure = exact_pressure_integral / volume;
1946 for (; cell != endc; ++cell)
1948 if (cell->is_locally_owned())
1950 cell->get_dof_indices(local_dof_indices);
1955 std::tie(cell_is_cut, std::ignore, std::ignore) =
cut_cells_map[cell];
1957 bool cell_is_overconstrained;
1958 std::tie(cell_is_overconstrained, std::ignore, std::ignore) =
1961 bool cell_is_inside;
1963 if (cell->at_boundary() &&
1964 this->check_existance_of_bc(
1967 for (
const auto face : cell->face_indices())
1969 if (cell->face(face)->at_boundary())
1971 unsigned int boundary_id =
1972 cell->face(face)->boundary_id();
1980 .navier_stokes_functions.at(boundary_id)
1982 &this->simulation_parameters.boundary_conditions
1983 .navier_stokes_functions.at(boundary_id)
1985 &this->simulation_parameters.boundary_conditions
1986 .navier_stokes_functions.at(boundary_id)
1989 fe_face_values.reinit(cell, face);
1990 fe_face_values[velocities].get_function_values(
1992 local_face_velocity_values);
1993 for (
unsigned int q = 0; q < n_q_points_face; q++)
1995 double u_x = local_face_velocity_values[q][0];
1996 double u_y = local_face_velocity_values[q][1];
1998 double u_x_a = function_v.
value(
1999 fe_face_values.quadrature_point(q), 0);
2000 double u_y_a = function_v.
value(
2001 fe_face_values.quadrature_point(q), 1);
2003 l2errorU_boundary +=
2004 ((u_x - u_x_a) * (u_x - u_x_a) +
2005 (u_y - u_y_a) * (u_y - u_y_a)) *
2006 fe_face_values.JxW(q);
2007 if constexpr (dim == 3)
2009 double u_z = local_face_velocity_values[q][2];
2010 double u_z_a = function_v.
value(
2011 fe_face_values.quadrature_point(q), 2);
2012 l2errorU_boundary += (u_z - u_z_a) *
2014 fe_face_values.JxW(q);
2022 if (!cell_is_cut && !cell_is_overconstrained)
2026 fe_values.reinit(cell);
2028 local_velocity_values);
2030 local_pressure_values);
2031 fe_values[velocities].get_function_gradients(
2036 cell->get_dof_indices(local_dof_indices);
2039 l_exact_solution->vector_value_list(
2040 fe_values.get_quadrature_points(), q_exactSol);
2041 for (
unsigned int q = 0; q < n_q_points; q++)
2043 double present_velocity_divergence =
2044 trace(present_velocity_gradients[q]);
2045 double mass_source =
2047 .navier_stokes_source->value(
2048 fe_values.get_quadrature_points()[q], dim);
2053 double ux_sim = local_velocity_values[q][0];
2054 double ux_exact = q_exactSol[q][0];
2056 double uy_sim = local_velocity_values[q][1];
2057 double uy_exact = q_exactSol[q][1];
2058 l2errorU += (ux_sim - ux_exact) * (ux_sim - ux_exact) *
2060 l2errorU += (uy_sim - uy_exact) * (uy_sim - uy_exact) *
2063 if constexpr (dim == 3)
2065 double uz_sim = local_velocity_values[q][2];
2066 double uz_exact = q_exactSol[q][2];
2067 l2errorU += (uz_sim - uz_exact) * (uz_sim - uz_exact) *
2070 if (!cell_is_inside)
2072 total_velocity_divergence +=
2073 (present_velocity_divergence - mass_source) *
2076 local_pressure_values[q] - average_pressure;
2078 q_exactSol[q][dim] - average_exact_pressure;
2079 l2errorP += (p_sim - p_exact) * (p_sim - p_exact) *
2090 total_velocity_divergence =
2093 this->
pcout <<
"div u : " << total_velocity_divergence << std::endl;
2097 this->
pcout <<
"error at the weak BC : " << std::sqrt(l2errorU_boundary)
2101 return std::make_pair(std::sqrt(l2errorU), std::sqrt(l2errorP));
2110 const double dt)
const
2113 ->load_particles_from_file ==
false)
2117 particle.
f_omega->set_time(time);
2133 if constexpr (dim == 3)
2147 for (
int d = 0; d < dim; ++d)
2171 using dealii::numbers::PI;
2176 double dr = GridTools::minimal_cell_diameter(*this->
triangulation) /
2177 std::numbers::sqrt2;
2179 const auto rheological_model =
2184 std::map<field, double> field_values;
2193 .is_non_newtonian() and
2194 this->simulation_parameters.particlesParameters
2195 ->enable_lubrication_force and
2197 RequiresConstantViscosity(
2198 "FluidDynamicsSharp<dim>::integrate_particles"));
2206 ->enable_lubrication_force ==
false)
2213 .density_is_constant(),
2214 RequiresConstantDensity(
2215 "FluidDynamicsSharp<dim>::integrate_particles"));
2216 auto density_model =
2218 double fluid_density = density_model->value(field_values);
2219 double kinematic_viscosity =
2220 rheological_model->value(field_values) * fluid_density;
2222 Vector<double> particles_residual_vect;
2223 particles_residual_vect.reinit(
particles.size());
2227 unsigned int current_newton_iteration =
2232 if (current_newton_iteration == 0 ||
2234 ->explicit_contact_impulsion_calculation ==
false and
2235 this->simulation_parameters.particlesParameters
2236 ->explicit_position_integration_calculation ==
false))
2238 ib_dem.integrate_particles_motion(
2239 dt, h_max, h_min, fluid_density, kinematic_viscosity);
2242 unsigned int worst_residual_particle_id = UINT_MAX;
2244 bool clear_combined_shape_cache =
false;
2246 for (
unsigned int p = 0; p <
particles.size(); ++p)
2253 clear_combined_shape_cache =
true;
2262 if constexpr (dim == 3)
2264 ->f_gravity->value(
particles[p].position, 2);
2266 Tensor<1, 3> gravity_buoyancy_force =
2267 g * (
particles[p].mass / volume - fluid_density) * volume;
2273 ib_dem.dem_particles[p].omega_impulsion;
2275 ib_dem.dem_particles[p].contact_impulsion;
2277 ib_dem.dem_particles[p].omega_contact_impulsion;
2281 std::vector<double> time_steps_vector =
2285 const Vector<double> &bdf_coefs =
2289 Tensor<1, 3> residual_velocity =
2290 -(bdf_coefs[0] *
particles[p].velocity);
2292 for (
unsigned int i = 1;
2296 residual_velocity +=
2297 -(bdf_coefs[i] *
particles[p].previous_velocity[i - 1]);
2299 residual_velocity +=
2301 particles[p].fluid_forces + gravity_buoyancy_force) /
2304 double inverse_of_relaxation_coefficient_velocity =
2306 0.5 * volume * fluid_density /
particles[p].mass / dt + DBL_MIN;
2310 if (
particles[p].previous_velocity_residual.norm() != 0)
2312 auto vector_of_velocity_variation =
2314 auto vector_of_residual_variation =
2315 residual_velocity -
particles[p].previous_velocity_residual;
2316 double dot_product_of_the_variation_vectors =
2317 scalar_product(vector_of_velocity_variation,
2318 vector_of_residual_variation);
2319 inverse_of_relaxation_coefficient_velocity =
2320 1 / (dot_product_of_the_variation_vectors /
2321 (vector_of_residual_variation.norm_square()) +
2325 double local_alpha = 1.;
2330 bool save_particle_state_is_used =
false;
2332 Tensor<1, 3> velocity_correction_vector;
2336 if (inverse_of_relaxation_coefficient_velocity ==
2337 inverse_of_relaxation_coefficient_velocity)
2339 velocity_correction_vector =
2340 residual_velocity * 1. /
2341 inverse_of_relaxation_coefficient_velocity;
2344 velocity_correction_vector = residual_velocity;
2351 velocity_correction_vector * alpha * local_alpha;
2353 particles[p].previous_velocity_residual = residual_velocity;
2358 if (
particles[p].contact_impulsion.norm() < 1e-12 and
2360 ->explicit_position_integration_calculation ==
false))
2363 for (
int d = 0; d < dim; ++d)
2365 for (
unsigned int i = 1;
2369 double position_update =
2371 particles[p].previous_positions[i - 1][d] /
2379 double position_update =
2380 particles[p].velocity[d] / bdf_coefs[0];
2404 <<
" is now outside the domain we do not update this particle. Position: "
2407 if constexpr (dim == 3)
2409 this->
pcout << std::endl;
2410 save_particle_state_is_used =
true;
2414 auto inv_inertia = invert(
particles[p].inertia);
2417 Tensor<1, 3> total_torque =
2419 (
particles[p].omega_contact_impulsion / dt +
2423 Tensor<1, 3> angular_velocity_in_particle_frame =
2425 Tensor<1, 3> angular_acceleration_in_particle_frame;
2426 angular_acceleration_in_particle_frame[0] =
2429 angular_velocity_in_particle_frame[2] *
2430 angular_velocity_in_particle_frame[1]) /
2432 angular_acceleration_in_particle_frame[1] =
2435 angular_velocity_in_particle_frame[2] *
2436 angular_velocity_in_particle_frame[0]) /
2438 angular_acceleration_in_particle_frame[2] =
2441 angular_velocity_in_particle_frame[0] *
2442 angular_velocity_in_particle_frame[1]) /
2446 Tensor<1, 3> residual_omega =
2448 for (
unsigned int i = 1;
2453 -(bdf_coefs[i] *
particles[p].previous_omega[i - 1]);
2458 angular_acceleration_in_particle_frame;
2461 double inverse_of_relaxation_coefficient_omega =
2462 -bdf_coefs[0] - 0.5 * 2. / 5 * volume * fluid_density *
2464 inv_inertia.norm() / dt;
2467 if (
particles[p].previous_omega_residual.norm() != 0)
2469 auto vector_of_omega_variation =
2471 auto vector_of_residual_variation =
2472 residual_omega -
particles[p].previous_omega_residual;
2474 double dot_product_of_the_variation_vectors =
2475 scalar_product(vector_of_omega_variation,
2476 vector_of_residual_variation);
2477 inverse_of_relaxation_coefficient_omega =
2478 1 / (dot_product_of_the_variation_vectors /
2479 (vector_of_residual_variation.norm_square()) +
2485 Tensor<1, 3> omega_correction_vector;
2486 if (inverse_of_relaxation_coefficient_omega ==
2487 inverse_of_relaxation_coefficient_omega)
2489 omega_correction_vector =
2490 residual_omega * 1 /
2491 inverse_of_relaxation_coefficient_omega;
2495 omega_correction_vector = residual_omega;
2498 double local_alpha_omega = 1;
2503 omega_correction_vector * alpha * local_alpha_omega;
2505 particles[p].previous_omega_residual = residual_omega;
2510 if (
particles[p].omega_contact_impulsion.norm() < 1e-12 and
2512 ->explicit_position_integration_calculation ==
false))
2519 particles[p].rotation_matrix[0][0] = 1.0;
2520 particles[p].rotation_matrix[1][1] = 1.0;
2521 particles[p].rotation_matrix[2][2] = 1.0;
2522 if constexpr (dim == 2)
2526 particles[p].rotation_matrix = Physics::
2527 Transformations::Rotations::rotation_matrix_3d(
2528 axis,
particles[p].previous_orientation[0][2]);
2530 if constexpr (dim == 3)
2532 for (
unsigned int i = 0; i < 3; ++i)
2537 Physics::Transformations::Rotations::
2541 .previous_orientation[0][2 - i]) *
2546 Physics::Transformations::Rotations::rotation_matrix_3d(
2551 particles[p].shape->rotation_matrix_to_xyz_angles(
2560 ib_dem.dem_particles[p].orientation;
2565 if (save_particle_state_is_used)
2569 double this_particle_residual =
2570 sqrt(std::pow(residual_velocity.norm(), 2) +
2571 std::pow(residual_omega.norm() *
particles[p].radius, 2)) *
2575 particles_residual_vect[p] = this_particle_residual;
2580 worst_residual_particle_id = p;
2595 clear_combined_shape_cache =
true;
2603 if (clear_combined_shape_cache)
2611 <<
" particle id : " << worst_residual_particle_id
2613 this->
pcout <<
"L2 particle residual L2 "
2614 << particles_residual_vect.l2_norm() << std::endl;
2621 for (
unsigned int p = 0; p <
particles.size(); ++p)
2647 int field_position = 0;
2652 const std::string field_name = properties_iterator.first;
2655 const unsigned components_number = properties_iterator.second;
2658 if (components_number == 3)
2662 field_position + components_number - 1,
2664 DataComponentInterpretation::component_is_part_of_vector);
2674 for (
unsigned int p = 0; p <
particles.size(); ++p)
2684 auto particle_properties =
particles[p].get_properties();
2686 for (
unsigned int property_index = 0;
2687 property_index <
particles[p].get_number_properties();
2689 patches[p].data(property_index, 0) =
2690 particle_properties[property_index];
2695const std::vector<DataOutBase::Patch<0, dim>> &
2702std::vector<std::string>
2710 std::tuple<
unsigned int,
2713 DataComponentInterpretation::DataComponentInterpretation>>
2730 for (
unsigned int p = 0; p <
particles.size(); ++p)
2732 for (
unsigned int i =
particles[p].previous_velocity.size() - 1; i > 0;
2740 particles[p].previous_orientation[i - 1];
2750 particles[p].previous_fluid_viscous_forces =
2752 particles[p].previous_fluid_pressure_forces =
2760 particles[p].previous_velocity_residual = 0;
2761 particles[p].previous_omega_residual = 0;
2766 this->
pcout <<
"particle " << p <<
" position "
2768 if constexpr (dim == 2)
2770 this->
pcout <<
"particle " << p <<
" velocity "
2776 this->
pcout <<
"particle " << p <<
" velocity "
2780 table_p[p].add_value(
"particle_ID", p);
2788 if constexpr (dim == 3)
2926 if constexpr (dim == 3)
2970 if constexpr (dim == 3)
2994 if constexpr (dim == 3)
3011 std::cout <<
"+------------------------------------------+"
3013 std::cout <<
"| Force summary particles "
3014 <<
" |" << std::endl;
3015 std::cout <<
"+------------------------------------------+"
3026 std::vector<double> &properties)
const
3030 properties.assign(PropertiesIndex::n_properties, 0.);
3032 properties[PropertiesIndex::type] = 0.;
3033 properties[PropertiesIndex::dp] = 2.0 * particle.
radius;
3034 properties[PropertiesIndex::mass] = particle.
mass;
3036 properties[PropertiesIndex::v_x] = particle.
velocity[0];
3037 properties[PropertiesIndex::v_y] = particle.
velocity[1];
3038 properties[PropertiesIndex::omega_x] = particle.
omega[0];
3039 properties[PropertiesIndex::omega_y] = particle.
omega[1];
3040 properties[PropertiesIndex::omega_z] = particle.
omega[2];
3042 properties[PropertiesIndex::fem_force_two_way_coupling_x] =
3044 properties[PropertiesIndex::fem_force_two_way_coupling_y] =
3046 properties[PropertiesIndex::fem_torque_x] = particle.
fluid_torque[0];
3047 properties[PropertiesIndex::fem_torque_y] = particle.
fluid_torque[1];
3048 properties[PropertiesIndex::fem_torque_z] = particle.
fluid_torque[2];
3050 if constexpr (dim == 2)
3052 properties[PropertiesIndex::v_z] = 0.;
3053 properties[PropertiesIndex::fem_force_two_way_coupling_z] = 0.;
3057 properties[PropertiesIndex::v_z] = particle.
velocity[2];
3058 properties[PropertiesIndex::fem_force_two_way_coupling_z] =
3066 Particles::ParticleHandler<dim, dim> &particle_handler,
3068 &particle_container,
3069 std::unordered_set<unsigned int> &local_particle_ids)
const
3071 particle_handler.clear();
3072 particle_container.clear();
3073 local_particle_ids.clear();
3075 Point<dim> ref_point;
3076 std::vector<double> properties;
3082 typename DoFHandler<dim>::active_cell_iterator cell;
3094 if (!cell->is_locally_owned())
3098 particle_handler.insert_particle(
3099 particle.position, ref_point, particle.particle_id, cell, properties);
3100 local_particle_ids.insert(particle.particle_id);
3103 particle_handler.sort_particles_into_subdomains_and_cells();
3104 particle_handler.exchange_ghost_particles(
true);
3113 &particle_container,
3114 const std::unordered_set<unsigned int> &local_particle_ids,
3116 &local_adjacent_particles,
3118 &ghost_adjacent_particles)
const
3120 local_adjacent_particles.clear();
3121 ghost_adjacent_particles.clear();
3125 const auto &pp_contact_map =
ib_dem.get_particle_particle_contact_map();
3126 for (
const auto &[particle_id, contacts] : pp_contact_map)
3132 if (local_particle_ids.find(particle_id) == local_particle_ids.end())
3135 const auto particle_one_it = particle_container.find(particle_id);
3136 if (particle_one_it == particle_container.end())
3139 for (
const auto &[particle_two_id, contact_info] : contacts)
3141 const auto particle_two_it = particle_container.find(particle_two_id);
3142 if (particle_two_it == particle_container.end())
3146 dem_contact_info.
particle_two = particle_two_it->second;
3148 contact_info.tangential_displacement;
3150 contact_info.rolling_resistance_spring_torque;
3157 if (local_particle_ids.find(particle_two_id) !=
3158 local_particle_ids.end())
3160 auto &adjacency = local_adjacent_particles[particle_id];
3161 adjacency.particle_one = particle_one_it->second;
3162 adjacency.second_particles[particle_two_id] = dem_contact_info;
3166 auto &adjacency = ghost_adjacent_particles[particle_id];
3167 adjacency.particle_one = particle_one_it->second;
3168 adjacency.second_particles[particle_two_id] = dem_contact_info;
3183 const bool write_particle_output = output_iteration;
3184 const bool write_force_chains =
3185 output_iteration && dem_parameters.post_processing.force_chains;
3187 if (!(write_particle_output || write_force_chains))
3190 Particles::ParticleHandler<dim, dim> particle_handler(
3196 std::unordered_set<unsigned int> local_particle_ids;
3200 local_particle_ids);
3203 local_adjacent_particles;
3205 ghost_adjacent_particles;
3207 if (write_force_chains)
3210 local_adjacent_particles,
3211 ghost_adjacent_particles);
3213 if (write_particle_output)
3215 const std::string folder =
3217 const std::string particles_solution_name =
3219 const unsigned int iter =
3222 const unsigned int group_files =
3230 get_properties_name());
3235 particles_solution_name,
3241 if (write_force_chains)
3243 auto particles_force_chains_object =
3247 particles_force_chains_object->write_force_chains(
3251 dem_parameters.simulation_control.output_folder,
3254 local_adjacent_particles,
3255 ghost_adjacent_particles);
3268 using dealii::numbers::PI;
3269 std::vector<typename DoFHandler<dim>::active_cell_iterator> active_neighbors;
3270 std::vector<typename DoFHandler<dim>::active_cell_iterator>
3271 active_neighbors_set;
3272 std::vector<typename DoFHandler<dim>::active_cell_iterator>
3274 const FEValuesExtractors::Scalar
pressure(dim);
3276 std::vector<double> time_steps_vector =
3279 std::map<types::global_dof_index, Point<dim>> support_points =
3284 FEValues<dim> fe_values(*this->
fe,
3286 update_quadrature_points | update_JxW_values);
3287 const unsigned int dofs_per_cell = this->
fe->dofs_per_cell;
3289 const unsigned int degree =
3291 double length_ratio =
3295 std::vector<double> ib_coef = stencil.
coefficients(degree, length_ratio);
3297 unsigned int n_q_points = q_formula.size();
3302 std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
3303 std::vector<types::global_dof_index> local_dof_indices_2(dofs_per_cell);
3304 std::vector<types::global_dof_index> local_dof_indices_3(dofs_per_cell);
3305 std::vector<types::global_dof_index> local_dof_indices_4(dofs_per_cell);
3306 std::set<unsigned int> clear_line;
3309 double dr = GridTools::minimal_cell_diameter(*this->
triangulation) /
3310 std::numbers::sqrt2;
3313 const auto &cell_iterator = this->
dof_handler->active_cell_iterators();
3314 double dt = time_steps_vector[0];
3320 ->assemble_navier_stokes_inside ==
true)
3323 for (
unsigned int p = 0; p <
particles.size(); ++p)
3325 Point<dim> pressure_reference_location =
3332 if (cell->is_locally_owned())
3334 cell->get_dof_indices(local_dof_indices);
3335 double sum_line = 0;
3337 fe_values.reinit(cell);
3338 std::vector<int> set_pressure_cell;
3339 set_pressure_cell.resize(
particles.size());
3342 for (
unsigned int qf = 0; qf < n_q_points; ++qf)
3343 volume += fe_values.JxW(qf);
3345 sum_line = volume / dt;
3347 unsigned int inside_index = local_dof_indices[dim];
3353 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
3355 const int component_i =
3356 this->
fe->system_to_component_index(i).first;
3358 local_dof_indices[i]) ==
false &&
3359 this->locally_owned_dofs.is_element(
3360 local_dof_indices[i]) &&
3363 inside_index = local_dof_indices[i];
3376 this->
system_matrix.add(inside_index, inside_index, sum_line);
3380 .pressure_scaling_factor;
3387 for (
const auto &
cell_cut : cell_iterator)
3399 unsigned int ib_particle_id;
3400 std::vector<unsigned int> count_particles;
3401 std::tie(cell_is_cut, ib_particle_id, count_particles) =
3403 bool cell_is_overconstrained;
3404 std::tie(cell_is_overconstrained, std::ignore, std::ignore) =
3406 if (cell_is_overconstrained)
3407 std::tie(cell_is_overconstrained, ib_particle_id, std::ignore) =
3410 if (cell_is_cut || cell_is_overconstrained)
3412 double sum_line = 0;
3417 for (
unsigned int qf = 0; qf < n_q_points; ++qf)
3418 volume += fe_values.JxW(qf);
3420 sum_line = volume / dt;
3421 cell_cut->get_dof_indices(local_dof_indices);
3425 for (
unsigned int i = 0; i < local_dof_indices.size(); ++i)
3427 unsigned int global_index_overwrite = local_dof_indices[i];
3428 if (
ib_done[global_index_overwrite].first ==
false)
3430 const int component_i =
3431 this->
fe->system_to_component_index(i).first;
3432 bool dof_is_inside =
3434 support_points[local_dof_indices[i]],
cell_cut) <= 0;
3440 bool use_ib_for_pressure =
3441 (dof_is_inside) && (component_i == dim) &&
3443 ->assemble_navier_stokes_inside ==
false) &&
3444 count_particles.size() < 2;
3448 local_dof_indices[i]) ||
3449 this->nonzero_constraints.is_constrained(
3450 local_dof_indices[i])) &&
3451 this->locally_owned_dofs.is_element(
3452 global_index_overwrite))
3455 local_dof_indices[i]))
3459 global_index_overwrite);
3461 auto local_entries =
3463 local_dof_indices[i]);
3464 double interpolation = 0;
3466 for (
unsigned int j = 0; j < local_entries.size();
3469 unsigned int col = local_entries[j].first;
3470 double entries = local_entries[j].second;
3478 local_dof_indices[i],
3480 entries * sum_line);
3496 local_dof_indices[i],
3503 interpolation * sum_line +
3505 local_dof_indices[i]) *
3509 local_dof_indices[i]))
3513 global_index_overwrite);
3516 auto local_entries_non_zero =
3518 .get_constraint_entries(
3519 local_dof_indices[i]);
3521 double interpolation = 0;
3523 for (
unsigned int j = 0;
3524 j < local_entries_non_zero.size();
3527 unsigned int col_non_zero =
3528 local_entries_non_zero[j].first;
3529 double entries_non_zero =
3530 local_entries_non_zero[j].second;
3538 local_dof_indices[i],
3540 entries_non_zero * sum_line);
3556 local_dof_indices[i],
3563 interpolation * sum_line +
3565 local_dof_indices[i]) *
3572 if (((component_i < dim) || use_ib_for_pressure) &&
3574 global_index_overwrite) &&
3575 (this->zero_constraints.is_constrained(
3576 local_dof_indices[i]) ||
3577 this->nonzero_constraints.is_constrained(
3578 local_dof_indices[i])) ==
false)
3605 auto [point, interpolation_points] =
3610 support_points[local_dof_indices[i]],
3613 auto point_to_find_cell =
3616 support_points[local_dof_indices[i]],
3618 typename DoFHandler<dim>::active_cell_iterator
3620 bool particle_close_to_wall =
false;
3621 (void)particle_close_to_wall;
3629 point_to_find_cell);
3634 particle_close_to_wall =
true;
3640 global_index_overwrite) ||
3641 this->nonzero_constraints.is_constrained(
3642 global_index_overwrite))
3648 stencil_cell->get_dof_indices(local_dof_indices_2);
3649 ib_done[global_index_overwrite] =
3650 std::make_pair(
true, stencil_cell);
3652 bool skip_stencil =
false;
3655 bool dof_on_ib =
false;
3667 ->enable_extrapolation)
3668 point_in_cell =
cell_cut->point_inside(
3669 interpolation_points
3674 point_in_cell =
cell_cut->point_inside(
3675 support_points[local_dof_indices[i]]);
3677 bool dof_is_dummy =
false;
3679 unsigned int ib_particle_id_2;
3680 std::tie(cell2_is_cut,
3683 bool cell2_is_overconstrained;
3684 std::tie(cell2_is_overconstrained,
3688 if (cell2_is_cut || point_in_cell)
3690 dof_is_dummy =
true;
3693 if (dof_is_dummy || use_ib_for_pressure ||
3694 cell2_is_overconstrained ||
3695 particle_close_to_wall)
3702 global_index_overwrite,
3704 skip_stencil =
true;
3708 if (abs(
particles[ib_particle_id].get_levelset(
3709 support_points[local_dof_indices[i]],
3721 std::vector<Point<dim>>
3722 unite_cell_interpolation_points(ib_coef.size());
3723 unite_cell_interpolation_points[0] =
3724 this->
mapping->transform_real_to_unit_cell(
3725 stencil_cell, point);
3726 for (
unsigned int j = 1; j < ib_coef.size(); ++j)
3732 .particlesParameters->enable_extrapolation)
3733 unite_cell_interpolation_points[j] =
3734 this->
mapping->transform_real_to_unit_cell(
3735 stencil_cell, interpolation_points[j - 1]);
3737 unite_cell_interpolation_points[j] =
3738 this->
mapping->transform_real_to_unit_cell(
3740 support_points[local_dof_indices[i]]);
3743 std::vector<double> local_interp_sol(ib_coef.size());
3746 if (skip_stencil ==
false)
3748 for (
unsigned int j = 0;
3749 j < local_dof_indices_2.size();
3752 const int component_j =
3753 this->
fe->system_to_component_index(j)
3755 if (component_j == component_i)
3776 double local_matrix_entry = 0;
3777 for (
unsigned int k = 0;
3781 local_matrix_entry +=
3782 this->
fe->shape_value(
3784 unite_cell_interpolation_points
3787 local_interp_sol[k] +=
3788 this->
fe->shape_value(
3790 unite_cell_interpolation_points
3793 local_dof_indices_2[j]);
3799 global_index_overwrite,
3800 local_dof_indices_2[j],
3801 local_matrix_entry * sum_line);
3826 support_points[local_dof_indices[i]],
3833 if (component_i == dim)
3835 for (
unsigned int k = 0;
3836 k < local_dof_indices.size();
3841 bool dof_is_inside_p =
3843 support_points[local_dof_indices[k]],
3845 const int component_k =
3846 this->
fe->system_to_component_index(k)
3848 if (component_k == dim &&
3849 dof_is_inside_p ==
false)
3852 local_dof_indices[k]);
3856 global_index_overwrite,
3857 local_dof_indices[k],
3877 for (
unsigned int k = 0; k < ib_coef.size(); ++k)
3880 -local_interp_sol[k] * ib_coef[k] * sum_line;
3890 const double pressure_scaling_factor =
3892 .pressure_scaling_factor;
3894 component_i == dim ? (v_ib * sum_line + rhs_add) /
3895 pressure_scaling_factor :
3896 v_ib * sum_line + rhs_add;
3901 component_i == dim ?
3903 global_index_overwrite) *
3905 pressure_scaling_factor :
3907 global_index_overwrite) *
3910 if (skip_stencil && dof_on_ib ==
false)
3915 component_i == dim ?
3917 global_index_overwrite) *
3919 pressure_scaling_factor :
3921 global_index_overwrite) *
3925 if (component_i == dim &&
3927 global_index_overwrite))
3933 unsigned int global_index_overwrite =
3934 local_dof_indices[i];
3935 bool dummy_dof =
true;
3940 global_index_overwrite,
3941 global_index_overwrite)) <= 1e-16 * dr)
3947 active_neighbors_set =
3950 for (
unsigned int m = 0;
3951 m < active_neighbors_set.size();
3954 const auto &neighbor_cell =
3955 active_neighbors_set[m];
3956 neighbor_cell->get_dof_indices(
3957 local_dof_indices_3);
3958 for (
const auto o : local_dof_indices_3)
3960 if (global_index_overwrite == o)
3967 std::tie(cell_is_cut,
3971 bool cell_is_overconstrained;
3972 std::tie(cell_is_overconstrained,
3977 if (cell_is_cut ==
false &&
3978 cell_is_overconstrained ==
false)
3985 if (dummy_dof ==
false)
3993 global_index_overwrite,
3994 global_index_overwrite,
4007 this->
system_rhs.compress(VectorOperation::insert);
4019 ExcMessage(
"SDIRK time-stepping methods are not supported by the "
4020 "sharp-interface immersed boundary solver. Use a BDF method "
4062 this->simulation_parameters.physical_properties_manager
4063 .density_is_constant())
4080 .is_non_newtonian())
4088 .density_is_constant())
4124 .is_non_newtonian())
4147 const typename DoFHandler<dim>::active_cell_iterator &cell,
4153 if (!cell->is_locally_owned())
4159 bool cell_is_cut =
false;
4160 std::tie(cell_is_cut, std::ignore, std::ignore) =
cut_cells_map[cell];
4161 bool cell_is_overconstrained;
4162 std::tie(cell_is_overconstrained, std::ignore, std::ignore) =
4165 copy_data.
cell_is_cut = cell_is_cut || cell_is_overconstrained;
4175 this->forcing_function,
4176 this->flow_control.get_beta(),
4177 this->simulation_parameters.stabilization.pressure_scaling_factor);
4181 const DoFHandler<dim> &dof_handler_cls =
4183 typename DoFHandler<dim>::active_cell_iterator phase_cell(
4201 bool cell_is_inside;
4204 ->assemble_navier_stokes_inside ==
false)
4208 assembler->assemble_matrix(scratch_data, copy_data);
4215 assembler->assemble_matrix(scratch_data, copy_data);
4229 const AffineConstraints<double> &constraints_used = this->
zero_constraints;
4230 constraints_used.distribute_local_to_global(copy_data.
local_matrix,
4232 this->system_matrix);
4238 const typename DoFHandler<dim>::active_cell_iterator &cell,
4244 if (!cell->is_locally_owned())
4250 bool cell_is_cut =
false;
4251 std::tie(cell_is_cut, std::ignore, std::ignore) =
cut_cells_map[cell];
4253 bool cell_is_overconstrained;
4254 std::tie(cell_is_overconstrained, std::ignore, std::ignore) =
4257 copy_data.
cell_is_cut = cell_is_cut || cell_is_overconstrained;
4267 this->forcing_function,
4268 this->flow_control.get_beta(),
4269 this->simulation_parameters.stabilization.pressure_scaling_factor);
4273 const DoFHandler<dim> &dof_handler_cls =
4275 typename DoFHandler<dim>::active_cell_iterator phase_cell(
4293 bool cell_is_inside;
4296 ->assemble_navier_stokes_inside ==
false)
4300 assembler->assemble_rhs(scratch_data, copy_data);
4307 assembler->assemble_rhs(scratch_data, copy_data);
4323 const AffineConstraints<double> &constraints_used = this->
zero_constraints;
4324 constraints_used.distribute_local_to_global(copy_data.
local_rhs,
4338 std::string prefix =
4342 TableHandler particles_information_table;
4343 std::string filename = prefix +
".ib_particles";
4344 std::ofstream output(filename.c_str());
4349 for (
unsigned int i_particle = 0; i_particle <
particles.size();
4352 for (
unsigned int j = 0;
4353 j <
particles[i_particle].previous_positions.size();
4356 particles_information_table.add_value(
"ID", i_particle);
4357 particles_information_table.add_value(
4358 "p_x",
particles[i_particle].previous_positions[j][0]);
4359 particles_information_table.set_precision(
"p_x", 16);
4360 particles_information_table.add_value(
4361 "p_y",
particles[i_particle].previous_positions[j][1]);
4362 particles_information_table.set_precision(
"p_y", 16);
4363 if constexpr (dim == 3)
4365 particles_information_table.add_value(
4366 "p_z",
particles[i_particle].previous_positions[j][2]);
4367 particles_information_table.set_precision(
"p_z", 16);
4370 particles_information_table.add_value(
4371 "v_x",
particles[i_particle].previous_velocity[j][0]);
4372 particles_information_table.set_precision(
"v_x", 16);
4373 particles_information_table.add_value(
4374 "v_y",
particles[i_particle].previous_velocity[j][1]);
4375 particles_information_table.set_precision(
"v_y", 16);
4376 if constexpr (dim == 3)
4378 particles_information_table.add_value(
4379 "v_z",
particles[i_particle].previous_velocity[j][2]);
4380 particles_information_table.set_precision(
"v_z", 16);
4383 particles_information_table.add_value(
4384 "f_x",
particles[i_particle].previous_fluid_forces[0]);
4385 particles_information_table.set_precision(
"f_x", 16);
4386 particles_information_table.add_value(
4387 "f_y",
particles[i_particle].previous_fluid_forces[1]);
4388 particles_information_table.set_precision(
"f_y", 16);
4390 if constexpr (dim == 3)
4392 particles_information_table.add_value(
4393 "f_z",
particles[i_particle].previous_fluid_forces[2]);
4394 particles_information_table.set_precision(
"f_z", 16);
4397 particles_information_table.add_value(
4398 "f_xv",
particles[i_particle].previous_fluid_viscous_forces[0]);
4399 particles_information_table.set_precision(
"f_xv", 16);
4400 particles_information_table.add_value(
4401 "f_yv",
particles[i_particle].previous_fluid_viscous_forces[1]);
4402 particles_information_table.set_precision(
"f_yv", 16);
4404 if constexpr (dim == 3)
4406 particles_information_table.add_value(
4408 particles[i_particle].previous_fluid_viscous_forces[2]);
4409 particles_information_table.set_precision(
"f_zv", 16);
4412 particles_information_table.add_value(
4414 particles[i_particle].previous_fluid_pressure_forces[0]);
4415 particles_information_table.set_precision(
"f_xp", 16);
4416 particles_information_table.add_value(
4418 particles[i_particle].previous_fluid_pressure_forces[1]);
4419 particles_information_table.set_precision(
"f_yp", 16);
4421 if constexpr (dim == 3)
4423 particles_information_table.add_value(
4425 particles[i_particle].previous_fluid_pressure_forces[2]);
4426 particles_information_table.set_precision(
"f_zp", 16);
4429 if constexpr (dim == 3)
4431 particles_information_table.add_value(
4432 "omega_x",
particles[i_particle].previous_omega[j][0]);
4433 particles_information_table.set_precision(
"omega_x", 16);
4434 particles_information_table.add_value(
4435 "omega_y",
particles[i_particle].previous_omega[j][1]);
4436 particles_information_table.set_precision(
"omega_y", 16);
4437 particles_information_table.add_value(
4439 particles[i_particle].previous_orientation[j][0]);
4440 particles_information_table.set_precision(
"theta_x", 16);
4441 particles_information_table.add_value(
4443 particles[i_particle].previous_orientation[j][1]);
4444 particles_information_table.set_precision(
"theta_y", 16);
4446 particles_information_table.add_value(
4447 "omega_z",
particles[i_particle].previous_omega[j][2]);
4448 particles_information_table.set_precision(
"omega_z", 16);
4449 particles_information_table.add_value(
4450 "theta_z",
particles[i_particle].previous_orientation[j][2]);
4451 particles_information_table.set_precision(
"theta_z", 16);
4452 if constexpr (dim == 3)
4454 particles_information_table.add_value(
4455 "T_x",
particles[i_particle].previous_fluid_torque[0]);
4456 particles_information_table.set_precision(
"T_x", 16);
4457 particles_information_table.add_value(
4458 "T_y",
particles[i_particle].previous_fluid_torque[1]);
4459 particles_information_table.set_precision(
"T_y", 16);
4461 particles_information_table.add_value(
4462 "T_z",
particles[i_particle].previous_fluid_torque[2]);
4463 particles_information_table.set_precision(
"T_z", 16);
4467 particles_information_table.write_text(output);
4478 "Reset Sharp-Edge particle information");
4480 std::string prefix =
4484 std::string filename = prefix +
".ib_particles";
4488 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4490 std::string filename_table =
4493 "." + Utilities::int_to_string(p_i, 2) +
".dat";
4499 std::map<std::string, std::vector<double>> restart_data;
4503 if constexpr (dim == 2)
4505 unsigned int row = 0;
4506 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4509 while (row < restart_data[
"ID"].size() &&
4510 restart_data[
"ID"][row] == p_i)
4514 particles[p_i].position[0] = restart_data[
"p_x"][row];
4515 particles[p_i].position[1] = restart_data[
"p_y"][row];
4516 particles[p_i].velocity[0] = restart_data[
"v_x"][row];
4517 particles[p_i].velocity[1] = restart_data[
"v_y"][row];
4518 particles[p_i].fluid_forces[0] = restart_data[
"f_x"][row];
4519 particles[p_i].fluid_forces[1] = restart_data[
"f_y"][row];
4520 particles[p_i].fluid_viscous_forces[0] =
4521 restart_data[
"f_xv"][row];
4522 particles[p_i].fluid_viscous_forces[1] =
4523 restart_data[
"f_yv"][row];
4524 particles[p_i].fluid_pressure_forces[0] =
4525 restart_data[
"f_xp"][row];
4526 particles[p_i].fluid_pressure_forces[1] =
4527 restart_data[
"f_yp"][row];
4528 particles[p_i].omega[2] = restart_data[
"omega_z"][row];
4529 particles[p_i].orientation[2] = restart_data[
"theta_z"][row];
4530 particles[p_i].fluid_torque[2] = restart_data[
"T_z"][row];
4533 particles[p_i].previous_positions[j][0] =
4534 restart_data[
"p_x"][row];
4535 particles[p_i].previous_positions[j][1] =
4536 restart_data[
"p_y"][row];
4537 particles[p_i].previous_velocity[j][0] =
4538 restart_data[
"v_x"][row];
4539 particles[p_i].previous_velocity[j][1] =
4540 restart_data[
"v_y"][row];
4542 restart_data[
"omega_z"][row];
4543 particles[p_i].previous_orientation[j][2] =
4544 restart_data[
"theta_z"][row];
4552 particles[p_i].previous_positions[j][0] =
4553 restart_data[
"p_x"][row];
4554 particles[p_i].previous_positions[j][1] =
4555 restart_data[
"p_y"][row];
4556 particles[p_i].previous_velocity[j][0] =
4557 restart_data[
"v_x"][row];
4558 particles[p_i].previous_velocity[j][1] =
4559 restart_data[
"v_y"][row];
4561 restart_data[
"omega_z"][row];
4562 particles[p_i].previous_orientation[j][2] =
4563 restart_data[
"theta_z"][row];
4570 if constexpr (dim == 3)
4572 unsigned int row = 0;
4573 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4576 while (row < restart_data[
"ID"].size() &&
4577 restart_data[
"ID"][row] == p_i)
4581 particles[p_i].position[0] = restart_data[
"p_x"][row];
4582 particles[p_i].position[1] = restart_data[
"p_y"][row];
4583 particles[p_i].position[2] = restart_data[
"p_z"][row];
4584 particles[p_i].velocity[0] = restart_data[
"v_x"][row];
4585 particles[p_i].velocity[1] = restart_data[
"v_y"][row];
4586 particles[p_i].velocity[2] = restart_data[
"v_z"][row];
4587 particles[p_i].fluid_forces[0] = restart_data[
"f_x"][row];
4588 particles[p_i].fluid_forces[1] = restart_data[
"f_y"][row];
4589 particles[p_i].fluid_forces[2] = restart_data[
"f_z"][row];
4590 particles[p_i].fluid_viscous_forces[0] =
4591 restart_data[
"f_xv"][row];
4592 particles[p_i].fluid_viscous_forces[1] =
4593 restart_data[
"f_yv"][row];
4594 particles[p_i].fluid_viscous_forces[2] =
4595 restart_data[
"f_zv"][row];
4596 particles[p_i].fluid_pressure_forces[0] =
4597 restart_data[
"f_xp"][row];
4598 particles[p_i].fluid_pressure_forces[1] =
4599 restart_data[
"f_yp"][row];
4600 particles[p_i].fluid_pressure_forces[2] =
4601 restart_data[
"f_zp"][row];
4602 particles[p_i].orientation[0] = restart_data[
"theta_x"][row];
4603 particles[p_i].orientation[1] = restart_data[
"theta_y"][row];
4604 particles[p_i].orientation[2] = restart_data[
"theta_z"][row];
4605 particles[p_i].omega[0] = restart_data[
"omega_x"][row];
4606 particles[p_i].omega[1] = restart_data[
"omega_y"][row];
4607 particles[p_i].omega[2] = restart_data[
"omega_z"][row];
4608 particles[p_i].fluid_torque[0] = restart_data[
"T_x"][row];
4609 particles[p_i].fluid_torque[1] = restart_data[
"T_y"][row];
4610 particles[p_i].fluid_torque[2] = restart_data[
"T_z"][row];
4613 particles[p_i].previous_positions[j][0] =
4614 restart_data[
"p_x"][row];
4615 particles[p_i].previous_positions[j][1] =
4616 restart_data[
"p_y"][row];
4617 particles[p_i].previous_positions[j][2] =
4618 restart_data[
"p_z"][row];
4619 particles[p_i].previous_velocity[j][0] =
4620 restart_data[
"v_x"][row];
4621 particles[p_i].previous_velocity[j][1] =
4622 restart_data[
"v_y"][row];
4623 particles[p_i].previous_velocity[j][2] =
4624 restart_data[
"v_z"][row];
4626 restart_data[
"omega_x"][row];
4628 restart_data[
"omega_y"][row];
4630 restart_data[
"omega_z"][row];
4631 particles[p_i].previous_orientation[j][0] =
4632 restart_data[
"theta_x"][row];
4633 particles[p_i].previous_orientation[j][1] =
4634 restart_data[
"theta_y"][row];
4635 particles[p_i].previous_orientation[j][2] =
4636 restart_data[
"theta_z"][row];
4644 particles[p_i].previous_positions[j][0] =
4645 restart_data[
"p_x"][row];
4646 particles[p_i].previous_positions[j][1] =
4647 restart_data[
"p_y"][row];
4648 particles[p_i].previous_positions[j][2] =
4649 restart_data[
"p_z"][row];
4650 particles[p_i].previous_velocity[j][0] =
4651 restart_data[
"v_x"][row];
4652 particles[p_i].previous_velocity[j][1] =
4653 restart_data[
"v_y"][row];
4654 particles[p_i].previous_velocity[j][2] =
4655 restart_data[
"v_z"][row];
4657 restart_data[
"omega_x"][row];
4659 restart_data[
"omega_y"][row];
4661 restart_data[
"omega_z"][row];
4662 particles[p_i].previous_orientation[j][0] =
4663 restart_data[
"theta_x"][row];
4664 particles[p_i].previous_orientation[j][1] =
4665 restart_data[
"theta_y"][row];
4666 particles[p_i].previous_orientation[j][2] =
4667 restart_data[
"theta_z"][row];
4682 std::make_shared<Parameters::Lagrangian::BCDEM>(
4684 this->mpi_communicator,
4686 ib_dem.update_contact_candidates();
4688 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4698 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4710 using dealii::numbers::PI;
4712 "Reset Sharp-Edge particle information");
4713 this->
pcout <<
"Loading particles from a file" << std::endl;
4714 std::string filename =
4719 std::map<std::string, std::vector<std::string>> particles_data;
4721 particles.resize(particles_data[
"type"].size());
4723 this->
pcout <<
"Particles found: " <<
particles.size() << std::endl;
4727 const auto parse_inertia = [](
const std::string &inertia_str) {
4728 const std::vector<double> inertia_list = Utilities::string_to_double(
4729 Utilities::split_string_list(inertia_str,
":"));
4730 Tensor<2, 3> inertia;
4731 if (inertia_list.size() == 9)
4733 for (
unsigned int i = 0; i < 3; ++i)
4734 for (
unsigned int j = 0; j < 3; ++j)
4735 inertia[i][j] = inertia_list[3 * i + j];
4737 else if (inertia_list.size() == 1)
4739 for (
unsigned int i = 0; i < 3; ++i)
4740 inertia[i][i] = inertia_list[0];
4744 throw(std::runtime_error(
4745 " Invalid inertia matrix. The inertia is given as a 3 by 3 matrix or a single value if the inertia is uniform around each axis."));
4751 if constexpr (dim == 2)
4754 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4761 Utilities::string_to_double(particles_data[
"p_x"][p_i]);
4763 Utilities::string_to_double(particles_data[
"p_y"][p_i]);
4765 Utilities::string_to_double(particles_data[
"v_x"][p_i]);
4767 Utilities::string_to_double(particles_data[
"v_y"][p_i]);
4769 Utilities::string_to_double(particles_data[
"orientation_z"][p_i]);
4773 std::string shape_type = particles_data[
"type"][p_i];
4774 std::string shape_arguments_str =
4775 particles_data[
"shape_argument"][p_i];
4778 std::string toReplace =
":";
4779 std::string replacement =
";";
4782 size_t pos = shape_arguments_str.find(toReplace);
4783 while (pos != std::string::npos)
4786 shape_arguments_str.replace(pos, toReplace.length(), replacement);
4790 shape_arguments_str.find(toReplace, pos + replacement.length());
4792 particles[p_i].initialize_shape(shape_type, shape_arguments_str);
4798 Utilities::string_to_double(particles_data[
"volume"][p_i]);
4802 volume =
particles[p_i].shape->displaced_volume();
4805 if constexpr (dim == 2)
4810 else if constexpr (dim == 3)
4812 volume = 4.0 / 3.0 * PI *
particles[p_i].radius *
4820 Utilities::string_to_double(particles_data[
"density"][p_i]);
4823 Utilities::string_to_double(particles_data[
"omega_z"][p_i]);
4826 parse_inertia(particles_data[
"inertia"][p_i]);
4829 Utilities::string_to_double(particles_data[
"pressure_x"][p_i]);
4831 Utilities::string_to_double(particles_data[
"pressure_y"][p_i]);
4834 Utilities::string_to_double(particles_data[
"youngs_modulus"][p_i]);
4835 particles[p_i].restitution_coefficient = Utilities::string_to_double(
4836 particles_data[
"restitution_coefficient"][p_i]);
4837 particles[p_i].friction_coefficient = Utilities::string_to_double(
4838 particles_data[
"friction_coefficient"][p_i]);
4840 Utilities::string_to_double(particles_data[
"poisson_ratio"][p_i]);
4841 particles[p_i].rolling_friction_coefficient =
4842 Utilities::string_to_double(
4843 particles_data[
"rolling_friction_coefficient"][p_i]);
4844 particles[p_i].initialize_previous_solution();
4845 if (particles_data[
"integrate_motion"][p_i] ==
"false")
4847 particles[p_i].integrate_motion =
false;
4857 if constexpr (dim == 3)
4860 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4866 Utilities::string_to_double(particles_data[
"p_x"][p_i]);
4868 Utilities::string_to_double(particles_data[
"p_y"][p_i]);
4870 Utilities::string_to_double(particles_data[
"p_z"][p_i]);
4872 Utilities::string_to_double(particles_data[
"v_x"][p_i]);
4874 Utilities::string_to_double(particles_data[
"v_y"][p_i]);
4876 Utilities::string_to_double(particles_data[
"v_z"][p_i]);
4878 Utilities::string_to_double(particles_data[
"orientation_x"][p_i]);
4880 Utilities::string_to_double(particles_data[
"orientation_y"][p_i]);
4882 Utilities::string_to_double(particles_data[
"orientation_z"][p_i]);
4884 std::string shape_type = particles_data[
"type"][p_i];
4885 std::string shape_arguments_str =
4886 particles_data[
"shape_argument"][p_i];
4889 std::string toReplace =
":";
4890 std::string replacement =
";";
4893 size_t pos = shape_arguments_str.find(toReplace);
4894 while (pos != std::string::npos)
4897 shape_arguments_str.replace(pos, toReplace.length(), replacement);
4901 shape_arguments_str.find(toReplace, pos + replacement.length());
4903 particles[p_i].initialize_shape(shape_type, shape_arguments_str);
4907 Utilities::string_to_double(particles_data[
"volume"][p_i]);
4911 volume =
particles[p_i].shape->displaced_volume();
4914 if constexpr (dim == 2)
4919 else if constexpr (dim == 3)
4921 volume = 4.0 / 3.0 * PI *
particles[p_i].radius *
4929 Utilities::string_to_double(particles_data[
"density"][p_i]);
4932 Utilities::string_to_double(particles_data[
"omega_x"][p_i]);
4934 Utilities::string_to_double(particles_data[
"omega_y"][p_i]);
4936 Utilities::string_to_double(particles_data[
"omega_z"][p_i]);
4939 parse_inertia(particles_data[
"inertia"][p_i]);
4942 Utilities::string_to_double(particles_data[
"pressure_x"][p_i]);
4944 Utilities::string_to_double(particles_data[
"pressure_y"][p_i]);
4946 Utilities::string_to_double(particles_data[
"pressure_z"][p_i]);
4949 Utilities::string_to_double(particles_data[
"youngs_modulus"][p_i]);
4950 particles[p_i].restitution_coefficient = Utilities::string_to_double(
4951 particles_data[
"restitution_coefficient"][p_i]);
4952 particles[p_i].friction_coefficient = Utilities::string_to_double(
4953 particles_data[
"friction_coefficient"][p_i]);
4955 Utilities::string_to_double(particles_data[
"poisson_ratio"][p_i]);
4956 particles[p_i].rolling_friction_coefficient =
4957 Utilities::string_to_double(
4958 particles_data[
"rolling_friction_coefficient"][p_i]);
4959 particles[p_i].initialize_previous_solution();
4960 if (particles_data[
"integrate_motion"][p_i] ==
"false")
4962 particles[p_i].integrate_motion =
false;
4979 "Update precalculated shape distance");
4980 for (
unsigned int p_i = 0; p_i <
particles.size(); ++p_i)
4993 .lagrangian_post_processing_enabled,
4995 "DEM lagrangian post-processing is not supported for lethe-fluid-sharp. "
4996 "Disable it in the DEM post-processing subsection."));
4999 .particle_wall_collision_statistics,
5001 "DEM particle-wall collision statistics are not supported for "
5002 "lethe-fluid-sharp. Disable them in the DEM post-processing "
5008 this->simulation_parameters.manifolds_parameters,
5009 this->simulation_parameters.restart_parameters.restart,
5010 this->simulation_parameters.boundary_conditions.periodic_boundaries);
5028 this->simulation_parameters.restart_parameters.restart);
5031 this->simulation_control->is_output_iteration())
5064 ib_dem.update_contact_candidates();
5078 this->simulation_control->get_iteration_number() %
5079 this->simulation_parameters.particlesParameters
5080 ->contact_search_frequency ==
5082 ib_dem.update_contact_candidates();
unsigned int number_of_previous_solutions(const Parameters::SimulationControl::TimeSteppingMethod method)
Get the number of previous time steps for a specific BDF scheme.
Controls the name of output variables for the vtu.
TrilinosWrappers::SparseMatrix system_matrix
virtual void update_multiphysics_time_average_solution() override
Updates the average velocity field solution in the multiphyscics interface.
FluidDynamicsMatrixBased(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
Construct the matrix-based Navier-Stokes solver.
GlobalVectorType dof_overconstrained
void generate_cut_cells_map()
This function creates a map (cut_cells_map) that indicates if a cell is cut, and the particle id of t...
virtual void read_checkpoint() override
Restart a previous simulation from a checkpoint file.
std::pair< bool, bool > generate_cut_cell_candidates(const typename DoFHandler< dim >::cell_iterator &cell, const unsigned int p_id)
This function abstracts the generation of cell candidates that possibly are cut.
void copy_local_matrix_to_global_matrix(const StabilizedMethodsTensorCopyData< dim > ©_data) override
Copy local cell information to global matrix This function is modified compared to the GLS function t...
FluidDynamicsSharp(CFDDEMSimulationParameters< dim > &nsparam)
virtual void write_checkpoint() override
Write a gls_sharp simulation checkpointing to allow for gls_sharp simulation restart This function st...
void apply_prescribed_particle_motion(IBParticle< dim > &particle, const double time, const double dt) const
Apply the prescribed motion of a particle whose dynamics is not integrated, at the end of the current...
std::map< unsigned int, bool > dof_with_more_then_one_particle
std::map< unsigned int, std::set< typename DoFHandler< dim >::active_cell_iterator > > vertices_to_cell
void build_ib_particle_handler(Particles::ParticleHandler< dim, dim > &particle_handler, typename DEM::dem_data_structures< dim >::particle_index_iterator_map &particle_container, std::unordered_set< unsigned int > &local_particle_ids) const
Build a temporary DEM particle handler from the current Sharp-IB particles.
void optimized_generate_cut_cells_map()
This function is only applied if all particles are spheres. It creates two maps (cut_cells_map and ce...
CFDDEMSimulationParameters< dim > cfd_dem_parameters
void force_on_ib()
Evaluate the forces applied on each of the IB particle.
std::shared_ptr< Shape< dim > > combined_shapes
void mesh_adapt_ib(const bool initial_refinement)
Adapt the mesh around each immersed-boundary particle. The refinement zone is defined by a ring in 2D...
bool cell_cut_by_p_absolute_distance(const typename DoFHandler< dim >::active_cell_iterator &cell, std::map< types::global_dof_index, Point< dim > > &support_points, unsigned int p)
Return a bool to define if a cell is cut by an IB. This function is built to handle special cases whe...
virtual std::vector< OutputStruct< dim, GlobalVectorType > > gather_output_hook() override
Adds levelset to output files.
std::map< typename DoFHandler< dim >::active_cell_iterator, std::tuple< bool, unsigned int, double > > overconstrained_fluid_cell_map
PVDHandler ib_particles_pvdhandler_force_chains
void integrate_particles()
Integrate the particle velocity and position based on the forces and torques and applies the next val...
void assemble_local_system_matrix(const typename DoFHandler< dim >::active_cell_iterator &cell, NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > ©_data) override
Assemble the local matrix for a given cell.
std::map< typename DoFHandler< dim >::active_cell_iterator, std::tuple< bool, unsigned int > > cells_inside_map
void fill_particle_properties(const IBParticle< dim > &particle, std::vector< double > &properties) const
Fill DEM particle properties from a Sharp-IB particle state.
void copy_local_rhs_to_global_rhs(const StabilizedMethodsTensorCopyData< dim > ©_data) override
Copy local cell rhs information to global rhs This function is modified compared to the GLS function ...
std::shared_ptr< LevelsetGradientPostprocessor< dim > > levelset_gradient_postprocessor
std::map< typename DoFHandler< dim >::active_cell_iterator, std::tuple< bool, unsigned int, std::vector< unsigned int > > > cut_cells_map
std::vector< TableHandler > table_p
std::shared_ptr< LevelsetPostprocessor< dim > > levelset_postprocessor
bool some_particles_are_coupled
void refinement_control(const bool initial_refinement)
Regroup and organize the refinement process around the IB particle.
void finish_time_step_particles()
Store the solution of the particles dynamics parameters for integration. Defines the table to store t...
void update_precalculations_for_ib()
This function updates the precalculations for every immersed particle.
void write_force_ib()
Write in a specifique file for each of the paticles its forces, velocity, position at each time step.
void sharp_edge()
Modify the system matrix to impose IB condition using the sharp_edge approach. The detail of this app...
void vertices_cell_mapping()
Map the vertex index to the cell that includes that vertex. This map is used to find all the cell clo...
GlobalVectorType local_dof_overconstrained
void build_contact_containers(const typename DEM::dem_data_structures< dim >::particle_index_iterator_map &particle_container, const std::unordered_set< unsigned int > &local_particle_ids, typename DEM::dem_data_structures< dim >::adjacent_particle_pairs &local_adjacent_particles, typename DEM::dem_data_structures< dim >::adjacent_particle_pairs &ghost_adjacent_particles) const
Build the DEM-style particle-particle contact containers of the Sharp-IB particles,...
std::map< unsigned int, std::pair< bool, typename DoFHandler< dim >::active_cell_iterator > > ib_done
void setup_assemblers() override
sets up the vector of assembler functions This function is modified compared to the GLS function to t...
std::tuple< bool, unsigned int, std::vector< types::global_dof_index > > cell_cut(const typename DoFHandler< dim >::active_cell_iterator &cell, std::vector< types::global_dof_index > &local_dof_indices, std::map< types::global_dof_index, Point< dim > > &support_points)
Return a bool to define if a cell is cut by an IB particle and the local DOFs of the cell for later u...
PVDHandler ib_particles_pvdhandler
void check_whether_all_particles_are_sphere()
This function checks if all particles are spheres. If one of them is not, the code will use the regul...
std::pair< double, double > calculate_L2_error_particles()
Evaluate the L2 error on the computational domain if an analytical solution is given....
IBParticlesDEM< dim > ib_dem
void solve() override
solve Solves the Navier-Stokes problem
std::vector< IBParticle< dim > > particles
void load_particles_from_file()
virtual void postprocess_fd(bool firstIter) override
Same function as its standard GLS counterpart but it used the error evaluation that takes into accoun...
void define_particles()
Defines the particle structure and value based on the parameter file. This structure gives access to ...
std::vector< std::shared_ptr< NavierStokesAssemblerBase< dim > > > assemblers_inside_ib
void assemble_local_system_rhs(const typename DoFHandler< dim >::active_cell_iterator &cell, NavierStokesScratchData< dim > &scratch_data, StabilizedMethodsTensorCopyData< dim > ©_data) override
Assemble the local rhs for a given cell.
void handle_dem_particle_output_and_postprocessing()
Mirror DEM-style particle output and post-processing for Sharp-IB particles.
bool point_inside_cell(const typename DoFHandler< dim >::active_cell_iterator &cell, Point< dim > point)
Return a bool that describes if a cell contains a specific point.
This class implements a boundary conditions for the fluid dynamics solver where the velocity componen...
double value(const Point< dim > &point, const unsigned int component) const override
Calculates the value of a Function-type fluid dynamics equations.
Class that assembles the core of the Navier-Stokes equation with free surface using CLS modeling....
Class that assembles the transient time arising from BDF time integration for the Navier Stokes equat...
Class that assembles the core of the Navier-Stokes equation using a Rheological model to predict non-...
Class that assembles the coriolis and the centrifugal if a simulation is carried out in a rotating fr...
Assembles the transient time arising from BDF time integration for the Navier-Stokes equation with fr...
Assembles the core of the Navier-Stokes equation with free surface using CLS modeling....
Assembles the core of the Navier-Stokes equation using a Rheological model to predict non-Newtonian b...
Define the behavior of a specific particle for the sharp interface IB solver.
std::vector< Tensor< 1, 3 > > previous_orientation
Previous time step's orientation.
Tensor< 1, 3 > orientation
Orientation, with 0 angular position by default on every axis.
double radius
Effective radius, which is the actual radius for spheres.
Tensor< 1, 3 > omega
Angular velocity.
std::shared_ptr< Functions::ParsedFunction< dim > > f_omega
Function that determines the angular velocity.
Tensor< 1, 3 > fluid_forces
Total fluid force applied on the particle.
std::vector< Point< dim > > previous_positions
Positions at the last n time steps. n depends on the time integration scheme.
double mass
Particle's mass.
Tensor< 1, 3 > velocity
Translational velocity.
std::shared_ptr< Functions::ParsedFunction< dim > > f_velocity
Function that determines the velocity.
Tensor< 1, 3 > fluid_torque
Fluid torque applied on the particle.
std::shared_ptr< Functions::ParsedFunction< dim > > f_position
Function that determines the position.
std::shared_ptr< Functions::ParsedFunction< dim > > f_orientation
Function that determines the orientation.
Point< dim > position
Position, which corresponds to the centroid for most implemented shapes.
Define where the sharp immersed-boundaries are imposed on Eulerian grid.
virtual std::tuple< Point< dim >, std::vector< Point< dim > > > support_points_for_interpolation(const unsigned int degree, const double length_ratio, IBParticle< dim > &p, const Point< dim > &dof_point, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Find the DOF at which we try to apply the IB by interpolation and the location of the support points ...
virtual double ib_velocity(IBParticle< dim > &p, const Point< dim > &dof_point, const unsigned int component, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Return the velocity of the IB used in the RHS of the equation.
virtual std::vector< double > coefficients(const unsigned int degree, const double length_ratio)
Return the coefficients (weights) of the stencil.
virtual Point< dim > point_for_cell_detection(IBParticle< dim > &p, const Point< dim > &dof_point, const typename DoFHandler< dim >::active_cell_iterator &cell_guess)
Define the point used to define the cell used for the stencil calculation.
virtual unsigned int number_of_interpolation_support_points(const unsigned int degree)
Return the number of points used by the interpolation stencil (excluding the dof itself) for a stenci...
Class that assembles a Poisson problem for all velocity components and pressure variables....
void box_refine_mesh(const bool restart)
ConvergenceTable error_table
std::shared_ptr< FESystem< dim > > fe
Function< dim > * exact_solution
AffineConstraints< double > nonzero_constraints
virtual void set_initial_condition(const Parameters::FluidDynamicsInitialConditionType initial_condition_type, const bool restart=false)
MPI_Comm mpi_communicator
IndexSet locally_owned_dofs
SDIRKVectors sdirk_vectors
unsigned int number_quadrature_points
std::shared_ptr< GlobalVectorType > present_solution
std::shared_ptr< Quadrature< dim - 1 > > face_quadrature
GlobalVectorType system_rhs
virtual void refine_mesh()
Allow the refinement of the mesh according to one of the 2 methods proposed.
virtual void read_checkpoint()
virtual void finish_time_step()
virtual void dynamic_flow_control()
const unsigned int this_mpi_process
SimulationParameters< dim > simulation_parameters
bool check_existance_of_bc(BoundaryConditions::FluidDynamicsBoundaryType bc)
virtual void postprocess_fd(bool first_iteration)
Post-process fluid dynamics after an iteration.
TimerOutput computing_timer
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
GlobalVectorType evaluation_point
std::shared_ptr< Function< dim > > forcing_function
std::shared_ptr< SimulationControl > simulation_control
void update_boundary_conditions()
std::vector< std::shared_ptr< NavierStokesAssemblerBase< dim > > > assemblers
std::shared_ptr< MultiphysicsInterface< dim > > multiphysics
AffineConstraints< double > zero_constraints
virtual void setup_dofs()
std::shared_ptr< Mapping< dim > > mapping
IndexSet locally_relevant_dofs
virtual void write_checkpoint()
std::shared_ptr< DoFHandler< dim > > dof_handler
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
virtual void postprocess(bool first_iteration)
Class that stores the information required by the assembly procedure for a Navier-Stokes equation....
void calculate_physical_properties()
Calculates the physical properties. This function calculates the physical properties that may be requ...
void reinit(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const std::vector< VectorType > &previous_solutions, const VectorType &sum_over_previous_stages, const std::shared_ptr< Function< dim > > &forcing_function, const Tensor< 1, dim > &beta_force, const double pressure_scaling_factor)
Reinitializes the content of the scratch.
void reinit_cls(const typename DoFHandler< dim >::active_cell_iterator &cell, const VectorType ¤t_solution, const VectorType ¤t_filtered_solution, const std::vector< VectorType > &previous_solutions)
Reinitialize the content of the scratch for the cls.
Class that assembles the weak formulation of an outlet boundary condition according to the following ...
Class that assembles the core of the Navier-Stokes equation. According to the following weak form: ...
Parameters for floating walls in DEM simulations.
Class that assembles the special case of partial slip condition using the weak formulation of a Diric...
unsigned int get_current_newton_iteration() const
Class that assembles a Neumann boundary condition. According to the following weak form: (p-mu*grad_u...
Class responsible for storing the information calculated using the assembly of stabilized Tensor<1,...
FullMatrix< double > local_matrix
Vector< double > local_rhs
void reset()
Resets the cell_matrix, cell_rhs, strong_residual and strong_jacobian to zero.
std::vector< types::global_dof_index > local_dof_indices
Building patches of particle properties for visualization. This function is taken from Aspect and dea...
void build_patches(Particles::ParticleHandler< dim > &particle_handler, const std::vector< std::pair< std::string, int > > &properties)
Build the patches of properties of particles for visualization.
Class that assembles the weak formulation of a Dirichlet boundary condition using the Nitsche method....
void fill_string_vectors_from_file(std::map< std::string, std::vector< std::string > > &map, const std::string &file_name, const std::string &delimiter=" ")
Function that read a file that was build from a dealii table and create a map with the key being the ...
void fill_vectors_from_file(std::map< std::string, std::vector< double > > &map, const std::string &file_name, const std::string &delimiter=" ")
function that read a file that was build from a dealii table and fill 2 vectors. The first vector con...
void fill_table_from_file(TableHandler &table, const std::string &file_name, const std::string &delimiter=" ")
Reads a file generated by a deal.II TableHandler and fills a TableHandler with its data.
void read_mesh_and_manifolds(parallel::DistributedTriangulationBase< dim, spacedim > &triangulation, const Parameters::Mesh< dim, spacedim > &mesh_parameters, const Parameters::Manifolds &manifolds_parameters, bool restart, const Parameters::PeriodicBoundaries &periodic_boundaries)
Completely sets up a mesh and its manifolds.
@ pressure
Pressure scalar field from fluid dynamics.
@ fluid_dynamics
Fluid Dynamics (Velocity,Pressure).
FluidDynamicsBoundaryType
PropertiesIndex
Particle property indices for CFD-DEM simulations.
@ n_properties
Number of properties.
double calculate_shear_rate_magnitude(const Tensor< 2, dim > shear_rate)
Calculates the magnitude of the shear rate tensor given as input.
std::shared_ptr< ParticlesForceChainsBase< dim, PropertiesIndex > > set_force_chains_contact_force_model(const DEMSolverParameters< dim > &dem_parameters)
Return the particle-particle contact force model based on the spring-dashpot model and the rolling re...
void write_vtu_and_pvd(PVDHandler &pvd_handler, const DataOutInterface< dim, spacedim > &data_out, const std::string &folder, const std::string &file_prefix, const double time, const unsigned int iter, const unsigned int group_files, const MPI_Comm &mpi_communicator, const unsigned int digits=5)
Output the data out to "group_files" vtu files, with a pvtu file and a pvd to store the timing This f...
ankerl::unordered_dense::map< types::particle_index, Particles::ParticleIterator< dim > > particle_index_iterator_map
ankerl::unordered_dense::map< types::particle_index, adjacent_particle_pairs_value > adjacent_particle_pairs
virtual const std::vector< DataOutBase::Patch< 0, dim > > & get_patches() const override
virtual std::vector< std::string > get_dataset_names() const override
std::vector< DataOutBase::Patch< 0, dim > > patches
void build_patches(std::vector< IBParticle< dim > > particles)
std::vector< std::pair< std::string, int > > properties_to_write
std::vector< std::string > dataset_names
std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > vector_datasets
virtual std::vector< std::tuple< unsigned int, unsigned int, std::string, DataComponentInterpretation::DataComponentInterpretation > > get_nonscalar_data_ranges() const override
Struct containing information about the solution output. It is used to pass the information required ...
Handle the information related to the calculation of the particle-particle contact force....
Particles::ParticleIterator< dim > particle_two
Tensor< 1, 3 > tangential_displacement
Tensor< 1, 3 > rolling_resistance_spring_torque
Tensor< 1, 3 > tensor_nd_to_3d(const Tensor< 1, dim > &tensor)
Tensor< 1, 2 > tensor_nd_to_2d(const Tensor< 1, dim > &tensor)
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.
void update_particle_container(typename DEM::dem_data_structures< dim >::particle_index_iterator_map &particle_container, const Particles::ParticleHandler< dim > *particle_handler)
Update the iterators to local particles in a map of particles (particle_container).