Skip to content

Commit

Permalink
Refactor the way the DEM PropertiesIndex are managed using templates (#…
Browse files Browse the repository at this point in the history
…1399)

Description
The deal.II ParticleHandler class supports storing a number of properties as double within the a PropertyPool. The issue is that this PropertyPool is nothing more than an array of double and associating the elements of that array to a physical meaning (e.g. knowing that property 8 is the diameter) can be challenging. To alleviate this issue, we have always used an enum of type int to do the link between the properties and their index. This is convenient, but it also hardcodes at compile time the properties. This has forced us to have the same number of properties in DEM and CFD-DEM. This is wasteful, because all of the hydrodynamic forces and torques, which are just zero in DEM, have the be stored anyway in a DEM simulation.

This PR changes this issue by templating ALL of the DEM classes that use the properties of the particle with a typename that is an enum. This typename PropertiesIndex is then used within the class to do the calculation with the adequate properties index. This essentially enable the contact models, the integrators, or whatever you actually want, to be reused with ParticleHandler that have a different amount of properties.

Some of the planned usage for this are notably heat transfer within particles, but also the addition of more properties on the particle within CFD-DEM (e.g. previous particle velocity like we discussed with @voferreira ). This PR opens all of these possibilities.

This is a major change because it changes everything in the code everywhere, but does not change the logic. The DEM results are unchanged, but the CFD-DEM results are changed.
This is because, now CFD-DEM requires translating a DEM ParticleHandler to a CFD-DEM ParticleHandler. To achieve this, I read the ParticleHandler from the DEM simulation and transform it into a CFD-DEM ParticleHandler using a new conversion function I wrote.

This essentially opens-up the possibility of reading particles that were created on a different mesh and converting it on a new one. This is what i will do in the next PR and this will essentially disconnect the mesh used for DEM and for CFD-DEM. Enabling us to change the CFD-DEM mesh without redoing a DEM insertion (which is cool). @voferreira this feature will be useful for your mesh convergence work

Testing
The CFD-DEM test results have changed because of the aforementioned issue

Documentation
This does not modify the documentation except for a minor parameter that was added.

Co-authored-by: OGaboriault <[email protected]>
Co-authored-by: Victor Oliveira Ferreira <[email protected]>
  • Loading branch information
3 people authored Jan 11, 2025
1 parent a31a90c commit b676be5
Show file tree
Hide file tree
Showing 180 changed files with 4,182 additions and 2,509 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to the Lethe project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/).

## [Master] - 2024-01-10

### Changed

- MAJOR The index of properties in the DEM and CFD-DEM simulations are now indexed using a template (PropertiesIndex) instead of using an hardcoded enum. This enables the different solvers to have different number of properties and different properties index. For large simulations, this gives minor performance gain for DEM simulations (e.g. around 5-10%), but this makes the solver significantly more flexible. This is a major change since it breaks DEM and CFD-DEM restart files from previous versions. [#1399](https://github.com/chaos-polymtl/lethe/pull/1399)

## [Master] - 2024-01-02

### Changed
Expand Down
42 changes: 37 additions & 5 deletions applications/lethe-particles/dem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,25 @@ main(int argc, char *argv[])
// Parsing of the file
prm.parse_input(argv[1]);
dem_parameters.parse(prm);
const DEM::SolverType solver_type =
dem_parameters.model_parameters.solver_type;

DEMSolver<2> problem(dem_parameters);
problem.solve();
if (solver_type == DEM::SolverType::dem)
{
DEMSolver<2, DEM::DEMProperties::PropertiesIndex> problem(
dem_parameters);
problem.solve();
}
else
{
AssertThrow(
false,
dealii::ExcMessage(
"While reading the solver type from the input file, "
"Lethe found a value different than \"dem\". As of January 2025, "
"the lethe-particles application requires the uses of "
"\"solver type = dem\", which is the default value."));
}
}

else if (dim == 3)
Expand All @@ -46,9 +62,25 @@ main(int argc, char *argv[])
// Parsing of the file
prm.parse_input(argv[1]);
dem_parameters.parse(prm);

DEMSolver<3> problem(dem_parameters);
problem.solve();
// const DEM::SolverType solver_type =
// dem_parameters.model_parameters.solver_type;
const DEM::SolverType solver_type = DEM::SolverType::dem;
if (solver_type == DEM::SolverType::dem)
{
DEMSolver<3, DEM::DEMProperties::PropertiesIndex> problem(
dem_parameters);
problem.solve();
}
else
{
AssertThrow(
false,
dealii::ExcMessage(
"While reading the solver type from the input file, "
"Lethe found a value different than \"dem\". As of January 2025, "
"the lethe-particles application requires the uses of "
"\"solver type = dem\", which is the default value."));
}
}

