Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
dem.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2020-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#include <core/grids.h>
6#include <core/manifolds.h>
8
10#include <dem/dem.h>
19#include <dem/read_checkpoint.h>
23#include <dem/utilities.h>
26
27#include <deal.II/base/table_handler.h>
28
29#include <deal.II/grid/grid_out.h>
30
31#include <sys/stat.h>
32
33#include <numbers>
34#include <ranges>
35#include <sstream>
36#include <utility>
37
38template <int dim, typename PropertiesIndex>
40 DEMSolverParameters<dim> dem_parameters)
41 : mpi_communicator(MPI_COMM_WORLD)
44 , pcout(std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD) == 0)
45 , parameters(std::move(dem_parameters))
48 Triangulation<dim>::limit_level_difference_at_vertices)
49 , mapping(1)
50 , particle_handler(triangulation, mapping, PropertiesIndex::n_properties)
52 this->pcout,
53 TimerOutput::never,
54 TimerOutput::wall_times)
58 parameters.lagrangian_physical_properties.particle_type_number)
59{}
60
61template <int dim, typename PropertiesIndex>
62void
64{
65 // DEM relies on a parallel::distributed::Triangulation throughout (boundary
66 // cell information, load balancing and checkpointing all require it), whereas
67 // simplex meshes need a parallel::fullydistributed::Triangulation. Reject
68 // them explicitly rather than letting the grid reading reach an unimplemented
69 // deal.II code path.
70 AssertThrow(
71 !parameters.mesh.simplex,
72 ExcMessage(
73 "Simplex meshes are not supported by DEM simulations. Set 'simplex = false' in the mesh subsection."));
74
75 // Print simulation starting information
76 pcout << std::endl;
77 std::stringstream ss;
78 ss << "Running on " << n_mpi_processes << " rank(s)";
79 announce_string(pcout, ss.str(), '*');
80
81 // Check if the output directory exists
82 std::string output_dir_name = parameters.simulation_control.output_folder;
83 struct stat buffer;
84
85 // If the output directory does not exist, create it
86 if (this_mpi_process == 0)
87 {
88 if (stat(output_dir_name.c_str(), &buffer) != 0)
89 {
90 create_output_folder(output_dir_name);
91 }
92 }
93
94 // Get the pointer of the only instance of the action manager
96
97 // Set the simulation control as transient DEM
98 simulation_control = std::make_shared<SimulationControlTransientDEM>(
99 parameters.simulation_control);
100
101 // Set up the load balancing parameters and attach the correct functions to
102 // the signals inside the triangulation
103 load_balancing.set_parameters(parameters.model_parameters);
104 load_balancing.copy_references(simulation_control,
108 load_balancing.connect_weight_signals();
109
110 // Set the adaptive sparse contacts parameters
111 if (parameters.model_parameters.sparse_particle_contacts)
112 {
113 sparse_contacts_object.set_parameters(
114 parameters.model_parameters.granular_temperature_threshold,
115 parameters.model_parameters.solid_fraction_threshold,
116 parameters.model_parameters.advect_particles);
117 }
118
119 // Set the distribution type and initialize the neighborhood threshold
121
122 if (this_mpi_process == 0)
124 pcout,
126
127 // Set the grid motion type
128 grid_motion_object = std::make_shared<::GridMotionBase<dim, dim>>(
129 parameters.grid_motion, simulation_control->get_time_step());
130
131 // Set up the solid objects
133
134 // Check whether periodic boundaries are present. If at least one periodic
135 // boundary is found, initialize the information for all periodic boundaries.
136 if (!parameters.boundary_conditions.periodic_boundaries.empty())
137 periodic_boundaries_object.set_periodic_boundaries_information(
138 parameters.boundary_conditions.periodic_boundaries);
139
140 // Assign gravity
141 g = parameters.lagrangian_physical_properties.g;
142
143 // If this is a restart simulation
144 if (parameters.restart.restart)
145 {
146 action_manager->restart_simulation();
147
148 if (parameters.model_parameters.load_balance_method !=
150 action_manager->load_balance_step();
151 }
152
153 // Disable position integration
155 parameters.model_parameters.disable_position_integration;
156}
157
158template <int dim, typename PropertiesIndex>
159void
174
175template <int dim, typename PropertiesIndex>
176void
178{
179 // Set up solid objects and carry them in vectors
180 for (unsigned int i_solid = 0;
181 i_solid < parameters.solid_objects->number_solid_surfaces;
182 ++i_solid)
183 {
184 solid_surfaces.push_back(std::make_shared<SerialSolid<dim - 1, dim>>(
185 this->parameters.solid_objects->solid_surfaces[i_solid], i_solid));
186 }
187
188 for (unsigned int i_solid = 0;
189 i_solid < parameters.solid_objects->number_solid_volumes;
190 ++i_solid)
191 {
192 solid_volumes.push_back(std::make_shared<SerialSolid<dim, dim>>(
193 this->parameters.solid_objects->solid_volumes[i_solid], i_solid));
194 }
195
196 // Resize the mesh info containers
199
200 // Simulation has solid objects and resize the container
201 if ((solid_surfaces.size() + solid_volumes.size()) > 0)
202 {
203 action_manager->set_solid_objects_enabled();
204 }
205}
206
207template <int dim, typename PropertiesIndex>
208void
210{
213
214 // Set the insertion object type before the restart because the restart only
215 // rebuilds the member of the insertion object
221
222 if (parameters.insertion_info.insertion_method ==
224 {
225 pcout << "\nUsing packed insertion method. This method overrides the\n"
226 "regular contact model. Please consult the documentation for\n"
227 "information on how to appropriately use it.\n"
228 << std::endl;
229
231 parameters.model_parameters.particle_particle_contact_force_model =
233 parameters.model_parameters.particle_wall_contact_force_method =
235
236 if (parameters.model_parameters.sparse_particle_contacts)
237 {
242 }
243 }
244
245 // Setting chosen contact force, insertion and integration methods
251}
252
253template <int dim, typename PropertiesIndex>
254std::function<void()>
256{
257 using namespace Parameters::Lagrangian;
259 contact_detection_method =
260 parameters.model_parameters.contact_detection_method;
261
262 switch (contact_detection_method)
263 {
268 default:
269 throw(std::runtime_error("Invalid contact detection method."));
270 }
271}
272
273template <int dim, typename PropertiesIndex>
274std::shared_ptr<Integrator<dim, PropertiesIndex>>
276{
277 using namespace Parameters::Lagrangian;
278 typename ModelParameters<dim>::IntegrationMethod integration_method =
279 parameters.model_parameters.integration_method;
280
281 switch (integration_method)
282 {
284 return std::make_shared<
287 return std::make_shared<
289 default:
290 throw(std::runtime_error("Invalid integration method."));
291 }
292}
293
294template <int dim, typename PropertiesIndex>
295void
297{
298 if (restart)
299 return;
300
301 const Parameters::MeshBoxRefinement<dim> &box_refinement =
302 *parameters.mesh_box_refinement;
303
304 for (unsigned int i_box = 0;
305 i_box < box_refinement.number_of_refinement_boxes;
306 ++i_box)
307 {
308 // Read the mesh that delimits the box
309 Triangulation<dim> box_to_refine;
311 (*box_refinement.refinement_boxes_meshes)[i_box], box_to_refine);
312
313 for (unsigned int i = 0;
314 i < box_refinement.box_additional_refinements[i_box];
315 ++i)
316 {
317 TimerOutput::Scope t(this->computing_timer, "Box refine");
318 pcout << "Initial refinement in box " << i_box << " - Step " << i + 1
319 << " of " << box_refinement.box_additional_refinements[i_box]
320 << std::endl;
321
322 // A DoFHandler on the background triangulation is required to search
323 // for the cells lying inside the box. No dofs need to be distributed
324 // on it, since the search is purely geometric. It is rebuilt at every
325 // step because the triangulation is refined below.
326 const DoFHandler<dim> background_dof_handler(triangulation);
327
329 box_to_refine);
330
331 // No solution transfer is needed: particles have not been inserted
332 // yet, so the triangulation carries no data.
333 triangulation.execute_coarsening_and_refinement();
334 }
335 }
336}
337
338template <int dim, typename PropertiesIndex>
339void
341{
342 // Find the smallest contact search frequency criterion between (smallest
343 // cell size - largest particle radius) and (security factor * (blob
344 // diameter - 1) * the largest particle radius). This value is used in
345 // the find_contact_detection_frequency function
347 std::min((GridTools::minimal_cell_diameter(triangulation) -
349 (parameters.model_parameters.dynamic_contact_search_factor *
350 (parameters.model_parameters.neighborhood_threshold - 1) *
352
353 // Find the smallest cell size and use this as the floating mesh mapping
354 // criterion. The edge case comes when the cells are completely square/cubic.
355 // In that case, every side of a cell is 2^-0.5 or 3^-0.5 times the
356 // cell_diameter. We want to refresh the mapping each time a solid-object
357 // passes through a cell or there will be late contact detection. Thus, we use
358 // this value.
360 if constexpr (dim == 2) // 2^-0.5 * D_c,min
361 return 0.5 * std::numbers::sqrt2 *
362 GridTools::minimal_cell_diameter(triangulation);
363 if constexpr (dim == 3) // 3^-0.5 * D_c,min
364 return std::numbers::inv_sqrt3 *
365 GridTools::minimal_cell_diameter(triangulation);
366 }();
367
368 // Set up background dof
370
371 // Set up the periodic boundaries (if PBC enabled)
372 periodic_boundaries_object.map_periodic_cells(
374
375 // Set the periodic offset per direction to the contact manager for
376 // periodic contact detection (if PBC enabled)
377 contact_manager.set_periodic_offset_per_direction(
378 periodic_boundaries_object.get_periodic_offset_per_direction());
379
380 // Set the periodic offsets of the periodic boundary pairs for other classes
381 for (const auto &pb_id :
382 periodic_boundaries_object.get_periodic_boundaries() | std::views::keys)
383 {
384 particle_particle_contact_force_object->set_periodic_offset(
385 periodic_boundaries_object.get_periodic_offset_distance(pb_id), pb_id);
386 }
387
388 // Set up the local and ghost cells (if ASC enabled)
389 sparse_contacts_object.update_local_and_ghost_cell_set(background_dh);
390}
391
392template <int dim, typename PropertiesIndex>
393void
395{
396 FE_Q<dim> background_fe(1);
397 background_dh.distribute_dofs(background_fe);
398
399 // Periodic nodes must be mapped, otherwise the disabling of contacts will not
400 // propagate the mobility status to the periodic nodes during iterations.
401 // Identification of periodic nodes is done with the background constraints.
402 // Those constraints are not used for any matrix assembly in DEM solver, this
403 // approach comes from CFD-DEM coupling where void fraction constraints are
404 // used to achieve the periodic node mapping.
405 if (action_manager->check_periodic_boundaries_enabled() &&
406 action_manager->check_sparse_contacts_enabled())
407 {
408 IndexSet locally_relevant_dofs =
409 DoFTools::extract_locally_relevant_dofs(background_dh);
410
412 background_constraints.reinit(background_dh.locally_owned_dofs(),
413 locally_relevant_dofs);
414
415 // Loop over the periodic boundary conditions, keyed by the principal
416 // periodic boundary id (id0).
417 for (auto const &[id0, periodic_boundary] :
418 parameters.boundary_conditions.periodic_boundaries)
419 {
420 // Default boundaries contain information for periodic boundary
421 // conditions that indicate id0 and id1 are 0 as default value To
422 // ensure these default values are not parsed, only make the
423 // periodicity constraints if id0 and id1 are distinct
424 if (id0 != periodic_boundary.neighbor_id)
425 DoFTools::make_periodicity_constraints(
427 id0,
428 periodic_boundary.neighbor_id,
429 periodic_boundary.direction,
431 }
432
434
436 }
437}
438
439template <int dim, typename PropertiesIndex>
440void
442{
443 load_balancing.check_load_balance_iteration();
444
445 if (!action_manager->check_load_balance())
446 return;
447
448 TimerOutput::Scope t(this->computing_timer, "Load balancing");
449
450 // If the load balancing uses the sparse_contact object to calculate the
451 // weight, make sure that the sparse contact object has all mobility status
452 // correctly identified and refreshed.
453 if (parameters.model_parameters.load_balance_method ==
455 sparse_contacts_object.identify_mobility_status(
458 triangulation.n_active_cells(),
460
461 // Prepare the particle handler for the adaptation of the triangulation to the
462 // load
463 particle_handler.prepare_for_coarsening_and_refinement();
464
465 pcout << "-->Repartitioning triangulation" << std::endl;
466 triangulation.repartition();
467
468 // Unpack the particle handler after the mesh has been repartitioned
469 particle_handler.unpack_after_coarsening_and_refinement();
470
471 // If PBC are enabled, update the periodic cells
472 periodic_boundaries_object.map_periodic_cells(
474
475 // If ASC is enabled, update the local and ghost cell set
476 sparse_contacts_object.update_local_and_ghost_cell_set(background_dh);
477
478 // Update neighbors of cells after load balance
479 contact_manager.update_cell_neighbors(triangulation,
481
484 parameters.floating_walls,
485 parameters.boundary_conditions.outlet_boundaries,
486 parameters.mesh.check_for_diamond_cells,
487 parameters.mesh.expand_particle_wall_contact_search,
488 pcout);
489
490 // Update the boundary information (if grid motion)
491 boundary_cell_object.update_boundary_info_after_grid_motion(
493
494 const auto average_minimum_maximum_cells =
495 Utilities::MPI::min_max_avg(triangulation.n_active_cells(),
497
498 const auto average_minimum_maximum_particles =
499 Utilities::MPI::min_max_avg(particle_handler.n_locally_owned_particles(),
501
502 pcout << "Load balance finished " << std::endl;
503 pcout
504 << "Average, minimum and maximum number of particles on the processors are "
505 << average_minimum_maximum_particles.avg << " , "
506 << average_minimum_maximum_particles.min << " and "
507 << average_minimum_maximum_particles.max << std::endl;
508 pcout << "Minimum and maximum number of cells owned by the processors are "
509 << average_minimum_maximum_cells.min << " and "
510 << average_minimum_maximum_cells.max << std::endl;
511
513}
514
515template <int dim, typename PropertiesIndex>
516inline void
518{
519 const bool parallel_update =
520 (simulation_control->get_iteration_number() %
521 parameters.model_parameters.contact_detection_frequency) == 0;
524 simulation_control->get_time_step(),
528 parallel_update);
529}
530
531template <int dim, typename PropertiesIndex>
532inline void
534{
535 if ((simulation_control->get_iteration_number() %
536 parameters.model_parameters.contact_detection_frequency) == 0)
537 action_manager->contact_detection_step();
538}
539
540template <int dim, typename PropertiesIndex>
541void
543{
544 // If the insertion frequency is set to 0, then no particles are going
545 // to be inserted
546 if (parameters.insertion_info.insertion_frequency == 0)
547 return;
548
549 if ((simulation_control->get_iteration_number() %
550 parameters.insertion_info.insertion_frequency) == 1 ||
551 simulation_control->get_iteration_number() == 1)
552 {
554
555 action_manager->particle_insertion_step();
556 }
557}
558
559template <int dim, typename PropertiesIndex>
560void
562{
563 // Particle-wall contact force
564 particle_wall_contact_force_object->calculate_particle_wall_contact(
565 contact_manager.get_particle_wall_in_contact(),
566 simulation_control->get_time_step(),
568
569 // Particle-floating wall contact force
570 if (parameters.floating_walls.floating_walls_number > 0)
571 {
572 particle_wall_contact_force_object->calculate_particle_wall_contact(
573 contact_manager.get_particle_floating_wall_in_contact(),
574 simulation_control->get_time_step(),
576 }
577
578 // Particle-solid objects contact force
579 if (action_manager->check_solid_objects_enabled()) // until refactor
580 {
582 ->calculate_particle_solid_object_contact(
583 contact_manager.get_particle_floating_mesh_potentially_in_contact(),
584 simulation_control->get_time_step(),
587 }
588
589 // Particle-point and particle-line contacts. Boundary points and lines are
590 // part of the walls, so they use the shift model with the packed insertion
591 // method, like the particle-wall contacts. The displacements are accumulated
592 // in the force container.
593 if (parameters.insertion_info.insertion_method ==
595 {
597 .calculate_particle_point_shift_displacement(
598 contact_manager.get_particle_points_in_contact(), force);
599
600 if constexpr (dim == 3)
601 {
603 .calculate_particle_line_shift_displacement(
604 contact_manager.get_particle_lines_in_contact(), force);
605 }
606 }
607 else // If this is a regular DEM simulation
608 {
610 .calculate_particle_point_contact_force(
611 &contact_manager.get_particle_points_in_contact(),
612 parameters.lagrangian_physical_properties,
613 force);
614
615 if constexpr (dim == 3)
616 {
618 .calculate_particle_line_contact_force(
619 &contact_manager.get_particle_lines_in_contact(),
620 parameters.lagrangian_physical_properties,
621 force);
622 }
623 }
624}
625
626template <int dim, typename PropertiesIndex>
627void
629{
630 if (!action_manager->check_solid_objects_enabled())
631 return;
632
633 // Move the solid triangulations, previous time must be used here
634 // instead of current time.
635 for (auto &solid_object : solid_surfaces)
636 solid_object->move_solid_triangulation(
637 simulation_control->get_time_step(),
638 simulation_control->get_previous_time());
639
640 for (auto &solid_object : solid_volumes)
641 solid_object->move_solid_triangulation(
642 simulation_control->get_time_step(),
643 simulation_control->get_previous_time());
644}
645
646template <int dim, typename PropertiesIndex>
647void
649{
650 // Previous time must be used here instead of current time, which is the time
651 // for which we are doing calculations. The solid object is moved and its
652 // temperature is updated before calculating the contact outcomes for the
653 // current time step, so its properties should correspond to the
654 // previous time step.
656 {
657 if (!action_manager->check_solid_objects_enabled())
658 return;
659
660 for (auto &solid_object : solid_surfaces)
661 solid_object->update_solid_temperature(
662 simulation_control->get_previous_time());
663
664 for (auto &solid_object : solid_volumes)
665 solid_object->update_solid_temperature(
666 simulation_control->get_previous_time());
667 }
668}
669
670template <int dim, typename PropertiesIndex>
671void
673{
674 // The previous time must be used here instead of
675 // the current time, since the contact outcomes are calculated with the
676 // particle positions of the previous time step.
678 set_wall_temperature_time(parameters.boundary_conditions,
679 simulation_control->get_previous_time());
680}
681
682template <int dim, typename PropertiesIndex>
683void
685{
686 // Check for contact search according to the contact detection method
688
689 // Check whether the solid objects needs to be mapped onto the background
690 // mesh.
692 this->solid_surfaces);
693
694 // Map solid objects if the action was triggered
695 if (action_manager->check_solid_object_search())
696 {
697 // Store the information about the floating mesh and background mesh
698 // intersection
699 for (unsigned int i_solid = 0; i_solid < solid_surfaces.size(); ++i_solid)
700 {
701 solid_surfaces_mesh_info[i_solid] =
702 solid_surfaces[i_solid]->map_solid_in_background_triangulation(
704 }
705
706 for (unsigned int i_solid = 0; i_solid < solid_volumes.size(); ++i_solid)
707 {
708 solid_volumes_mesh_info[i_solid] =
709 solid_volumes[i_solid]->map_solid_in_background_triangulation(
711 }
712 }
713
714 // Execute the contact search if the action was triggered
715 if (action_manager->check_contact_search())
716 {
717 // Apply particle displacement across periodic boundaries.
718 periodic_boundaries_object.execute_particles_displacement(
720
722
723 // Compute the mobility status of the cells.
724 sparse_contacts_object.identify_mobility_status(
727 triangulation.n_active_cells(),
729
730 // Execute the broad search by filling the particle-particle containers of
731 // contact pair candidates and the containers of particle-wall
732 // contact pair candidates
733 contact_manager.execute_particle_particle_broad_search(
735
736 contact_manager.execute_particle_wall_broad_search(
740 parameters.floating_walls,
741 simulation_control->get_current_time(),
743
744 // Update contacts by removing duplicates and adding new contact pairs
745 // when particles are exchanged between processors.
746 contact_manager.update_contacts();
747
748 // Update the particle iterators in local-local contact
749 // containers
750 contact_manager.update_local_particles_in_cells(particle_handler);
751
752 // Execute particle-particle fine search and update contact pairs
753 // within the neighborhood threshold
754
755 contact_manager.execute_particle_particle_fine_search(
757
758 // Execute the particle-wall fine search and update the contact
759 // pairs within the neighborhood threshold
760 contact_manager.execute_particle_wall_fine_search(
761 parameters.floating_walls,
762 simulation_control->get_current_time(),
764
765 // Updating number of contact builds
767 }
768 else
769 {
770 particle_handler.update_ghost_particles();
771 }
772}
773
774template <int dim, typename PropertiesIndex>
775void
777{
778 // Particle-particle contact force
779 particle_particle_contact_force_object->calculate_particle_particle_contact(
780 contact_manager.get_local_adjacent_particles(),
781 contact_manager.get_ghost_adjacent_particles(),
782 contact_manager.get_local_local_periodic_adjacent_particles(),
783 contact_manager.get_local_ghost_periodic_adjacent_particles(),
784 contact_manager.get_ghost_local_periodic_adjacent_particles(),
785 simulation_control->get_time_step(),
787
788 // Update the boundary points and vectors (if grid motion)
789 // We have to update the positions of the points on boundary faces and
790 // their normal vectors here. The update_contacts deletes the
791 // particle-wall contact candidate if it exists in the contact list.
792 // As a result, when we update the points on boundary faces and their
793 // normal vectors, update_contacts deletes it from the output of broad
794 // search, and they are not updated in the contact force calculations.
795 grid_motion_object->update_boundary_points_and_normal_vectors_in_contact_list(
796 contact_manager.get_particle_wall_in_contact(),
798
799 // Particle-wall contact force
801}
802
803template <int dim, typename PropertiesIndex>
804void
806{
807 // The particle positions have reached time t, but their velocities are
808 // still lagging by half a time step. The contact forces are re-evaluated at
809 // this position so that the closing half velocity step can be applied.
810 // Neither the particles nor the solid objects are moved here, hence the
811 // insertion, the grid motion, the load balancing and the solid object motion
812 // are all left out. This step is only applied to synchronize velocity and
813 // position at the same time.
815
817
818 integrator_object->integrate_end(particle_handler,
819 g,
820 simulation_control->get_time_step(),
821 torque,
822 force,
823 MOI,
826
827 // Reset all trigger flags
828 action_manager->reset_triggers();
829}
830
831template <int dim, typename PropertiesIndex>
832void
834{
835 // Timer output
837 {
838 this->pcout << std::defaultfloat;
839 this->computing_timer.print_summary();
840 this->pcout << std::scientific;
841 }
842
843 // Testing
844 if (parameters.test.enabled)
845 {
846 switch (parameters.test.test_type)
847 {
849 {
852 pcout);
853 break;
854 }
856 {
857 // Get mobility status vector sorted by cell id
858 Vector<float> mobility_status(triangulation.n_active_cells());
859 sparse_contacts_object.get_mobility_status_vector(
860 mobility_status);
861
862 // Output mobility status vector
863 visualization_object.print_intermediate_format(mobility_status,
866 pcout);
867 break;
868 }
870 {
871 // Get mobility status vector sorted by cell id
872 Vector<float> subdomain(triangulation.n_active_cells());
873 for (unsigned int i = 0; i < subdomain.size(); ++i)
874 subdomain(i) = triangulation.locally_owned_subdomain();
875
876 // Output subdomain vector
877 visualization_object.print_intermediate_format(subdomain,
880 pcout);
881 break;
882 }
883 default:
884 break;
885 }
886 }
887
888 // Outputting force and torques over the boundaries
889 if (parameters.forces_torques.calculate_force_torque)
890 {
892 parameters.forces_torques.force_torque_output_name,
893 parameters.forces_torques.output_frequency,
894 triangulation.get_boundary_ids(),
895 simulation_control->get_time_step(),
898 }
899}
900
901template <int dim, typename PropertiesIndex>
902void
904{
905 TimerOutput::Scope t(this->computing_timer, "Output VTU");
906
907 const std::string folder = parameters.simulation_control.output_folder;
908 const std::string particles_solution_name =
909 parameters.simulation_control.output_name;
910 const unsigned int iter = simulation_control->get_iteration_number();
911 const double time = simulation_control->get_current_time();
912 const unsigned int group_files = parameters.simulation_control.group_files;
913
914 // Write particles
915 Visualization<dim, PropertiesIndex> particle_data_out;
916 particle_data_out.build_patches(particle_handler,
917 properties_class.get_properties_name());
918
920 particle_data_out,
921 folder,
922 particles_solution_name,
923 time,
924 iter,
925 group_files,
927
928 if (simulation_control->get_output_boundaries())
929 {
930 DataOutFaces<dim> data_out_faces;
931
932 // Set up background dofs to initiate right sized boundary_id vector
933 Vector<float> boundary_id(background_dh.n_dofs());
934
935 // Attach the boundary_id to the data_out_faces object
937 data_out_faces.attach_dof_handler(background_dh);
938 data_out_faces.add_data_vector(boundary_id, boundary);
939 data_out_faces.build_patches();
940
942 data_out_faces, folder, time, iter, this->mpi_communicator);
943 }
944 if (parameters.post_processing.force_chains)
945 {
946 // Force chains visualization
949 particles_force_chains_object->write_force_chains(
952 this->mpi_communicator,
953 folder,
954 iter,
955 time,
956 contact_manager.get_local_adjacent_particles(),
957 contact_manager.get_ghost_adjacent_particles());
958 }
959
960 // Write all solid objects
961 for (const auto &solid_object : solid_surfaces)
962 solid_object->write_output_results(simulation_control);
963
964 for (const auto &solid_object : solid_volumes)
965 solid_object->write_output_results(simulation_control);
966}
967
968template <int dim, typename PropertiesIndex>
969void
971{
972 if (parameters.post_processing.lagrangian_post_processing_enabled &&
973 simulation_control->is_output_iteration())
974 {
981 simulation_control->get_current_time(),
982 simulation_control->get_iteration_number(),
985 }
986}
987
988template <int dim, typename PropertiesIndex>
989void
991{
992 // Update statistics on the contact list
993 double number_of_list_built_since_last_log =
994 double(contact_build_number) - contact_list.total;
995 contact_list.max =
996 std::max(number_of_list_built_since_last_log, contact_list.max);
997 contact_list.min =
998 std::min(number_of_list_built_since_last_log, contact_list.min);
999 contact_list.total += number_of_list_built_since_last_log;
1000 contact_list.average = contact_list.total /
1001 (simulation_control->get_iteration_number()) *
1002 simulation_control->get_log_frequency();
1003
1004 // Calculate statistics on the particles
1006 dim,
1007 PropertiesIndex,
1011 dim,
1012 PropertiesIndex,
1017 PropertiesIndex,
1022 PropertiesIndex,
1025
1026 if (this_mpi_process == 0)
1027 {
1028 TableHandler report;
1029
1030 report.declare_column("Variable");
1031 report.declare_column("Min");
1032 report.declare_column("Max");
1033 report.declare_column("Average");
1034 report.declare_column("Total");
1035 add_statistics_to_table_handler("Contact list generation",
1037 report);
1038 add_statistics_to_table_handler("Velocity magnitude", velocity, report);
1039 add_statistics_to_table_handler("Angular velocity magnitude",
1040 omega,
1041 report);
1042 add_statistics_to_table_handler("Translational kinetic energy",
1044 report);
1045 add_statistics_to_table_handler("Rotational kinetic energy",
1047 report);
1048
1049
1050
1051 report.set_scientific("Min", true);
1052 report.set_scientific("Max", true);
1053 report.set_scientific("Average", true);
1054 report.set_scientific("Total", true);
1055
1056 report.write_text(std::cout, dealii::TableHandler::org_mode_table);
1057 }
1058
1059 // Timer output
1061 {
1062 this->pcout << std::defaultfloat;
1063 this->computing_timer.print_summary();
1064 this->pcout << std::scientific;
1065 }
1066}
1067
1068template <int dim, typename PropertiesIndex>
1069inline void
1071{
1072 particle_handler.sort_particles_into_subdomains_and_cells();
1073
1074 // Exchange ghost particles
1075 particle_handler.exchange_ghost_particles(true);
1076
1077 // Resize the displacement, force and torque containers only if the particles
1078 // have changed subdomains
1079 if (action_manager->check_resize_containers())
1080 {
1081 unsigned int number_of_particles =
1082 particle_handler.get_max_local_particle_index();
1083 // Resize displacement container
1084 displacement.resize(number_of_particles);
1085 // Resize outcome containers
1086 contact_outcome.resize_interaction_containers(number_of_particles);
1087 MOI.resize(number_of_particles);
1088
1089 // Updating the moment of inertia container
1090 for (auto &particle : particle_handler)
1091 {
1092 auto particle_properties = particle.get_properties();
1093 MOI[particle.get_local_index()] =
1094 0.1 * particle_properties[PropertiesIndex::mass] *
1095 particle_properties[PropertiesIndex::dp] *
1096 particle_properties[PropertiesIndex::dp];
1097 }
1098 }
1099
1100 // Always reset the displacement values since we are doing a search detection
1101 std::ranges::fill(displacement, 0.);
1102}
1103
1104template <int dim, typename PropertiesIndex>
1105bool
1107{
1108 if (parameters.insertion_info.insertion_method !=
1110 return false;
1111
1112 unsigned int number_of_pp_contact_on_proc =
1113 particle_particle_contact_force_object->get_number_of_contacts();
1114
1115 // Boundary points and lines are part of the walls, so their contacts are
1116 // counted as particle-wall contacts
1117 unsigned int number_of_pw_contact_on_proc =
1118 particle_wall_contact_force_object->get_number_of_contacts() +
1119 particle_point_line_contact_force_object.get_number_of_contacts();
1120
1121 const unsigned int total_number_of_pp_contacts =
1122 Utilities::MPI::sum(number_of_pp_contact_on_proc, mpi_communicator);
1123
1124 const unsigned int total_number_of_pw_contacts =
1125 Utilities::MPI::sum(number_of_pw_contact_on_proc, mpi_communicator);
1126 if (total_number_of_pp_contacts + total_number_of_pw_contacts == 0)
1127 {
1128 pcout << "No contact detected. Exiting simulation." << std::endl;
1129 if (!parameters.test.enabled)
1131 return true;
1132 }
1133 if (simulation_control->is_verbose_iteration())
1134 pcout << std::endl
1135 << "Total number of p-p contacts: " << total_number_of_pp_contacts
1136 << std::endl
1137 << "Total number of p-w contacts: " << total_number_of_pw_contacts
1138 << std::endl
1139 << std::endl;
1140
1141 particle_particle_contact_force_object->reset_number_of_contacts();
1142 particle_wall_contact_force_object->reset_number_of_contacts();
1143 particle_point_line_contact_force_object.reset_number_of_contacts();
1144
1145 // Displace the particles using the displacements accumulated by the shift
1146 // contact models. A particle may not move by more than the largest particle
1147 // diameter during a pseudo-time step. This is important, otherwise a particle
1148 // could move to a non-neighboring cell within one pseudo-time step.
1151
1152 // Packed insertion is enabled and simulation will continue.
1153 return false;
1154}
1155
1156template <int dim, typename PropertiesIndex>
1157void
1159{
1160 // Set up the parameters
1162
1163 // Reading mesh
1164 pcout << "Reading triangulation" << std::endl;
1165
1167 parameters.mesh,
1168 parameters.manifolds_parameters,
1169 action_manager->check_restart_simulation(),
1170 parameters.boundary_conditions.periodic_boundaries);
1171
1172 pcout << std::endl << "Finished reading triangulation" << std::endl;
1173
1174 // Set up functions and pointers according to parameters
1176
1177 // Read checkpoint if needed
1179 parameters,
1188
1189 // Refine the background mesh within the user-specified refinement boxes. This
1190 // must happen before the triangulation-dependent parameters are set up, since
1191 // they are derived from the smallest cell of the final mesh.
1192 box_refine_mesh(action_manager->check_restart_simulation());
1193
1196 pcout,
1198
1199 // Set up the various parameters that need the triangulation
1201
1202 // Build the mapping of the cell neighbors
1203 contact_manager.execute_cell_neighbors_search(
1205
1206 // Find boundary cells with faces
1209 parameters.floating_walls,
1210 parameters.boundary_conditions.outlet_boundaries,
1211 parameters.mesh.check_for_diamond_cells,
1212 parameters.mesh.expand_particle_wall_contact_search,
1213 pcout);
1214
1215 // DEM engine iterator
1216 while (simulation_control->integrate())
1217 {
1218 simulation_control->print_progression(pcout);
1219 if (simulation_control->is_verbose_iteration())
1221
1222 // Move grid and update the boundary information (if grid motion)
1224 boundary_cell_object.update_boundary_info_after_grid_motion(
1226
1227 // Insert particle if needed
1229
1230 // Load balancing (if load balancing enabled and if needed)
1231 load_balance();
1232
1233 // Check if a contact detection is required and, if so, execute the
1234 // particle-particle and particle-wall broad and fine searches
1236
1237 // Move solid objects
1239
1240 // Update solid objects temperatures
1242
1243 // Update walls temperatures
1245
1246 // Particle-particle and particle-wall contact forces
1248
1249 // Integration of temperature for multiphysic DEM
1251 {
1254 simulation_control->get_time_step(),
1255 contact_outcome.heat_transfer_rate,
1256 std::vector<double>(force.size()));
1257 }
1258
1259 // Integration of force and velocity for new location of particles.
1260 // The very first iteration is handed to integrate_start, which lets the
1261 // scheme decide whether it needs a special opening step. Restarted
1262 // simulations resume with regular steps, since the checkpoints store the
1263 // velocities as the scheme left them.
1265 {
1266 if (simulation_control->is_at_start() && !parameters.restart.restart)
1267 {
1268 integrator_object->integrate_start(
1270 g,
1271 simulation_control->get_time_step(),
1272 torque,
1273 force,
1274 MOI);
1275 }
1276 else
1277 {
1279 g,
1280 simulation_control->get_time_step(),
1281 torque,
1282 force,
1283 MOI,
1286 }
1287 }
1288
1289 // If the packed insertion has reached the end due to the fact
1290 // that no particle-wall or particle-particle contact remain, we break
1291 // the simulation control loop.
1293 break;
1294
1295 // Visualization
1296 if (simulation_control->is_output_iteration())
1298
1299 // Log the contact statistics if the parameter is enabled
1300 if (parameters.post_processing.particle_wall_collision_statistics)
1301 {
1303 parameters,
1304 contact_manager.get_particle_wall_in_contact(),
1305 simulation_control->get_current_time(),
1308 }
1309
1310 // Calculation of forces and torques if needed
1311 if (parameters.forces_torques.calculate_force_torque)
1312 {
1313 if ((this_mpi_process == 0) &&
1314 (simulation_control->get_iteration_number() %
1315 parameters.forces_torques.output_frequency ==
1316 0) &&
1317 (parameters.forces_torques.force_torque_verbosity ==
1319 {
1322 ->get_iteration_number()],
1324 ->get_iteration_number()]);
1325 }
1326 }
1327
1328 // Post-processing if needed
1330
1331 // Write checkpoint if needed
1332 if (checkpoint_controller.is_checkpoint_time_step(
1333 simulation_control->get_iteration_number()))
1334 {
1336 parameters,
1344 pcout,
1347 }
1348
1349 // Reset all trigger flags
1350 action_manager->reset_triggers();
1351 }
1352
1353 // Closing step of the integration scheme. It brings the velocities of the
1354 // particles to the final time, at which their positions already are.
1356 {
1358
1359 if (simulation_control->is_verbose_iteration())
1360 {
1361 announce_string(pcout, "Synchronized particle statistics");
1363 }
1364 }
1365
1366 // Write particle-wall collision statistics file if enabled
1367 if (parameters.post_processing.particle_wall_collision_statistics)
1369
1371}
1372
Mechanism that disables contacts computation through mobility status of cells based on granular tempe...
BoundaryPostprocessor Post-processor class used to attach the boundary id to the faces when outputtin...
Definition manifolds.h:99
void set_sparse_contacts_disabled()
Disables the ASC.
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
Handles all the parameters declared in the parameter handler file.
Solver using the soft-sphere model of the discrete element method (DEM) to simulate granular systems.
Definition dem.h:49
void setup_triangulation_dependent_parameters()
Set up the triangulation dependent parameters after the reading of the mesh and/or the simulation res...
Definition dem.cc:340
dem_data_structures< dim >::boundary_points_and_normal_vectors updated_boundary_points_and_normal_vectors
The map of the point and normal vector of grid. Only used with grid motion.
Definition dem.h:495
void particle_wall_contact_force()
Calculates particles-wall contact forces.
Definition dem.cc:561
void setup_functions_and_pointers()
Set up the pointers to the functions and classes according to the parameters.
Definition dem.cc:209
Tensor< 1, 3 > g
The acceleration acting on the particles.
Definition dem.h:329
dem_data_structures< dim >::vector_on_boundary forces_boundary_information
The boundary information of the forces.
Definition dem.h:501
std::vector< double > MOI
The moment of inertia of particles.
Definition dem.h:474
DEM::ParticleProperties< dim, PropertiesIndex > properties_class
The properties of the DEM simulation.
Definition dem.h:324
void compute_contact_forces()
Calculate the particle-particle and the particle-wall contact forces and torques at the current posit...
Definition dem.cc:776
ConditionalOStream pcout
The output stream used for the parallel simulation, only used by the process 0.
Definition dem.h:280
std::shared_ptr< Integrator< dim, PropertiesIndex > > set_integrator_type()
Set the integration method.
Definition dem.cc:275
void setup_solid_objects()
Set up the solid object containers with serial objects. TODO: Modify this set up once the solid volum...
Definition dem.cc:177
Particles::ParticleHandler< dim, dim > particle_handler
The particle handler that manages the particles.
Definition dem.h:306
dem_data_structures< dim >::vector_on_boundary torques_boundary_information
The torques boundary information.
Definition dem.h:507
void execute_contact_detection_and_search()
Check if a contact detection is required at the current iteration and, if it is, map the solid object...
Definition dem.cc:684
void box_refine_mesh(const bool restart)
Refine the triangulation within the user-specified refinement boxes.
Definition dem.cc:296
statistics contact_list
The storage of statistics about time and contact lists.
Definition dem.h:536
OngoingCollisionLog< dim > ongoing_collision_log
Class object to store the particle id, boundary id, velocity tensor, omega tensor and time of ongoing...
Definition dem.h:458
void solve()
Engine of the DEM solver. Calls all the necessary functions to set parameters, solve the simulation,...
Definition dem.cc:1158
ParticleInteractionOutcomes< PropertiesIndex > contact_outcome
Class object to store the vectors of force, torque and heat transfer rate applied to particles.
Definition dem.h:443
void setup_distribution_type()
Initialize the distribution type for the particles, and sets the maximum particle diameter and the ne...
Definition dem.cc:160
PVDHandler particles_pvdhandler
The particle PVD handler.
Definition dem.h:433
AffineConstraints< double > background_constraints
The constraints for the background grid needed for the adaptive sparse.
Definition dem.h:562
const unsigned int this_mpi_process
The rank of the current MPI process.
Definition dem.h:274
DoFHandler< dim > background_dh
The background degree of freedom handler uses for parallel grid processing.
Definition dem.h:526
DEM::dem_data_structures< dim >::periodic_boundaries_cells_info periodic_boundaries_cells_information
The periodic boundaries cells information map. Only used with a simulation with periodic boundaries.
Definition dem.h:514
double smallest_solid_object_mapping_criterion
The smallest solid object mapping criterion. The value is .
Definition dem.h:348
AdaptiveSparseContacts< dim, PropertiesIndex > sparse_contacts_object
The object handling the adaptive sparse contacts (ASC). Only used with the ASC method.
Definition dem.h:557
BoundaryCellsInformation< dim > boundary_cell_object
The boundary cells object.
Definition dem.h:384
std::shared_ptr< ParticleWallContactForceBase< dim, PropertiesIndex > > particle_wall_contact_force_object
The particle-wall contact force object.
Definition dem.h:401
const unsigned int n_mpi_processes
The number of MPI processes used for the parallel simulation.
Definition dem.h:269
void synchronize_velocities()
Carry out the closing half velocity step of a staggered integration scheme, which synchronizes the ve...
Definition dem.cc:805
double neighborhood_threshold_squared
The neighborhood threshold squared. .
Definition dem.h:354
std::function< void()> set_contact_search_iteration_function()
Set the iteration check function according to the chosen contact detection method.
Definition dem.cc:255
std::shared_ptr< SimulationControl > simulation_control
The simulation control (DEM Transient).
Definition dem.h:379
void check_contact_search_iteration_constant()
Establish if this is a contact detection iteration using the constant contact detection frequency....
Definition dem.cc:533
std::shared_ptr<::GridMotionBase< dim > > grid_motion_object
The grid motion object.
Definition dem.h:389
DEMSolverParameters< dim > parameters
The parameters of the DEM simulation.
Definition dem.h:285
Visualization< dim, PropertiesIndex > visualization_object
The visualization object.
Definition dem.h:428
std::shared_ptr< ParticleParticleContactForceBase< dim, PropertiesIndex > > particle_particle_contact_force_object
The particle-particle contact force object.
Definition dem.h:395
std::shared_ptr< ParticlesForceChainsBase< dim, PropertiesIndex > > particles_force_chains_object
The particle force chains post-processing object.
Definition dem.h:413
std::shared_ptr< Integrator< dim, PropertiesIndex > > integrator_object
The integrator object.
Definition dem.h:418
LagrangianLoadBalancing< dim, PropertiesIndex > load_balancing
The load balancing handler.
Definition dem.h:374
CompletedCollisionLog< dim > collision_event_log
Class object to store the complete collision events (start and end).
Definition dem.h:463
std::vector< std::shared_ptr< SerialSolid< dim - 1, dim > > > solid_surfaces
The container of the solid surfaces.
Definition dem.h:541
PVDHandler particles_pvdhandler_force_chains
The force chains PVD handler.
Definition dem.h:438
std::vector< Tensor< 1, 3 > > & torque
The vector of torque of particles.
Definition dem.h:448
DEMSolver(DEMSolverParameters< dim > dem_parameters)
Definition dem.cc:39
void setup_parameters()
Set the parameters for the DEM simulation.
Definition dem.cc:63
MappingQGeneric< dim > mapping
The polynomial mapping. The mapping is first order in DEM simulations.
Definition dem.h:301
void report_statistics()
Calculate statistics on the particles and report them to the terminal. This function is notably used ...
Definition dem.cc:990
MPI_Comm mpi_communicator
The MPI communicator used for the parallel simulation.
Definition dem.h:264
void check_contact_search_iteration_dynamic()
Establish if this is a contact detection iteration using the maximal displacement of the particles....
Definition dem.cc:517
std::vector< double > displacement
The displacement tracking of particles for the dynamic contact detection.
Definition dem.h:469
void insert_particles()
Check if particles have to be inserted at this iteration and perform it if necessary.
Definition dem.cc:542
void setup_background_dofs()
Set up the background degree of freedom used for parallel grid output or mapping of periodic dofs whe...
Definition dem.cc:394
CheckpointControl checkpoint_controller
The checkpoint controller of the DEM simulation.
Definition dem.h:290
void load_balance()
Check if a load balancing is required according to the load balancing method and perform it if necess...
Definition dem.cc:441
double maximum_particle_diameter
The maximum particle diameter.
Definition dem.h:359
void update_temperature_solid_objects()
Update solid objects temperatures.
Definition dem.cc:648
void move_solid_objects()
Move all solid objects.
Definition dem.cc:628
std::vector< std::shared_ptr< SerialSolid< dim, dim > > > solid_volumes
The container of the solid volumes.
Definition dem.h:546
bool disable_position_integration
Disable position integration, useful for multiphysic simulations with a packed bed,...
Definition dem.h:580
std::vector< Tensor< 1, 3 > > & force
The vector of force of particles.
Definition dem.h:453
std::shared_ptr< Insertion< dim, PropertiesIndex > > insertion_object
The insertion object.
Definition dem.h:423
double smallest_contact_search_criterion
The contact search frequency criterion for the dynamic contact detection method. The value is the sma...
Definition dem.h:342
void write_output_results()
Generate VTU file with particles information for visualization.
Definition dem.cc:903
DEMActionManager * action_manager
The action manager that manages the actions triggered by events.
Definition dem.h:311
std::function< void()> contact_detection_iteration_check_function
The pointer to the contact detection function that checks if a contact search is required.
Definition dem.h:574
dem_data_structures< dim >::solid_volumes_mesh_info solid_volumes_mesh_info
The vector of vector of pairs of the mapping of the background mesh to the solid volume.
Definition dem.h:488
std::vector< std::shared_ptr< Distribution > > size_distribution_object_container
The container of the distribution objects.
Definition dem.h:551
PeriodicBoundariesManipulator< dim > periodic_boundaries_object
The periodic boundaries manipulator. Only used with a simulation with periodic boundaries.
Definition dem.h:520
void finish_simulation()
Execute the last post-processing at the end of the simulation and output test results if necessary.
Definition dem.cc:833
dem_data_structures< dim >::solid_surfaces_mesh_information solid_surfaces_mesh_info
The vector of vector of pairs of the mapping of the background mesh to the solid surface.
Definition dem.h:481
PVDHandler grid_pvdhandler
The grid PVD handler.
Definition dem.h:531
ParticlePointLineForce< dim, PropertiesIndex > particle_point_line_contact_force_object
The particle-point-line contact force object.
Definition dem.h:407
bool packed_insertion_report_and_status()
Hook for particular operations that are related to the packed insertion.
Definition dem.cc:1106
parallel::distributed::Triangulation< dim > triangulation
The distributed triangulation used for the DEM simulation.
Definition dem.h:295
void update_temperature_walls()
Update the temperatures of the walls of the grid.
Definition dem.cc:672
void sort_particles_into_subdomains_and_cells()
Execute the sorting of particle into subdomains and cells, and reinitialize the containers dependent ...
Definition dem.cc:1070
TimerOutput computing_timer
The timer that keeps track of the time spent in some functions. Currently theses functions are: load ...
Definition dem.h:317
unsigned int contact_build_number
The counter to keep track of the number of contact search.
Definition dem.h:364
DEMContactManager< dim, PropertiesIndex > contact_manager
The manager of all the contact search operations.
Definition dem.h:369
void post_process_results()
Calculate average velocity and other post-processed quantities that need to be outputted to files.
Definition dem.cc:970
Implementation of a classical explicit euler scheme for the integration of the particle motion....
static void apply_shift_displacement(Particles::ParticleHandler< dim > &particle_handler, const double max_displacement, ParticleInteractionOutcomes< PropertiesIndex > &contact_outcome, std::vector< double > &displacements)
Displace the locally owned particles by the displacements accumulated by the shift contact models.
Parameters controlling particle insertion in DEM simulations.
Numerical model parameters for DEM simulations.
IntegrationMethod
Time integration method for particle motion.
ContactDetectionMethod
Contact detection method used in the simulation.
Implementation of a classical velocity verlet scheme for the integration of the particle motion....
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.
A simple container for storing basic statistical values.
Definition utilities.h:56
void create_output_folder(const std::string &dirname)
Creates the simulation output folder.
Definition utilities.cc:401
void announce_string(const ConditionalOStream &pcout, const std::string &expression, const char delimiter='-')
Prints a string and then adds a line above and below made with dashes containing as many dashes as th...
Definition utilities.h:500
void add_statistics_to_table_handler(const std::string &variable, const statistics &stats, TableHandler &table)
Add statistical values to a TableHandler.
Definition utilities.h:97
void report_cell_size_to_particle_diameter_ratio(const parallel::DistributedTriangulationBase< dim > &triangulation, const double maximum_particle_diameter, const ConditionalOStream &pcout, const MPI_Comm &mpi_communicator)
Reports the ratio between the minimum cell size and the maximum particle diameter.
Definition utilities.h:35
void setup_distributions(const LagrangianPhysicalProperties &lpp, std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container, double &maximum_particle_diameter, const unsigned int mpi_process_id, const ConditionalOStream &pcout)
void find_particle_contact_detection_step(Particles::ParticleHandler< dim > &particle_handler, const double dt, const double smallest_contact_search_criterion, MPI_Comm &mpi_communicator, std::vector< double > &displacement, const bool parallel_update=true)
Find steps for dynamic contact search for particle-particle contacts.
void find_floating_mesh_mapping_step(const double smallest_contact_search_criterion, std::vector< std::shared_ptr< SerialSolid< dim - 1, dim > > > solids)
Find steps for dynamic contact search in particle-floating mesh contacts.
void build_refinement_box_triangulation(const Parameters::Mesh< dim, spacedim > &box_mesh_parameters, Triangulation< dim, spacedim > &box_triangulation)
Build the triangulation which delimits a mesh refinement box.
Definition grids.cc:712
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.
Definition grids.cc:447
void input_parameter_inspection(const DEMSolverParameters< dim > &dem_parameters, const ConditionalOStream &pcout, const std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container)
Check input parameters in the parameter handler to be in the correct range. Warnings or error would a...
void write_post_processing_results(const parallel::distributed::Triangulation< dim > &triangulation, PVDHandler &grid_pvdhandler, const DoFHandler< dim > &background_dh, const Particles::ParticleHandler< dim > &particle_handler, const DEMSolverParameters< dim > &dem_parameters, const double current_time, const unsigned int step_number, const MPI_Comm &mpi_communicator, AdaptiveSparseContacts< dim, PropertiesIndex > &sparse_contacts_object)
Carries out writing the cell data of the domain.
void log_collision_data(const DEMSolverParameters< dim > &parameters, typename DEM::dem_data_structures< dim >::particle_wall_in_contact &particle_wall_pairs_in_contact, const double current_time, OngoingCollisionLog< dim > &ongoing_collision_log, CompletedCollisionLog< dim > &collision_event_log)
Logs the particle-wall contact statistics.
void write_collision_stats(const DEMSolverParameters< dim > &parameters, const CompletedCollisionLog< dim > &collision_event_log, const MPI_Comm &mpi_communicator)
Writes the collision statistics to a file.
void integrate_temperature(Particles::ParticleHandler< dim > &particle_handler, const double dt, std::vector< double > &heat_transfer_rate, const std::vector< double > &heat_source)
Implementation of an explicit euler time-stepping scheme for the integration of the particles' temper...
constexpr bool has_thermal_properties
Whether a properties index set carries thermal properties.
statistics calculate_granular_statistics(const Particles::ParticleHandler< dim > &particle_handler, const MPI_Comm &mpi_communicator)
Calculate statistics on a DEM ParticleHandler. At the moment, the following statistics are supported:
void flag_cells_in_refinement_box(const DoFHandler< dim > &dof_handler, const Triangulation< dim > &box_triangulation)
Flag for refinement of all the cells of a triangulation which lie within a refinement box.
void write_forces_torques_output_locally(std::map< unsigned int, Tensor< 1, 3 > > force_on_walls, std::map< unsigned int, Tensor< 1, 3 > > torque_on_walls)
write_forces_torques_output_locally Writes the results of force and torque calculations in the termin...
void write_forces_torques_output_results(const std::string &filename, const unsigned int output_frequency, const std::vector< unsigned int > &boundary_index, const double time_step, DEM::dem_data_structures< 3 >::vector_on_boundary &forces_boundary_information, DEM::dem_data_structures< 3 >::vector_on_boundary &torques_boundary_information)
write_forces_torques_output_results Writes the results of force and torque calculations in a file,...
void set_wall_temperature_time(const Parameters::Lagrangian::BCDEM &boundary_conditions, const double time)
Set the time of the temperature functions of the walls of the grid with a temperature boundary condit...
void read_checkpoint(TimerOutput &computing_timer, const DEMSolverParameters< dim > &parameters, std::shared_ptr< SimulationControl > &simulation_control, PVDHandler &particles_pvdhandler, PVDHandler &grid_pvdhandler, parallel::distributed::Triangulation< dim > &triangulation, Particles::ParticleHandler< dim > &particle_handler, std::shared_ptr< Insertion< dim, PropertiesIndex > > &insertion_object, std::vector< std::shared_ptr< SerialSolid< dim - 1, dim > > > &solid_surfaces, CheckpointControl &checkpoint_controller)
Read a DEM simulation checkpoint, allowing the simulation to restart from where it stopped.
std::shared_ptr< Insertion< dim, PropertiesIndex > > set_insertion_type(std::vector< std::shared_ptr< Distribution > > &size_distribution_object_container, parallel::distributed::Triangulation< dim > &triangulation, DEMSolverParameters< dim > &dem_parameters, const double &maximum_particle_diameter)
Set up the particle insertion method for the simulation. Creates and configures the appropriate inser...
std::shared_ptr< ParticleParticleContactForceBase< dim, PropertiesIndex > > set_particle_particle_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...
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...
std::shared_ptr< ParticleWallContactForceBase< dim, PropertiesIndex > > set_particle_wall_contact_force_model(const DEMSolverParameters< dim > &dem_parameters)
Return the particle-wall contact force model based on the spring-dashpot model and the rolling resist...
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...
void write_boundaries_vtu(const DataOutFaces< dim > &data_out, const std::string &folder, const double time, const unsigned int iter, const MPI_Comm &mpi_communicator, const std::string &file_prefix=std::string("boundaries"), const unsigned int digits=5)
Output the Data Out Faces to a single vtu file This function outputs the DataOutFaces to a vtu file.
std::shared_ptr< std::vector< Mesh< dim, spacedim > > > refinement_boxes_meshes
unsigned int number_of_refinement_boxes
Number of boxes delimiting refinement regions.
std::vector< unsigned int > box_additional_refinements
Vector of additional refinement values of the different boxes.
void write_checkpoint(TimerOutput &computing_timer, const DEMSolverParameters< dim > &parameters, std::shared_ptr< SimulationControl > &simulation_control, PVDHandler &particles_pvdhandler, PVDHandler &grid_pvdhandler, parallel::distributed::Triangulation< dim > &triangulation, Particles::ParticleHandler< dim > &particle_handler, std::shared_ptr< Insertion< dim, PropertiesIndex > > &insertion_object, std::vector< std::shared_ptr< SerialSolid< dim - 1, dim > > > &solid_objects, const ConditionalOStream &pcout, MPI_Comm &mpi_communicator, const CheckpointControl &checkpoint_controller)
Write_checkpoint Write a DEM simulation checkpointing to allow for DEM simulation restart.