Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
cfd_dem_coupling.cc
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2021-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/utilities.h>
7
17#include <dem/utilities.h>
21
22#include <boost/archive/text_iarchive.hpp>
23#include <boost/archive/text_oarchive.hpp>
24
25#include <filesystem>
26#include <fstream>
27#include <ranges>
28#include <sstream>
29
30// Constructor for the class CFD-DEM class
31template <int dim, typename PropertiesIndex>
38
39template <int dim, typename PropertiesIndex>
41
42template <int dim, typename PropertiesIndex>
43void
45{
47
48 // Initialize DEM Parameters
49 dem_parameters.lagrangian_physical_properties =
50 this->cfd_dem_simulation_parameters.dem_parameters
51 .lagrangian_physical_properties;
52 g = dem_parameters.lagrangian_physical_properties.g;
53 dem_parameters.boundary_conditions =
54 this->cfd_dem_simulation_parameters.dem_parameters.boundary_conditions;
55 dem_parameters.insertion_info =
56 this->cfd_dem_simulation_parameters.dem_parameters.insertion_info;
57 dem_parameters.floating_walls =
58 this->cfd_dem_simulation_parameters.dem_parameters.floating_walls;
59 dem_parameters.model_parameters =
60 this->cfd_dem_simulation_parameters.dem_parameters.model_parameters;
61 dem_parameters.simulation_control =
62 this->cfd_dem_simulation_parameters.dem_parameters.simulation_control;
63 dem_parameters.post_processing =
64 this->cfd_dem_simulation_parameters.dem_parameters.post_processing;
65 dem_parameters.mesh = this->cfd_dem_simulation_parameters.dem_parameters.mesh;
66 dem_parameters.restart =
67 this->cfd_dem_simulation_parameters.dem_parameters.restart;
69 dem_parameters.lagrangian_physical_properties.particle_type_number);
70
71 const auto parallel_triangulation =
72 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
73 &*this->triangulation);
74
75 // Setup load balancing parameters
76 load_balancing.set_parameters(dem_parameters.model_parameters);
77 load_balancing.copy_references(this->simulation_control,
78 *parallel_triangulation,
79 this->particle_handler,
81
82 // Attach the correct functions to the signals inside the triangulation
83 load_balancing.connect_weight_signals();
84
85 if (dem_parameters.model_parameters.sparse_particle_contacts)
86 {
87 dem_action_manager->set_sparse_contacts_enabled();
88 sparse_contacts_object.set_parameters(
89 dem_parameters.model_parameters.granular_temperature_threshold,
90 dem_parameters.model_parameters.solid_fraction_threshold,
91 dem_parameters.model_parameters.advect_particles);
92 }
93
95
96
97 // Calculate the Rayleigh critical time step ratio
98 rayleigh_time_step = DBL_MAX;
99
100 for (unsigned int i = 0;
101 i < dem_parameters.lagrangian_physical_properties.particle_type_number;
102 ++i)
103 {
104 const double youngs_modulus =
105 dem_parameters.lagrangian_physical_properties
106 .youngs_modulus_particle[i];
107 const double poisson_ratio =
108 dem_parameters.lagrangian_physical_properties.poisson_ratio_particle[i];
109 const double density =
110 dem_parameters.lagrangian_physical_properties.density_particle[i];
111
112 const double shear_modulus =
113 youngs_modulus / (2.0 * (1.0 + poisson_ratio));
114
115 const double min_diameter =
116 size_distribution_object_container.at(i)->find_min_diameter();
117
119 std::min(M_PI_2 * min_diameter * sqrt(density / shear_modulus) /
120 (0.1631 * poisson_ratio + 0.8766),
122 }
123
124 // Give an initial estimation of the DEM time step that will be overwritten
125 // later on by the SubSimulationControlDEM
126 dem_simulation_control = std::make_shared<SubSimulationControlDEM>(
127 this->cfd_dem_simulation_parameters.cfd_dem.dem_iteration_control,
128 this->simulation_control->get_time_step(),
129 this->cfd_dem_simulation_parameters.cfd_dem.coupling_frequency,
131 this->cfd_dem_simulation_parameters.cfd_dem.fraction_of_rayleigh_time);
132
134
135 // Check if there are periodic boundaries
136 if (!dem_parameters.boundary_conditions.periodic_boundaries.empty())
137 {
138 dem_action_manager->set_periodic_boundaries_enabled();
139
140 periodic_boundaries_object.set_periodic_boundaries_information(
141 dem_parameters.boundary_conditions.periodic_boundaries);
142 }
143
146 *parallel_triangulation,
149
150 // Initialize the total contact list counter
154 this->cfd_dem_simulation_parameters.dem_parameters);
155
156 // Initialize the contact search counter
158}
159
160template <int dim, typename PropertiesIndex>
161void
163{
165 setup_distributions(dem_parameters.lagrangian_physical_properties,
169 this->pcout);
170
172 std::pow(dem_parameters.model_parameters.neighborhood_threshold *
174 2);
175}
176
177template <int dim, typename PropertiesIndex>
178std::shared_ptr<Integrator<dim, PropertiesIndex>>
180{
181 using namespace Parameters::Lagrangian;
182 typename ModelParameters<dim>::IntegrationMethod integration_method =
183 dem_parameters.model_parameters.integration_method;
184
185 switch (integration_method)
186 {
188 return std::make_shared<
191 return std::make_shared<
193 default:
194 throw(std::runtime_error("Invalid integration method."));
195 }
196}
197
198template <int dim, typename PropertiesIndex>
199void
201{
202 this->pcout << "Initializing DEM parameters" << std::endl;
203
204 const auto parallel_triangulation =
205 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
206 &*this->triangulation);
207
208 // Set up the local and ghost cells (if ASC enabled)
209 sparse_contacts_object.update_local_and_ghost_cell_set(
210 *this->particle_projector.dof_handler);
211
214 this->cfd_dem_simulation_parameters.dem_parameters);
215
216 // Set the temperature of the walls of the grid for the first DEM iteration.
219 this->cfd_dem_simulation_parameters.dem_parameters.boundary_conditions,
220 this->simulation_control->get_current_time());
221
222 // Finding the smallest contact search frequency criterion between (smallest
223 // cell size - largest particle radius) and (security factor * (blob diameter
224 // - 1) * the largest particle radius). This value is used in
225 // find_contact_detection_frequency function
227 std::min((GridTools::minimal_cell_diameter(*this->triangulation) -
229 (dem_parameters.model_parameters.dynamic_contact_search_factor *
230 (dem_parameters.model_parameters.neighborhood_threshold - 1) *
232
233 // Remap periodic cells (if PBC enabled)
234 periodic_boundaries_object.map_periodic_cells(
235 *parallel_triangulation, periodic_boundaries_cells_information);
236
237 // Set the periodic offset per direction to the contact manager for
238 // periodic contact detection (if PBC enabled)
239 contact_manager.set_periodic_offset_per_direction(
240 periodic_boundaries_object.get_periodic_offset_per_direction());
241
242 // Set the periodic offsets of the periodic boundary pairs for other classes
243 for (const auto &pb_id :
244 periodic_boundaries_object.get_periodic_boundaries() | std::views::keys)
245 {
246 particle_particle_contact_force_object->set_periodic_offset(
247 periodic_boundaries_object.get_periodic_offset_distance(pb_id), pb_id);
248 }
249
250 // Find cell neighbors
251 contact_manager.execute_cell_neighbors_search(
252 *parallel_triangulation, periodic_boundaries_cells_information);
253
254 // Find boundary cells with faces
256 *parallel_triangulation,
257 dem_parameters.floating_walls,
258 dem_parameters.boundary_conditions.outlet_boundaries,
259 this->cfd_dem_simulation_parameters.cfd_parameters.mesh
260 .check_for_diamond_cells,
261 this->cfd_dem_simulation_parameters.cfd_parameters.mesh
262 .expand_particle_wall_contact_search,
263 this->pcout);
264
266
267 // Remap periodic nodes after setup of dofs (If ASC and PBC)
268 if (dem_action_manager->check_periodic_boundaries_enabled() &&
269 dem_action_manager->check_sparse_contacts_enabled())
270 {
271 sparse_contacts_object.map_periodic_nodes(
272 this->particle_projector.void_fraction_constraints);
273 }
274
275 this->pcout << "Finished initializing DEM parameters" << std::endl
276 << "DEM time step is " << dem_simulation_control->get_time_step()
277 << " s" << std::endl;
278}
279
280template <int dim, typename PropertiesIndex>
281void
283{
284 this->pcout << "Reading DEM checkpoint" << std::endl;
285
286 std::string prefix =
287 this->cfd_dem_simulation_parameters.void_fraction->dem_file_name;
288
289 // Load checkpoint controller
290 std::string checkpoint_controller_object_filename =
291 prefix + ".checkpoint_controller";
292 check_file_exists(checkpoint_controller_object_filename,
293 "checkpoint file of the checkpoint controller, given by "
294 "'subsection void fraction' - 'set dem file name'");
295 std::ifstream iss_checkpoint_controller_obj(
296 checkpoint_controller_object_filename);
297 boost::archive::text_iarchive ia_checkpoint_controller_obj(
298 iss_checkpoint_controller_obj, boost::archive::no_header);
299
300 unsigned int checkpoint_id;
301 ia_checkpoint_controller_obj >> checkpoint_id;
302
303 // New prefix for the remaining files
304 prefix = prefix + "_" + Utilities::int_to_string(checkpoint_id);
305
306 // Gather particle serialization information
307 std::string particle_filename = prefix + ".particles";
308 check_file_exists(particle_filename,
309 "checkpoint file of the particles, given by "
310 "'subsection void fraction' - 'set dem file name'");
311 std::ifstream input(particle_filename.c_str());
312
313 std::string buffer;
314 std::getline(input, buffer);
315 std::istringstream iss(buffer);
316 boost::archive::text_iarchive ia(iss, boost::archive::no_header);
317
318 // Create a temporary particle_handler with the DEM properties of the
319 // simulation this one is restarted from
320 using DEMPropertiesIndex =
322
323 Particles::ParticleHandler<dim> temporary_particle_handler(
324 *this->triangulation,
325 this->particle_mapping,
326 DEMPropertiesIndex::n_properties);
327
328 ia >> temporary_particle_handler;
329
330 const std::string filename = prefix + ".triangulation";
331 check_file_exists(filename,
332 "checkpoint file of the triangulation, given by "
333 "'subsection void fraction' - 'set dem file name'");
334
335 if (auto parallel_triangulation =
336 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
337 &*this->triangulation))
338 {
339 try
340 {
341 parallel_triangulation->load(filename.c_str());
342
343 // Deserialize particles have the triangulation has been read
344 temporary_particle_handler.deserialize();
345 }
346 catch (...)
347 {
348 AssertThrow(false,
349 ExcMessage("Cannot open snapshot mesh file or read the"
350 "triangulation stored there."));
351 }
352
353 // Fill the existing particle handler using the temporary one
354 // This is done during the dynamic cast for the convert_particle_handler
355 // function which requires a parallel::distributed::triangulation
357 *parallel_triangulation,
358 temporary_particle_handler,
359 this->particle_handler);
360 }
361 else
362 {
363 throw std::runtime_error(
364 "VANS equations currently do not support triangulations other than parallel::distributed");
365 }
366
367 this->pcout << "Finished reading DEM checkpoint" << std::endl
368 << this->particle_handler.n_global_particles()
369 << " particles are in the simulation" << std::endl;
370
372}
373
374template <int dim, typename PropertiesIndex>
375std::vector<OutputStructTableHandler>
377{
378 std::vector<OutputStructTableHandler> table_output_structs;
379
380 const Parameters::PostProcessing<dim> post_processing =
381 this->simulation_parameters.post_processing;
382 std::string prefix =
383 this->simulation_parameters.simulation_control.output_folder;
384 std::string suffix = ".checkpoint";
385 if (post_processing.calculate_phase_volumes)
386 table_output_structs.emplace_back(
388 prefix + post_processing.phase_volumes_output_name + suffix);
389 return table_output_structs;
390}
391
392template <int dim, typename PropertiesIndex>
393void
395{
396 TimerOutput::Scope timer(this->computing_timer, "Write checkpoint");
397
398 std::string prefix =
399 this->simulation_parameters.simulation_control.output_folder +
400 this->simulation_parameters.restart_parameters.filename;
401 std::string prefix_particles = prefix + "_particles";
402 std::string prefix_grid = prefix + "_lagrangian_postprocessing";
403
404 // Register the particles for serialization (all ranks)
405 this->particle_handler.prepare_for_serialization();
406
407 // Serial restart files, identical on every rank: written once
408 if (Utilities::MPI::this_mpi_process(this->mpi_communicator) == 0)
409 {
410 this->simulation_control->save(prefix);
411 this->pvdhandler.save(prefix);
412 particles_pvdhandler.save(prefix_particles);
413
414 if (this->dem_parameters.post_processing
415 .lagrangian_post_processing_enabled)
416 grid_pvdhandler.save(prefix_grid);
417
418 if (this->simulation_parameters.flow_control.enable_flow_control)
419 this->flow_control.save(prefix);
420
421 // Serialize the global particle counters
422 std::ostringstream oss_particle_handler;
423 boost::archive::text_oarchive oa_particle_handler(
424 oss_particle_handler, boost::archive::no_header);
425 oa_particle_handler << this->particle_handler;
426
427 // Write additional particle information for deserialization
428 std::string particle_filename = prefix + ".particles";
429 std::ofstream output(particle_filename.c_str());
430 output << oss_particle_handler.str() << std::endl;
431
432 // Prepare the insertion object for checkpointing
433 std::string insertion_object_filename = prefix + ".insertion_object";
434 std::ofstream oss_insertion_obj(insertion_object_filename);
435 boost::archive::text_oarchive oa_insertion_obj(oss_insertion_obj,
436 boost::archive::no_header);
437 insertion_object->serialize(oa_insertion_obj);
438 }
439
440 std::vector<const GlobalVectorType *> sol_set_transfer;
441 sol_set_transfer.push_back(&(*this->present_solution));
442 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
443 {
444 sol_set_transfer.push_back(&(*this->previous_solutions)[i]);
445 }
446
448 {
449 std::vector<const GlobalVectorType *> av_set_transfer =
450 this->average_velocities->save(prefix);
451
452 // Insert average velocities vectors into the set transfer vector
453 sol_set_transfer.insert(sol_set_transfer.end(),
454 av_set_transfer.begin(),
455 av_set_transfer.end());
456 }
457
458 // Prepare for Serialization
459 SolutionTransfer<dim, GlobalVectorType> system_trans_vectors(
460 *this->dof_handler);
461 system_trans_vectors.prepare_for_serialization(sol_set_transfer);
462
463 // Void Fraction
464 std::vector<const GlobalVectorType *> vf_set_transfer;
465 vf_set_transfer.push_back(
466 &(*this->particle_projector.void_fraction_locally_relevant));
467 for (unsigned int i = 0;
468 i < this->particle_projector.previous_void_fraction->size();
469 ++i)
470 {
471 vf_set_transfer.push_back(
472 &this->particle_projector.previous_void_fraction->at(i));
473 }
474
475 this->multiphysics->write_checkpoint();
476
477 // Prepare for Serialization
478 SolutionTransfer<dim, GlobalVectorType> vf_system_trans_vectors(
479 *this->particle_projector.dof_handler);
480 vf_system_trans_vectors.prepare_for_serialization(vf_set_transfer);
481
482 if (auto parallel_triangulation =
483 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
484 &*this->triangulation))
485 {
486 parallel_triangulation->save(prefix + ".triangulation");
487 }
488 // Serialize all post-processing tables that are currently used
489 // Serialize the post-processing tables that are additional in this solver
490 const std::vector<OutputStructTableHandler> &table_output_structs_add =
491 this->gather_tables();
492 serialize_tables_vector(table_output_structs_add, this->mpi_communicator);
493 // Serialize the default post-processing tables that are members of
494 // NavierStokesBase
495 const std::vector<OutputStructTableHandler> &table_output_structs =
497 serialize_tables_vector(table_output_structs, this->mpi_communicator);
498}
499
500template <int dim, typename PropertiesIndex>
501void
503{
504 TimerOutput::Scope timer(this->computing_timer, "Read checkpoint");
505 std::string prefix =
506 this->simulation_parameters.simulation_control.output_folder +
507 this->simulation_parameters.restart_parameters.filename;
508 std::string prefix_particles = prefix + "_particles";
509 std::string prefix_grid = prefix + "_lagrangian_postprocessing";
510
511 this->simulation_control->read(prefix);
512 this->pvdhandler.read(prefix);
513 particles_pvdhandler.read(prefix_particles);
514
515 if (this->dem_parameters.post_processing.lagrangian_post_processing_enabled)
516 {
517 grid_pvdhandler.read(prefix_grid);
518 }
519
520 // Gather particle serialization information
521 std::string particle_filename = prefix + ".particles";
522 check_file_exists(particle_filename,
523 "checkpoint file of the particles, given by "
524 "'subsection restart' - 'set filename'");
525 std::ifstream input(particle_filename.c_str());
526
527 std::string buffer;
528 std::getline(input, buffer);
529 std::istringstream iss(buffer);
530 boost::archive::text_iarchive ia(iss, boost::archive::no_header);
531
532 ia >> this->particle_handler;
533
534 // Load the insertion object. Checkpoints written before the insertion object
535 // was checkpointed in CFD-DEM simulations do not contain this file. In that
536 // case, the insertion object keeps the state it was initialized with.
537 std::string insertion_object_filename = prefix + ".insertion_object";
538 if (std::filesystem::exists(insertion_object_filename))
539 {
540 std::ifstream iss_insertion_obj(insertion_object_filename);
541 boost::archive::text_iarchive ia_insertion_obj(iss_insertion_obj,
542 boost::archive::no_header);
543 insertion_object->deserialize(ia_insertion_obj);
544 }
545
546 const std::string filename = prefix + ".triangulation";
547 check_file_exists(filename,
548 "checkpoint file of the triangulation, given by "
549 "'subsection restart' - 'set filename'");
550
551 try
552 {
553 if (auto parallel_triangulation =
554 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
555 this->triangulation.get()))
556 parallel_triangulation->load(filename.c_str());
557 }
558 catch (...)
559 {
560 AssertThrow(false,
561 ExcMessage("Cannot open snapshot mesh file or read the "
562 "triangulation stored there."));
563 }
564
565 this->setup_dofs();
566
567 // TODO BB
568 // Remap periodic nodes after setup of dofs
569 if (dem_action_manager->check_periodic_boundaries_enabled() &&
570 dem_action_manager->check_sparse_contacts_enabled())
571 {
572 sparse_contacts_object.map_periodic_nodes(
573 this->particle_projector.void_fraction_constraints);
574 }
575
576 // Velocity Vectors
577 std::vector<GlobalVectorType *> x_system(1 +
578 this->previous_solutions->size());
579
580 GlobalVectorType distributed_system(this->locally_owned_dofs,
581 this->mpi_communicator);
582
583 x_system[0] = &(distributed_system);
584
585 std::vector<GlobalVectorType> distributed_previous_solutions;
586
587 distributed_previous_solutions.reserve(this->previous_solutions->size());
588
589 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
590 {
591 distributed_previous_solutions.emplace_back(
593 x_system[i + 1] = &distributed_previous_solutions[i];
594 }
595
596 SolutionTransfer<dim, GlobalVectorType> system_trans_vectors(
597 *this->dof_handler);
598
600 {
601 std::vector<GlobalVectorType *> sum_vectors =
602 this->average_velocities->read(prefix);
603
604 x_system.insert(x_system.end(), sum_vectors.begin(), sum_vectors.end());
605 }
606
607 system_trans_vectors.deserialize(x_system);
608
609 *this->present_solution = distributed_system;
610 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
611 {
612 (*this->previous_solutions)[i] = distributed_previous_solutions[i];
613 }
614
616
617 // Void Fraction Vectors
618 std::vector<GlobalVectorType *> vf_system(
619 1 + this->particle_projector.previous_void_fraction->size());
620
621 GlobalVectorType vf_distributed_system(
622 this->particle_projector.locally_owned_dofs, this->mpi_communicator);
623
624 vf_system[0] = &(vf_distributed_system);
625
626 std::vector<GlobalVectorType> vf_distributed_previous_solutions;
627
628 vf_distributed_previous_solutions.reserve(
629 this->particle_projector.previous_void_fraction->size());
630
631 for (unsigned int i = 0;
632 i < this->particle_projector.previous_void_fraction->size();
633 ++i)
634 {
635 vf_distributed_previous_solutions.emplace_back(
636 GlobalVectorType(this->particle_projector.locally_owned_dofs,
637 this->mpi_communicator));
638 vf_system[i + 1] = &vf_distributed_previous_solutions[i];
639 }
640
641 SolutionTransfer<dim, GlobalVectorType> vf_system_trans_vectors(
642 *this->particle_projector.dof_handler);
643
644 vf_system_trans_vectors.deserialize(vf_system);
645
646 *this->particle_projector.void_fraction_locally_relevant =
647 vf_distributed_system;
648 for (unsigned int i = 0;
649 i < this->particle_projector.previous_void_fraction->size();
650 ++i)
651 {
652 this->particle_projector.previous_void_fraction->at(i) =
653 vf_distributed_previous_solutions[i];
654 }
655
656 if (this->simulation_parameters.flow_control.enable_flow_control)
657 {
658 this->flow_control.read(prefix);
659 }
660
661 this->multiphysics->read_checkpoint();
662
663 // Deserialize particles have the triangulation has been read
664 this->particle_handler.deserialize();
665
666 // Deserialize all post-processing tables that are currently used
667 // Deserialize the post-processing tables that are particular to this solver
668 std::vector<OutputStructTableHandler> table_output_structs_add =
669 this->gather_tables();
670 deserialize_tables_vector(table_output_structs_add, this->mpi_communicator);
671
672 // Deserialize the default post-processing tables that are members of
673 // NavierStokesBase
674 std::vector<OutputStructTableHandler> table_output_structs =
676 deserialize_tables_vector(table_output_structs, this->mpi_communicator);
677}
678
679template <int dim, typename PropertiesIndex>
680void
682 unsigned int counter)
683{
684 // Use namespace and alias to make the code more readable
685 using namespace Parameters::Lagrangian;
687 dem_parameters.model_parameters;
688
689 switch (model_parameters.contact_detection_method)
690 {
692 {
693 if ((counter % model_parameters.contact_detection_frequency) == 0)
694 dem_action_manager->contact_detection_step();
695 break;
696 }
698 {
699 double dt =
700 this->simulation_control->get_time_step() /
701 this->cfd_dem_simulation_parameters.cfd_dem.coupling_frequency;
702
704 this->particle_handler,
705 dt,
707 this->mpi_communicator,
709 break;
710 }
711 default:
712 break;
713 }
714}
715
716template <int dim, typename PropertiesIndex>
717void
719{
720 load_balancing.check_load_balance_iteration();
721
722 // If not a load balance iteration, exit the function
723 if (!dem_action_manager->check_load_balance())
724 return;
725
726 std::vector<const GlobalVectorType *> sol_set_transfer;
727 sol_set_transfer.push_back(&(*this->present_solution));
728 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
729 {
730 sol_set_transfer.push_back(&(*this->previous_solutions)[i]);
731 }
732
733 // Prepare for Serialization
734 SolutionTransfer<dim, GlobalVectorType> system_trans_vectors(
735 *this->dof_handler);
736 system_trans_vectors.prepare_for_coarsening_and_refinement(sol_set_transfer);
737
738 // The time-averaged velocity accumulators live on the fluid dof handler and
739 // must be transferred to the new partition as well. Otherwise the setup_dofs
740 // below resets them to zero while the total averaging time keeps spanning
741 // the whole averaging window, which makes the average velocity and the
742 // Reynolds stresses decay towards zero at every load balance.
744 this->average_velocities->prepare_for_mesh_adaptation();
745
746 // Void Fraction
747 std::vector<const GlobalVectorType *> vf_set_transfer;
748 vf_set_transfer.push_back(
749 &(*this->particle_projector.void_fraction_locally_relevant));
750 for (unsigned int i = 0;
751 i < this->particle_projector.previous_void_fraction->size();
752 ++i)
753 {
754 vf_set_transfer.push_back(
755 &this->particle_projector.previous_void_fraction->at(i));
756 }
757
758 // Prepare for Serialization
759 SolutionTransfer<dim, GlobalVectorType> vf_system_trans_vectors(
760 *this->particle_projector.dof_handler);
761 vf_system_trans_vectors.prepare_for_coarsening_and_refinement(
762 vf_set_transfer);
763
764 // Prepare particle handle for serialization
765 this->particle_handler.prepare_for_coarsening_and_refinement();
766
767 this->pcout << "-->Repartitioning triangulation" << std::endl;
768
769 const auto parallel_triangulation =
770 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
771 &*this->triangulation);
772
773 parallel_triangulation->repartition();
774
775 // If PBC are enabled remap periodic cells
776 periodic_boundaries_object.map_periodic_cells(
777 *parallel_triangulation, periodic_boundaries_cells_information);
778
779 // Update cell neighbors
780 contact_manager.update_cell_neighbors(*parallel_triangulation,
782
784 *parallel_triangulation,
785 dem_parameters.floating_walls,
786 dem_parameters.boundary_conditions.outlet_boundaries,
787 this->cfd_dem_simulation_parameters.cfd_parameters.mesh
788 .check_for_diamond_cells,
789 this->cfd_dem_simulation_parameters.cfd_parameters.mesh
790 .expand_particle_wall_contact_search,
791 this->pcout);
792
793 const auto average_minimum_maximum_cells =
794 Utilities::MPI::min_max_avg(parallel_triangulation->n_active_cells(),
795 this->mpi_communicator);
796
797 const auto average_minimum_maximum_particles = Utilities::MPI::min_max_avg(
798 this->particle_handler.n_locally_owned_particles(), this->mpi_communicator);
799
800 this->pcout << "Load balance finished" << std::endl;
801 this->pcout
802 << "Average, minimum and maximum number of particles on the processors are "
803 << average_minimum_maximum_particles.avg << " , "
804 << average_minimum_maximum_particles.min << " and "
805 << average_minimum_maximum_particles.max << std::endl;
806 this->pcout
807 << "Minimum and maximum number of cells owned by the processors are "
808 << average_minimum_maximum_cells.min << " and "
809 << average_minimum_maximum_cells.max << std::endl;
810
811 this->pcout << "Setup DOFs" << std::endl;
812 this->setup_dofs();
813
814 // TODO BB
815 // Remap periodic nodes after setup of dofs
816 if (dem_action_manager->check_periodic_boundaries_enabled() &&
817 dem_action_manager->check_sparse_contacts_enabled())
818 {
819 sparse_contacts_object.map_periodic_nodes(
820 this->particle_projector.void_fraction_constraints);
821 }
822
823 // Update the local and ghost cells (if ASC enabled)
824 sparse_contacts_object.update_local_and_ghost_cell_set(
825 *this->particle_projector.dof_handler);
826
827 // Velocity Vectors
828 std::vector<GlobalVectorType *> x_system(1 +
829 this->previous_solutions->size());
830
831 GlobalVectorType distributed_system(this->locally_owned_dofs,
832 this->mpi_communicator);
833
834 x_system[0] = &(distributed_system);
835
836 std::vector<GlobalVectorType> distributed_previous_solutions;
837
838 distributed_previous_solutions.reserve(this->previous_solutions->size());
839
840 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
841 {
842 distributed_previous_solutions.emplace_back(
844 x_system[i + 1] = &distributed_previous_solutions[i];
845 }
846
847 system_trans_vectors.interpolate(x_system);
848
849 *this->present_solution = distributed_system;
850 for (unsigned int i = 0; i < this->previous_solutions->size(); ++i)
851 {
852 (*this->previous_solutions)[i] = distributed_previous_solutions[i];
853 }
854
855 // Restore the time-averaged velocity accumulators on the new partition. This
856 // also reevaluates the average velocity and the Reynolds stresses from the
857 // transferred sums.
859 this->average_velocities->post_mesh_adaptation();
860
861 x_system.clear();
862
863 // Void Fraction Vectors
864 std::vector<GlobalVectorType *> vf_system(
865 1 + this->particle_projector.previous_void_fraction->size());
866
867 GlobalVectorType vf_distributed_system(
868 this->particle_projector.locally_owned_dofs, this->mpi_communicator);
869
870 vf_system[0] = &(vf_distributed_system);
871
872 std::vector<GlobalVectorType> vf_distributed_previous_solutions;
873
874 vf_distributed_previous_solutions.reserve(
875 this->particle_projector.previous_void_fraction->size());
876
877 for (unsigned int i = 0;
878 i < this->particle_projector.previous_void_fraction->size();
879 ++i)
880 {
881 vf_distributed_previous_solutions.emplace_back(
882 GlobalVectorType(this->particle_projector.locally_owned_dofs,
883 this->mpi_communicator));
884 vf_system[i + 1] = &vf_distributed_previous_solutions[i];
885 }
886
887 vf_system_trans_vectors.interpolate(vf_system);
888
889 *this->particle_projector.void_fraction_locally_relevant =
890 vf_distributed_system;
891 for (unsigned int i = 0;
892 i < this->particle_projector.previous_void_fraction->size();
893 ++i)
894 {
895 this->particle_projector.previous_void_fraction->at(i) =
896 vf_distributed_previous_solutions[i];
897 }
898
899 vf_system.clear();
900
901 // Unpack particle handler after load balancing step
902 this->particle_handler.unpack_after_coarsening_and_refinement();
903
904 // Regenerate vertex to cell map
905 this->vertices_cell_mapping();
906}
907
908template <int dim, typename PropertiesIndex>
909void
911{
912 for (auto particle = this->particle_handler.begin();
913 particle != this->particle_handler.end();
914 ++particle)
915 {
916 auto particle_properties = particle->get_properties();
917
918 types::particle_index particle_id = particle->get_local_index();
919
920 force[particle_id][0] +=
921 particle_properties[PropertiesIndex::fem_force_two_way_coupling_x] +
922 particle_properties[PropertiesIndex::fem_force_one_way_coupling_x] +
923 particle_properties[PropertiesIndex::fem_drag_x];
924 force[particle_id][1] +=
925 particle_properties[PropertiesIndex::fem_force_two_way_coupling_y] +
926 particle_properties[PropertiesIndex::fem_force_one_way_coupling_y] +
927 particle_properties[PropertiesIndex::fem_drag_y];
928 force[particle_id][2] +=
929 particle_properties[PropertiesIndex::fem_force_two_way_coupling_z] +
930 particle_properties[PropertiesIndex::fem_force_one_way_coupling_z] +
931 particle_properties[PropertiesIndex::fem_drag_z];
932 }
933}
934
935template <int dim, typename PropertiesIndex>
936void
938{
939 for (auto particle = this->particle_handler.begin();
940 particle != this->particle_handler.end();
941 ++particle)
942 {
943 auto particle_properties = particle->get_properties();
944
945 types::particle_index particle_id = particle->get_local_index();
946
947 torque[particle_id][0] +=
948 particle_properties[PropertiesIndex::fem_torque_x];
949 torque[particle_id][1] +=
950 particle_properties[PropertiesIndex::fem_torque_y];
951 torque[particle_id][2] +=
952 particle_properties[PropertiesIndex::fem_torque_z];
953 }
954}
955
956template <int dim, typename PropertiesIndex>
957void
959{
960 // If the insertion frequency is set to 0, then no particles are going
961 // to be inserted in the CFD-DEM simulation and the function returns
962 if (dem_parameters.insertion_info.insertion_frequency == 0)
963 return;
964
965 const auto parallel_triangulation =
966 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
967 &*this->triangulation);
968 if ((this->simulation_control->get_iteration_number() %
969 dem_parameters.insertion_info.insertion_frequency) == 1 ||
970 this->simulation_control->get_iteration_number() == 1)
971 {
973 *parallel_triangulation,
975
976 dem_action_manager->particle_insertion_step();
977
978 // Sort particles after insertion
980 }
981}
982
983template <int dim, typename PropertiesIndex>
984void
986{
987 const double dem_time_step = dem_simulation_control->get_time_step();
988 // Particle-wall contact force
989 particle_wall_contact_force_object->calculate_particle_wall_contact(
990 contact_manager.get_particle_wall_in_contact(),
991 dem_time_step,
993
994 // Particle-floating wall contact force
995 if (dem_parameters.floating_walls.floating_walls_number > 0)
996 {
997 particle_wall_contact_force_object->calculate_particle_wall_contact(
998 contact_manager.get_particle_floating_wall_in_contact(),
999 dem_time_step,
1001 }
1002
1004 .calculate_particle_point_contact_force(
1005 &contact_manager.get_particle_points_in_contact(),
1006 dem_parameters.lagrangian_physical_properties,
1007 force);
1008
1009 if constexpr (dim == 3)
1010 {
1012 .calculate_particle_line_contact_force(
1013 &contact_manager.get_particle_lines_in_contact(),
1014 dem_parameters.lagrangian_physical_properties,
1015 force);
1016 }
1017}
1018
1019template <int dim, typename PropertiesIndex>
1020void
1022{
1023 const std::string folder = dem_parameters.simulation_control.output_folder;
1024 const std::string particles_solution_name =
1025 dem_parameters.simulation_control.output_name + "_particles";
1026 const unsigned int iter = this->simulation_control->get_iteration_number();
1027 const double time = this->simulation_control->get_current_time();
1028 const unsigned int group_files =
1029 dem_parameters.simulation_control.group_files;
1030
1031 // Write particles
1032 Visualization<dim, PropertiesIndex> particle_data_out;
1033 particle_data_out.build_patches(this->particle_handler,
1034 properties_class.get_properties_name());
1035
1037 particle_data_out,
1038 folder,
1039 particles_solution_name,
1040 time,
1041 iter,
1042 group_files,
1043 this->mpi_communicator);
1044}
1045
1046template <int dim, typename PropertiesIndex>
1047void
1049{
1050 // Update statistics on contact list
1051 double number_of_list_built_since_last_log =
1053 contact_list.max =
1054 std::max(number_of_list_built_since_last_log, contact_list.max);
1055 contact_list.min =
1056 std::min(number_of_list_built_since_last_log, contact_list.min);
1058 contact_list.average = contact_list.total /
1059 (this->simulation_control->get_iteration_number()) *
1060 this->simulation_control->get_log_frequency();
1061
1062 // Calculate statistics on the particles
1064 dim,
1065 PropertiesIndex,
1067 this->particle_handler, this->mpi_communicator);
1069 dim,
1070 PropertiesIndex,
1072 this->particle_handler, this->mpi_communicator);
1075 PropertiesIndex,
1077 this->particle_handler, this->mpi_communicator);
1080 PropertiesIndex,
1082 this->particle_handler, this->mpi_communicator);
1083
1084 if (this_mpi_process == 0)
1085 {
1086 TableHandler report;
1087
1088 std::vector<std::string> column_names{
1089 "Variable", "Min", "Max", "Average", "Total"};
1090
1091 for (const std::string &column_name : column_names)
1092 report.declare_column(column_name);
1093
1094 add_statistics_to_table_handler("Contact list generation",
1096 report);
1097 add_statistics_to_table_handler("Velocity magnitude", velocity, report);
1098 add_statistics_to_table_handler("Angular velocity magnitude",
1099 omega,
1100 report);
1101 add_statistics_to_table_handler("Translational kinetic energy",
1103 report);
1104 add_statistics_to_table_handler("Rotational kinetic energy",
1106 report);
1107
1108 // Only for Min, Max, Average and Total columns
1109 for (unsigned int i = 1; i < column_names.size(); ++i)
1110 {
1111 report.set_scientific(column_names[i], true);
1112 report.set_precision(column_names[i],
1113 this->simulation_control->get_log_precision());
1114 }
1115
1116 announce_string(this->pcout, "Particle statistics");
1117 report.write_text(std::cout, dealii::TableHandler::org_mode_table);
1118 }
1119
1120 if (dem_parameters.post_processing.lagrangian_post_processing_enabled &&
1121 this->simulation_control->is_output_iteration())
1122 {
1123 const auto parallel_triangulation =
1124 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
1125 &*this->triangulation);
1126
1128 *parallel_triangulation,
1130 *this->dof_handler,
1131 this->particle_handler,
1133 this->simulation_control->get_current_time(),
1134 this->simulation_control->get_iteration_number(),
1135 this->mpi_communicator,
1137 }
1138}
1139
1140template <int dim, typename PropertiesIndex>
1141void
1143{
1144 const int display_width = this->simulation_control->get_log_precision() + 8;
1145 this->pcout << "Particle Summary" << std::endl;
1146
1147 this->pcout << std::setw(display_width) << std::left << "id, "
1148 << std::setw(display_width) << std::left << "x, "
1149 << std::setw(display_width) << std::left << "y, "
1150 << std::setw(display_width) << std::left << "z, "
1151 << std::setw(display_width) << std::left << "v_x, "
1152 << std::setw(display_width) << std::left << "v_y, "
1153 << std::setw(display_width) << std::left << "v_z";
1155 {
1156 this->pcout << ", " << std::setw(display_width) << std::left << "T";
1157 }
1158 this->pcout << std::endl;
1159 // Aggressively force synchronization of the header line
1160 usleep(500);
1161 MPI_Barrier(this->mpi_communicator);
1162 usleep(500);
1163 MPI_Barrier(this->mpi_communicator);
1164
1165 std::map<int, Particles::ParticleIterator<dim>> global_particles;
1166 unsigned int current_id, current_id_max = 0;
1167
1168 // Mapping of all particles & find the max id on current processor
1169 for (auto particle = this->particle_handler.begin();
1170 particle != this->particle_handler.end();
1171 ++particle)
1172 {
1173 current_id = particle->get_id();
1174 current_id_max = std::max(current_id, current_id_max);
1175
1176 global_particles.insert({current_id, particle});
1177 }
1178
1179 // Find global max particle index
1180 unsigned int id_max =
1181 Utilities::MPI::max(current_id_max, this->mpi_communicator);
1182
1183 for (unsigned int i = 0; i <= id_max; i++)
1184 {
1185 for (auto &iterator : global_particles)
1186 {
1187 unsigned int id = iterator.first;
1188 if (id == i)
1189 {
1190 auto particle = iterator.second;
1191 auto particle_properties = particle->get_properties();
1192 auto particle_location = particle->get_location();
1193
1194 std::cout << std::setw(display_width) << std::left << id;
1195 for (int d = 0; d < dim; ++d)
1196 std::cout << std::setw(display_width) << std::left
1197 << particle_location[d];
1198 std::cout << std::setw(display_width) << std::left
1199 << particle_properties[PropertiesIndex::v_x]
1200 << std::setw(display_width) << std::left
1201 << particle_properties[PropertiesIndex::v_y]
1202 << std::setw(display_width) << std::left
1203 << particle_properties[PropertiesIndex::v_z];
1205 {
1206 std::cout << std::setw(display_width) << std::left
1207 << particle_properties[PropertiesIndex::T];
1208 }
1209 std::cout << std::endl;
1210 }
1211 }
1212 usleep(500);
1213 MPI_Barrier(this->mpi_communicator);
1214 }
1215}
1216
1217template <int dim, typename PropertiesIndex>
1218void
1220{
1221 this->FluidDynamicsMatrixBased<dim>::postprocess_fd(first_iteration);
1222
1223 // Visualization
1224 if (this->simulation_control->is_output_iteration())
1225 {
1227 }
1228 if (!first_iteration)
1229 {
1230 this->pcout
1231 << "---------------------------------------------------------------"
1232 << std::endl;
1233 }
1234}
1235
1236template <int dim, typename PropertiesIndex>
1237void
1239{
1240 // Calculate total volume of fluid and solid
1241 if (this->simulation_parameters.post_processing.calculate_phase_volumes)
1242 {
1243 TimerOutput::Scope t(this->computing_timer, "total_volume_calculation");
1244 double total_volume_fluid, total_volume_particles;
1245 std::tie(total_volume_fluid, total_volume_particles) =
1247 *this->particle_projector.dof_handler,
1248 *this->particle_projector.void_fraction_locally_relevant,
1249 *this->cell_quadrature,
1250 *this->mapping);
1251 this->table_phase_volumes.add_value(
1252 "time", this->simulation_control->get_current_time());
1253 this->table_phase_volumes.add_value("total-volume-fluid",
1254 total_volume_fluid);
1255 this->table_phase_volumes.add_value("total-volume-particles",
1256 total_volume_particles);
1257 if (this->simulation_parameters.post_processing.verbosity ==
1259 {
1260 this->pcout << "Total volume of fluid: "
1261 << this->simulation_parameters.physical_properties_manager
1262 .get_density_scale() *
1263 total_volume_fluid
1264 << " m^3" << std::endl;
1265 this->pcout << "Total volume of particles: "
1266 << this->simulation_parameters.physical_properties_manager
1267 .get_density_scale() *
1268 total_volume_particles
1269 << " m^3" << std::endl;
1270 }
1271
1272 // Output pressure drop to a text file from processor 0
1273 if ((this->simulation_control->get_iteration_number() %
1274 this->simulation_parameters.post_processing.output_frequency ==
1275 0) &&
1276 this->this_mpi_process == 0)
1277 {
1278 std::string filename =
1279 this->simulation_parameters.simulation_control.output_folder +
1280 this->simulation_parameters.post_processing
1281 .phase_volumes_output_name +
1282 ".dat";
1283 std::ofstream output(filename.c_str());
1284 table_phase_volumes.set_precision("time", 12);
1285 table_phase_volumes.set_precision("total-volume-fluid", 12);
1286 table_phase_volumes.set_precision("total-volume-particles", 12);
1287 this->table_phase_volumes.write_text(output);
1288 }
1289 }
1290}
1291
1292template <int dim, typename PropertiesIndex>
1293void
1295{
1296 if (this->simulation_parameters.flow_control.enable_flow_control &&
1297 this->simulation_parameters.simulation_control.method !=
1299 {
1300 // Calculate the average velocity according to the void fraction
1301 unsigned int flow_direction =
1302 this->simulation_parameters.flow_control.flow_direction;
1303 double average_velocity = calculate_average_velocity(
1304 *this->dof_handler,
1305 *this->particle_projector.dof_handler,
1306 *this->present_solution,
1307 *this->particle_projector.void_fraction_locally_relevant,
1308 flow_direction,
1309 *this->cell_quadrature,
1310 *this->mapping);
1311
1312 // Calculate the beta force for fluid
1313 this->flow_control.calculate_beta(
1314 average_velocity,
1315 this->simulation_control->get_time_step(),
1316 this->simulation_control->get_iteration_number());
1317
1318 Tensor<1, 3> beta_particle;
1319 if (this->simulation_parameters.flow_control.enable_beta_particle)
1320 {
1321 // Calculate the beta for particles and add it to force tensor g
1322 AssertThrow(
1323 dem_parameters.lagrangian_physical_properties
1324 .particle_type_number == 1,
1325 ExcMessage(std::string(
1326 "Beta force calculation for particles is not implemented for multiple particle types.")));
1327
1328 double fluid_density =
1329 this->simulation_parameters.physical_properties_manager
1330 .get_density_scale();
1331 double particle_density =
1332 dem_parameters.lagrangian_physical_properties.density_particle[0];
1333 beta_particle =
1334 this->flow_control.get_beta_particles(fluid_density,
1335 particle_density);
1336 g = dem_parameters.lagrangian_physical_properties.g + beta_particle;
1337 }
1338
1339 // Showing results
1340 if (this->simulation_parameters.flow_control.verbosity ==
1342 this->simulation_control->get_iteration_number() > 0 &&
1343 this->this_mpi_process == 0)
1344 {
1345 announce_string(this->pcout, "Flow control summary");
1346 this->pcout << "Fluid space-average velocity: " << average_velocity
1347 << std::endl;
1348 this->pcout << "Fluid beta force: "
1349 << this->flow_control.get_beta()[flow_direction]
1350 << std::endl;
1351 this->pcout << "Particle beta force: "
1352 << beta_particle[flow_direction] << std::endl;
1353 }
1354 }
1355}
1356
1357template <int dim, typename PropertiesIndex>
1358inline void
1360{
1361 this->particle_handler.sort_particles_into_subdomains_and_cells();
1362
1363 // Exchange ghost particles
1364 this->particle_handler.exchange_ghost_particles(true);
1365
1366 // Resize the displacement, force and torque containers only if the particles
1367 // have changed subdomains
1368 if (dem_action_manager->check_resize_containers())
1369 {
1370 unsigned int number_of_particles =
1371 this->particle_handler.get_max_local_particle_index();
1372 // Resize displacement container
1373 displacement.resize(number_of_particles);
1374 // Resize outcome containers
1375 contact_outcome.resize_interaction_containers(number_of_particles);
1376 MOI.resize(number_of_particles);
1377
1378 // Updating moment of inertia container
1379 for (auto &particle : this->particle_handler)
1380 {
1381 auto particle_properties = particle.get_properties();
1382 MOI[particle.get_local_index()] =
1383 0.1 * particle_properties[PropertiesIndex::mass] *
1384 particle_properties[PropertiesIndex::dp] *
1385 particle_properties[PropertiesIndex::dp];
1386 }
1387 }
1388
1389 // Always reset the displacement values since we are doing a search detection
1390 std::ranges::fill(displacement, 0.);
1391
1392 this->particle_handler.exchange_ghost_particles(true);
1393}
1394
1395template <int dim, typename PropertiesIndex>
1396void
1398{
1399 const unsigned int counter = dem_simulation_control->get_iteration();
1400 const double dem_time_step = dem_simulation_control->get_time_step();
1401
1402 // dem_contact_build carries out the particle-particle and particle-wall
1403 // broad and fine searches, sort_particles_into_subdomains_and_cells, and
1404 // exchange_ghost
1406
1407 // Particle-particle contact force
1408 particle_particle_contact_force_object->calculate_particle_particle_contact(
1409 contact_manager.get_local_adjacent_particles(),
1410 contact_manager.get_ghost_adjacent_particles(),
1411 contact_manager.get_local_local_periodic_adjacent_particles(),
1412 contact_manager.get_local_ghost_periodic_adjacent_particles(),
1413 contact_manager.get_ghost_local_periodic_adjacent_particles(),
1414 dem_time_step,
1416
1417 // Particles-walls contact force:
1419
1420 // Integration of the temperature of the particles for the multiphysic DEM.
1421 // The heat source is zero since the fluid does not exchange heat with the
1422 // particles yet.
1424 {
1426 this->particle_handler,
1427 dem_time_step,
1428 contact_outcome.heat_transfer_rate,
1429 std::vector<double>(contact_outcome.force.size()));
1430
1431 // Update the temperature of the walls of the grid for the next DEM
1432 // iteration. The counter first iteration starts at 1 so the time is given
1433 // by the previous time (of the cfd) plus the counter times the DEM time
1434 // step.
1436 this->cfd_dem_simulation_parameters.dem_parameters.boundary_conditions,
1437 this->simulation_control->get_previous_time() +
1438 counter * dem_time_step);
1439 }
1440
1441 // Add fluid-particle interaction force to the force container
1443
1444 // Add fluid-particle interaction torque to the torque container
1445 if (this->cfd_dem_simulation_parameters.cfd_dem.rotational_viscous_torque ||
1446 this->cfd_dem_simulation_parameters.cfd_dem.vortical_viscous_torque)
1448
1449 // The cell average velocities and accelerations are updated
1450 // from the fully computed forces at step 0, but we do not use the
1451 // mobility status to disabled contacts at this step. The reason
1452 // is that the current mobility status are computed for the last
1453 // DEM time step (from the last CFD time step) are the force of
1454 // the fluid may have significantly changed the particulate
1455 // agitation.
1456 // Update the cell average velocities and accelerations
1457 sparse_contacts_object.update_average_velocities_acceleration(
1458 this->particle_handler, g, force, dem_time_step);
1459
1460 // Integration correction step (after force calculation).
1461 // Since the velocities are synchronized with the positions at the end of
1462 // every CFD time step (see synchronize_particle_velocities), the first DEM
1463 // sub-iteration of every CFD time step is an opening step, which lets the
1464 // scheme restart its staggering if it has one.
1465 if (dem_simulation_control->is_first_iteration())
1466 {
1467 integrator_object->integrate_start(
1468 this->particle_handler, g, dem_time_step, torque, force, MOI);
1469 }
1470 else
1471 {
1472 const auto parallel_triangulation =
1473 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
1474 &*this->triangulation);
1475 integrator_object->integrate(this->particle_handler,
1476 g,
1477 dem_time_step,
1478 torque,
1479 force,
1480 MOI,
1481 *parallel_triangulation,
1483 }
1484
1485 // Log the contact statistics if the parameter is enabled
1486 if (dem_parameters.post_processing.particle_wall_collision_statistics)
1487 {
1488 const double dem_current_time =
1489 (this->simulation_control->get_current_time()) +
1490 (dem_time_step * dem_simulation_control->get_iteration());
1491
1494 contact_manager.get_particle_wall_in_contact(),
1495 dem_current_time,
1498 }
1499
1500 dem_action_manager->reset_triggers();
1501}
1502
1503template <int dim, typename PropertiesIndex>
1504void
1506{
1507 const double dem_time_step = dem_simulation_control->get_time_step();
1508
1509 // The particles have reached their final position for this CFD time step, but
1510 // their velocities are still lagging by half a DEM time step. The forces are
1511 // re-evaluated at this final position so that the closing half velocity step
1512 // can be applied. No contact search is carried out: the contact lists built
1513 // at the last DEM sub-iteration are exactly as valid here as they are for any
1514 // sub-iteration that does not trigger a search, and only the ghost particles
1515 // need to be updated.
1516 this->particle_handler.update_ghost_particles();
1517
1518 // Particle-particle contact force
1519 particle_particle_contact_force_object->calculate_particle_particle_contact(
1520 contact_manager.get_local_adjacent_particles(),
1521 contact_manager.get_ghost_adjacent_particles(),
1522 contact_manager.get_local_local_periodic_adjacent_particles(),
1523 contact_manager.get_local_ghost_periodic_adjacent_particles(),
1524 contact_manager.get_ghost_local_periodic_adjacent_particles(),
1525 dem_time_step,
1527
1528 // Particles-walls contact force
1530
1531 // The heat transfer rate accumulated by the contact force objects is
1532 // discarded. The temperature is not integrated by the closing half step,
1533 // since it is not staggered and has already been advanced to the final time
1534 // by the last DEM sub-iteration. Leaving the container filled would leak
1535 // this heat transfer rate into the temperature integration of the next CFD
1536 // time step, which would then be counted twice.
1538 std::ranges::fill(contact_outcome.heat_transfer_rate, 0.);
1539
1540 // Add fluid-particle interaction force to the force container
1542
1543 // Add fluid-particle interaction torque to the torque container
1544 if (this->cfd_dem_simulation_parameters.cfd_dem.rotational_viscous_torque ||
1545 this->cfd_dem_simulation_parameters.cfd_dem.vortical_viscous_torque)
1547
1548 const auto parallel_triangulation =
1549 dynamic_cast<parallel::distributed::Triangulation<dim> *>(
1550 &*this->triangulation);
1551 integrator_object->integrate_end(this->particle_handler,
1552 g,
1553 dem_time_step,
1554 torque,
1555 force,
1556 MOI,
1557 *parallel_triangulation,
1559
1560 dem_action_manager->reset_triggers();
1561}
1562
1563template <int dim, typename PropertiesIndex>
1564void
1566{
1567 const unsigned int counter = dem_simulation_control->get_iteration();
1568
1569 // If this is not the last DEM iteration before the next CFD iteration, check
1570 // if a contact detection step is necessary
1571 if (!this->dem_simulation_control->is_last_iteration())
1573
1574 // Otherwise, force a contact search at the last DEM iteration before a CFD
1575 // iteration to ensure that the particles are adequately located before
1576 // calculating the coupling between particle and fluid.
1577 else
1578 dem_action_manager->last_dem_of_cfddem_iteration_step();
1579
1580 // Sort particles in cells
1581 if (dem_action_manager->check_contact_search())
1582 {
1583 this->pcout << "DEM contact search at dem step " << counter << std::endl;
1585
1586 // Execute periodic boundaries (if PBC enabled)
1587 periodic_boundaries_object.execute_particles_displacement(
1589
1590 // Sort particles into subdomains and cells and reset the vectors that
1591 // the local particle if is their index
1593
1594 // Identify the mobility status of particles (if ASC enabled)
1595 sparse_contacts_object.identify_mobility_status(
1596 *this->particle_projector.dof_handler,
1597 this->particle_handler,
1598 (*this->triangulation).n_active_cells(),
1599 this->mpi_communicator);
1600
1601 // Execute broad search by filling containers of particle-particle
1602 // contact pair candidates and containers of particle-wall
1603 // contact pair candidates
1604 contact_manager.execute_particle_particle_broad_search(
1606
1607 contact_manager.execute_particle_wall_broad_search(
1608 this->particle_handler,
1611 dem_parameters.floating_walls,
1612 this->simulation_control->get_current_time(),
1614
1615 // Update contacts, remove replicates and add new contact pairs
1616 // to the contact containers when particles are exchanged between
1617 // processors
1618 contact_manager.update_contacts();
1619
1620 // Updates the iterators to particles in local-local contact
1621 // containers
1622 contact_manager.update_local_particles_in_cells(this->particle_handler);
1623
1624 // Execute fine search by updating particle-particle contact
1625 // containers regards the neighborhood threshold
1626 contact_manager.execute_particle_particle_fine_search(
1628
1629 // Execute fine search by updating particle-wall contact containers
1630 // regards the neighborhood threshold
1631 contact_manager.execute_particle_wall_fine_search(
1632 dem_parameters.floating_walls,
1633 this->simulation_control->get_current_time(),
1635 }
1636 else
1637 {
1638 this->particle_handler.update_ghost_particles();
1639 }
1640}
1641
1642template <int dim, typename PropertiesIndex>
1643void
1645{
1646 AssertThrow(
1647 this->simulation_parameters.simulation_control.method !=
1649 ExcMessage(
1650 "To run a steady simulation of a fluid-particle mixture, the lethe-fluid-vans application should be used."));
1651
1652 this->computing_timer.enter_subsection("Read mesh, manifolds and particles");
1653
1655 *this->triangulation,
1656 this->cfd_dem_simulation_parameters.cfd_parameters.mesh,
1657 this->cfd_dem_simulation_parameters.cfd_parameters.manifolds_parameters,
1658 this->cfd_dem_simulation_parameters.cfd_parameters.restart_parameters
1659 .restart ||
1660 this->cfd_dem_simulation_parameters.void_fraction->read_dem,
1661 this->cfd_dem_simulation_parameters.cfd_parameters.boundary_conditions
1662 .periodic_boundaries);
1663
1665
1666 // Reading DEM start file information
1667 if (this->cfd_dem_simulation_parameters.void_fraction->read_dem == true &&
1668 !this->cfd_dem_simulation_parameters.cfd_parameters.restart_parameters
1669 .restart)
1670 read_dem();
1671
1672 this->computing_timer.leave_subsection("Read mesh, manifolds and particles");
1673
1674 this->setup_dofs();
1675
1677 this->cfd_dem_simulation_parameters.cfd_parameters.initial_condition->type,
1678 this->cfd_dem_simulation_parameters.cfd_parameters.restart_parameters
1679 .restart);
1680
1683 this->pcout,
1684 this->mpi_communicator);
1685 if (this->cfd_dem_simulation_parameters.void_fraction->output_qcm)
1686 this->particle_projector.write_qcm_quadrature_points(
1687 this->cfd_dem_simulation_parameters.cfd_parameters.simulation_control
1688 .output_folder,
1689 "qcm_quadrature_points",
1690 this->cfd_dem_simulation_parameters.cfd_parameters.simulation_control
1691 .group_files);
1692
1693 // Only needed if other physics apart from fluid dynamics are enabled.
1694 if (this->multiphysics->get_active_physics().size() > 1)
1696
1697 // In the case the simulation is being restarted from a checkpoint file, the
1698 // restart_simulation parameter is set to true. This allows to perform all
1699 // operations related to restarting a simulation. Once all operations have
1700 // been performed, this restart_simulation is reset to false. It is only set
1701 // once and reset once since restarting only occurs once.
1702 if (this->cfd_dem_simulation_parameters.cfd_parameters.restart_parameters
1703 .restart)
1704 dem_action_manager->restart_simulation();
1705
1706 // Initialize the DEM parameters and generate the required ghost particles
1708
1709 // Calculate first instance of void fraction and of the projected particle
1710 // temperature once particles are set up
1711 this->vertices_cell_mapping();
1712 if (!dem_action_manager->check_restart_simulation())
1713 {
1714 this->particle_projector.initialize_void_fraction(
1715 this->simulation_control->get_current_time());
1716 this->particle_projector.calculate_particle_temperature_projection();
1717 }
1718
1719 // Output the solution after initializing the void fraction
1720 if (!this->cfd_dem_simulation_parameters.cfd_parameters.restart_parameters
1721 .restart)
1722 {
1723 this->postprocess_fd(true);
1724 this->multiphysics->postprocess(true);
1725 if (this->simulation_control->is_output_iteration())
1727 }
1728
1729 while (this->simulation_control->integrate())
1730 {
1731 this->simulation_control->print_progression(this->pcout);
1732
1733 // We allow the physics to update their boundary conditions
1734 // according to their own parameters
1736 this->multiphysics->update_boundary_conditions();
1737
1738 // Insert particle if needed
1740
1741 this->dynamic_flow_control();
1742
1743 if (!this->simulation_control->is_at_start())
1744 {
1746 this->vertices_cell_mapping();
1747 }
1748
1750 this->simulation_control->get_current_time());
1751
1752 // Project the particle temperature onto the fluid mesh (thermal CFD-DEM
1753 // simulations only), so that the other physics see the particle
1754 // temperature of the current time step
1755 this->particle_projector.calculate_particle_temperature_projection();
1756
1757 {
1758 TimerOutput::Scope t(this->computing_timer,
1759 "Calculate particle-fluid projection");
1760 // Project particle forces into the fluid mesh if the parameter is
1761 // enabled
1762 if (this->cfd_dem_simulation_parameters.cfd_dem.project_particle_forces)
1763 {
1764 this->particle_projector.calculate_particle_fluid_forces_projection(
1765 this->cfd_dem_simulation_parameters.cfd_dem,
1766 *this->dof_handler,
1767 *this->present_solution,
1768 *this->previous_solutions,
1769 this->cfd_dem_simulation_parameters.dem_parameters
1770 .lagrangian_physical_properties.g,
1772 this->simulation_control,
1773 this->simulation_parameters.physical_properties_manager,
1774 *this->fe,
1775 *this->cell_quadrature,
1776 *this->mapping,
1777 *this->face_quadrature));
1778 }
1779 }
1780 this->iterate();
1781
1782 if (this->cfd_dem_simulation_parameters.cfd_parameters.test.enabled)
1783 {
1784 switch (
1785 this->cfd_dem_simulation_parameters.cfd_parameters.test.test_type)
1786 {
1788 {
1790 break;
1791 }
1793 {
1794 if (this->simulation_control->is_at_end())
1795
1796 {
1797 // Get mobility status vector sorted by cell id
1798 Vector<float> mobility_status(
1799 this->triangulation->n_active_cells());
1800 sparse_contacts_object.get_mobility_status_vector(
1801 mobility_status);
1802
1803 // Output mobility status vector
1804 visualization_object.print_intermediate_format(
1805 mobility_status,
1806 *this->particle_projector.dof_handler,
1807 this->mpi_communicator,
1808 this->pcout);
1809 }
1810 break;
1811 }
1812 default:
1814 }
1815 }
1816
1817 // DEM iterations
1818 {
1819 announce_string(this->pcout, "DEM");
1820 TimerOutput::Scope t(this->computing_timer, "DEM_Iterator");
1821
1822 // Make alias reference to improve readability
1823 const auto &cfd_dem_prm = this->cfd_dem_simulation_parameters.cfd_dem;
1824
1825 // Create a simulation control object for the dem iterations
1826 dem_simulation_control = std::make_shared<SubSimulationControlDEM>(
1827 cfd_dem_prm.dem_iteration_control,
1828 this->simulation_control->get_time_step(),
1829 cfd_dem_prm.coupling_frequency,
1831 cfd_dem_prm.fraction_of_rayleigh_time);
1832
1833 // First DEM iteration of the CFD iteration
1834 dem_action_manager->first_dem_of_cfddem_iteration_step();
1835
1836 // Load balancing if needed
1837 load_balance();
1838
1839 // Update DEM time step when the simulation uses adaptive time-stepping
1840 if (this->simulation_control->is_adaptive_time_stepping())
1842
1844 while (dem_simulation_control->iterate())
1845 {
1846 // dem_iterator carries out the particle-particle and
1847 // particle_wall force calculations, integration and
1848 // update_ghost
1849 dem_iterator();
1850 }
1851
1852 // Closing step of the integration scheme. It brings the velocities of
1853 // the particles to the end of the CFD time step, at which their
1854 // positions already are.
1856
1857 this->pcout << "Finished " << dem_simulation_control->get_iteration()
1858 << " DEM iterations" << std::endl;
1859 }
1860
1862
1863 this->postprocess(false);
1864 this->postprocess_cfd_dem();
1865 this->finish_time_step_fd();
1866
1867 this
1868 ->FluidDynamicsVANS<dim, PropertiesIndex>::monitor_mass_conservation();
1869
1870 if (this->cfd_dem_simulation_parameters.cfd_dem.particle_statistics)
1872 }
1873
1874 // Write particle-wall collision statistics file if enabled
1875 if (dem_parameters.post_processing.particle_wall_collision_statistics)
1878 this->mpi_communicator);
1879
1880 this->finish_simulation();
1881}
1882
1883// Pre-compile the 2D and 3D CFD-DEM solver to ensure that the
1884// library is valid before we actually compile the solver This greatly
1885// helps with debugging
Solver class for coupled Computational Fluid Dynamics and Discrete Element Method (CFD-DEM) simulatio...
double maximum_particle_diameter
Maximum diameter among all particles in the simulation.
void add_fluid_particle_interaction_force()
Calculate and add fluid-particle interaction forces.
ParticleInteractionOutcomes< PropertiesIndex > contact_outcome
Container for particle interaction outcomes (forces and torques).
DEM::dem_data_structures< dim >::periodic_boundaries_cells_info periodic_boundaries_cells_information
Information about cells involved in periodic boundary conditions.
void dem_contact_build()
Perform contact detection and build contact lists.
std::vector< OutputStructTableHandler > gather_tables() override
Gather TableHandler objects for serialization during checkpointing.
std::vector< std::shared_ptr< Distribution > > size_distribution_object_container
Container for particle size distribution objects.
void add_fluid_particle_interaction_torque()
Calculate and add fluid-particle interaction torques.
virtual void solve() override
Engine of the CFD-DEM solver. Calls all the necessary functions to set parameters,...
void report_rayleigh_time_ratio()
Reports the ratio between the DEM time step and the Rayleigh time.
double rayleigh_time_step
Rayleigh time step.
DEM::ParticleProperties< dim, PropertiesIndex > properties_class
Particle properties handler for DEM simulation.
AdaptiveSparseContacts< dim, PropertiesIndex > sparse_contacts_object
Object for handling adaptive sparse contact detection algorithms.
unsigned int contact_search_total_number
Total number of contact searches since simulation start.
std::shared_ptr< Integrator< dim, PropertiesIndex > > integrator_object
Time integration scheme for particle motion equations.
void print_particles_summary()
Print final summary of particle simulation results.
dem_data_structures< dim >::solid_surfaces_mesh_information solid_surfaces_mesh_info
Mesh information for solid surfaces in contact with particles.
std::shared_ptr< ParticleWallContactForceBase< dim, PropertiesIndex > > particle_wall_contact_force_object
Contact force model for particle-wall interactions.
TableHandler table_phase_volumes
void postprocess_fd(bool first_iteration) override
Perform fluid dynamics post-processing after each iteration.
DEMSolverParameters< dim > dem_parameters
DEM simulation parameters container.
void read_checkpoint() override
Read CFD-DEM simulation checkpoint files.
std::shared_ptr< Integrator< dim, PropertiesIndex > > set_integrator_type()
Set up the time integration method for particle motion.
void report_particle_statistics()
Calculate and report particle statistics to the terminal.
const unsigned int n_mpi_processes
Total number of MPI processes.
std::vector< Tensor< 1, 3 > > & force
Reference to force vector from contact outcomes.
void check_contact_detection_method(unsigned int counter)
Check if contact detection is required and execute it if necessary.
void set_initial_condition(const Parameters::FluidDynamicsInitialConditionType initial_condition_type, const bool restart=false) override
Set the initial condition. The version in this class does not output the solution,...
unsigned int contact_search_counter
Counter for contact searches performed in the current CFD iteration.
CompletedCollisionLog< dim > collision_event_log
Object to store completed collision events.
const unsigned int this_mpi_process
Current MPI process identifier.
BoundaryCellsInformation< dim > boundary_cell_object
Information about boundary cells for contact detection.
std::vector< Tensor< 1, 3 > > & torque
Reference to torque vector from contact outcomes.
void dynamic_flow_control() override
Calculate dynamic flow control accounting for void fraction.
void particle_wall_contact_force()
Calculate contact forces between particles and walls.
PVDHandler grid_pvdhandler
PVD handler for grid visualization output.
std::shared_ptr< ParticleParticleContactForceBase< dim, PropertiesIndex > > particle_particle_contact_force_object
Contact force model for particle-particle interactions.
Tensor< 1, 3 > g
Gravitational acceleration vector.
void setup_distribution_type()
Initialize the particle size distribution and related parameters.
statistics contact_list
Statistics container for timing and contact list information.
void sort_particles_into_subdomains_and_cells()
Sort particles into subdomains and cells for efficient processing.
void synchronize_particle_velocities()
Carry out the closing half velocity step of a staggered integration scheme at the end of the DEM sub-...
void dem_setup_parameters()
Set up the various parameters related to the DEM simulation.
LagrangianLoadBalancing< dim, PropertiesIndex > load_balancing
Load balancing handler for distributing particles across MPI processes.
~CFDDEMSolver() override
Destructor for the CFD-DEM solver.
PeriodicBoundariesManipulator< dim > periodic_boundaries_object
Handler for periodic boundary condition manipulations.
DEMActionManager * dem_action_manager
Pointer to DEM action manager for handling DEM-specific operations.
void dem_iterator()
Execute a complete DEM iteration step.
std::shared_ptr< SubSimulationControlDEM > dem_simulation_control
void read_dem() override
Read DEM restart files from a previous simulation.
double neighborhood_threshold_squared
Squared threshold distance for neighborhood particle detection.
DEMContactManager< dim, PropertiesIndex > contact_manager
void initialize_dem_parameters()
Initialize fundamental DEM simulation parameters.
std::vector< double > displacement
Displacement vector for particle motion calculations.
OngoingCollisionLog< dim > ongoing_collision_log
Object to store ongoing collision information.
double smallest_contact_search_criterion
Smallest criterion used for contact search algorithms.
void postprocess_cfd_dem()
Perform CFD-DEM coupled post-processing after each iteration.
PVDHandler particles_pvdhandler
PVD handler for particle visualization output.
Visualization< dim, PropertiesIndex > visualization_object
Visualization handler for DEM output generation.
void write_dem_output_results()
Write DEM simulation results to output files.
void write_checkpoint() override
Write CFD-DEM simulation checkpoint files.
ParticlePointLineForce< dim, PropertiesIndex > particle_point_line_contact_force_object
Handler for point and line contact forces between particles.
CFDDEMSolver(CFDDEMSimulationParameters< dim > &nsparam)
Constructor for the CFD-DEM solver.
std::shared_ptr< Insertion< dim, PropertiesIndex > > insertion_object
Particle insertion method handler.
void insert_particles()
Check if particles need to be inserted and perform insertion.
void load_balance()
Check if load balancing is required and perform it if necessary.
std::vector< double > MOI
Moment of inertia values for all particles.
static DEMActionManager * get_action_manager()
Getter of the unique instance of the DEMActionManager.
Implementation of a classical explicit euler scheme for the integration of the particle motion....
virtual void update_multiphysics_time_average_solution() override
Updates the average velocity field solution in the multiphyscics interface.
CFDDEMSimulationParameters< dim > cfd_dem_simulation_parameters
Member Variables.
void vertices_cell_mapping()
Create mapping between vertices and cells.
ParticleProjector< dim, PropertiesIndex > particle_projector
Particle projector for calculating void fraction and particle effects.
virtual void finish_time_step_fd()
Complete operations at the end of a time step.
virtual void iterate() override
Execute a single VANS iteration.
FluidDynamicsVANS(CFDDEMSimulationParameters< dim > &nsparam)
Constructor for the VANS solver.
virtual void setup_dofs() override
Set up degrees of freedom and initialize void fraction field.
MappingQGeneric< dim > particle_mapping
Mapping object for particle position calculations and projections.
Particles::ParticleHandler< dim, dim > particle_handler
Particle handler for managing particle data and operations.
void calculate_void_fraction(const double time)
Calculate void fraction field based on particle positions.
void write_output_results(const GlobalVectorType &solution)
virtual std::vector< OutputStructTableHandler > gather_tables()
Returns a vector of references to TableHandler objects that needs to be serialized/ deserialized for ...
std::shared_ptr< GlobalVectorType > present_solution
virtual void refine_mesh()
Allow the refinement of the mesh according to one of the 2 methods proposed.
std::shared_ptr< std::vector< GlobalVectorType > > previous_solutions
std::shared_ptr< SimulationControl > simulation_control
std::shared_ptr< MultiphysicsInterface< dim > > multiphysics
std::shared_ptr< AverageVelocities< dim, GlobalVectorType, IndexSet > > average_velocities
std::shared_ptr< DoFHandler< dim > > dof_handler
std::shared_ptr< parallel::DistributedTriangulationBase< dim > > triangulation
Class that stores the information required by the assembly procedure for a Navier-Stokes equation....
Numerical model parameters for DEM simulations.
enum Parameters::Lagrangian::ModelParameters::ContactDetectionMethod contact_detection_method
IntegrationMethod
Time integration method for particle motion.
unsigned int contact_detection_frequency
Frequency of particle-particle and particle-wall contact detection.
Postprocessing - Defines the parameters for the post-processing. In Lethe, post-processing implies th...
std::string phase_volumes_output_name
prefix for the total volume output in cfd-dem 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 check_file_exists(const std::string &file_name, const std::string &file_description)
Verify that a file that Lethe must read exists and can be opened, and raise an error stated in the us...
Definition utilities.cc:225
void serialize_tables_vector(const std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Serializes all the TableHandler objects in table_output_structs.
Definition utilities.h:602
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 deserialize_tables_vector(std::vector< OutputStructTableHandler > &table_output_structs, const MPI_Comm mpi_communicator)
Deserializes all the TableHandler objects in table_output_structs.
Definition utilities.h:624
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 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 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.
std::conditional_t< has_thermal_properties< PropertiesIndex >, DEMMPProperties::PropertiesIndex, DEMProperties::PropertiesIndex > matching_dem_properties_index
The pure DEM index set matching a given index set.
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 convert_particle_handler(const parallel::distributed::Triangulation< dim > &triangulation, const Particles::ParticleHandler< dim > &ph_in, Particles::ParticleHandler< dim > &ph_out)
Converts an input particle handler with a given set of input properties into an output particle handl...
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...
double calculate_average_velocity(const DoFHandler< dim > &dof_handler, const VectorType &present_solution, const unsigned int &boundary_id, const Quadrature< dim - 1 > &face_quadrature_formula, const Mapping< dim > &mapping)
calculate_average_velocity. This function calculates average velocity from the volumetric flow rate a...
std::pair< double, double > calculate_fluid_and_particle_volumes(const DoFHandler< dim > &void_fraction_dof_handler, const VectorType &present_void_fraction_solution, const Quadrature< dim > &quadrature_formula, const Mapping< dim > &mapping)
This function calculates total volume of fluid and total volume of particles in cfd-dem simulation.
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< 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...
dealii::TrilinosWrappers::MPI::Vector GlobalVectorType
Definition vector.h:17