else
Expand Down
37 changes: 14 additions & 23 deletions applications_tests/lethe-fluid-particles/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ set(TEST_TARGET lethe-fluid-particles)
string(TOLOWER ${CMAKE_BUILD_TYPE} _build_type)

file(COPY particle_sedimentation_files/dem.checkpoint_controller DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.triangulation DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.triangulation.info DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.triangulation_fixed.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_0.triangulation_variable.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.triangulation DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.triangulation.info DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.triangulation_fixed.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY particle_sedimentation_files/dem_1.triangulation_variable.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/particle_sedimentation.${_build_type}/mpirun=1/")

file(COPY restart_particle_sedimentation_files/case.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/restart_particle_sedimentation.${_build_type}/mpirun=1/")
file(COPY restart_particle_sedimentation_files/case.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/restart_particle_sedimentation.${_build_type}/mpirun=1/")
Expand All @@ -21,21 +21,13 @@ file(COPY restart_particle_sedimentation_files/case.triangulation_fixed.data DES
file(COPY restart_particle_sedimentation_files/case.triangulation_variable.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/restart_particle_sedimentation.${_build_type}/mpirun=1/")

file(COPY dynamic_contact_search_files/dem.checkpoint_controller DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.triangulation DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.triangulation.info DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.triangulation_fixed.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_0.triangulation_variable.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")

file(COPY conserve_phase_volumes_files/dem.checkpoint_controller DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY conserve_phase_volumes_files/dem_0.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY conserve_phase_volumes_files/dem_0.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY conserve_phase_volumes_files/dem_0.triangulation DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY conserve_phase_volumes_files/dem_0.triangulation.info DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY conserve_phase_volumes_files/dem_0.triangulation_fixed.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY conserve_phase_volumes_files/dem_0.triangulation_variable.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/conserve_phase_volumes.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.pvdhandler DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.simulationcontrol DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.triangulation DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.triangulation.info DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.triangulation_fixed.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")
file(COPY dynamic_contact_search_files/dem_1.triangulation_variable.data DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/dynamic_contact_search.${_build_type}/mpirun=1/")

file(COPY liquid_fluidized_bed_files/dem.checkpoint_controller DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/liquid_fluidized_bed.${_build_type}/mpirun=1/")
file(COPY liquid_fluidized_bed_files/dem_0.particles DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/liquid_fluidized_bed.${_build_type}/mpirun=1/")
Expand Down Expand Up @@ -99,5 +91,4 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set_tests_properties(lethe-fluid-particles/restart_particle_sedimentation.mpirun=1.debug PROPERTIES TIMEOUT 1200)
set_tests_properties(lethe-fluid-particles/dynamic_contact_search.mpirun=1.debug PROPERTIES TIMEOUT 1200)
set_tests_properties(lethe-fluid-particles/liquid_fluidized_bed.mpirun=1.debug PROPERTIES TIMEOUT 5000)
set_tests_properties(lethe-fluid-particles/conserve_phase_volumes.mpirun=1.debug PROPERTIES TIMEOUT 5000)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ DEM contact search at dem step 1
DEM contact search at dem step 49
Finished 50 DEM iterations
---------------------------------------------------------------
Global continuity equation error: 2.803e-09 s^-1
Max local continuity error: 7.07295e-08 s^-1
Global continuity equation error: 2.76979e-09 s^-1
Max local continuity error: 6.88735e-08 s^-1

**********************************************************************************
Transient iteration: 2 Time: 0.002 Time step: 0.001 CFL: 7.48857e-05
Transient iteration: 2 Time: 0.002 Time step: 0.001 CFL: 7.47614e-05
**********************************************************************************
--------------
Void Fraction
Expand All @@ -54,7 +54,7 @@ print_from_processor_0
0 1
0
1 8
4 4 4 4 4 4 4 4
3 3 3 3 3 3 3 3


[deal.II intermediate Patch<3,3>]
Expand All @@ -64,7 +64,7 @@ print_from_processor_0
1 1
0
1 8
4 4 4 4 4 4 4 4
2 2 2 2 2 2 2 2


[deal.II intermediate Patch<3,3>]
Expand All @@ -74,7 +74,7 @@ print_from_processor_0
2 1
0
1 8
3 3 3 3 3 3 3 3
2 2 2 2 2 2 2 2


[deal.II intermediate Patch<3,3>]
Expand Down Expand Up @@ -136,5 +136,5 @@ DEM contact search at dem step 1
DEM contact search at dem step 49
Finished 50 DEM iterations
---------------------------------------------------------------
Global continuity equation error: -2.28117e-09 s^-1
Max local continuity error: 6.96484e-07 s^-1
Global continuity equation error: 2.16995e-09 s^-1
Max local continuity error: 6.35415e-07 s^-1
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0 0 350 78 350
0 0 350 75 350
Binary file not shown.
Binary file not shown.

This file was deleted.

Loading

0 comments on commit b676be5

Please sign in to comment.