From c32cbf71e1e94a44b5a649c02d5b98b39639f4fc Mon Sep 17 00:00:00 2001 From: Bruno Blais Date: Mon, 5 Aug 2024 09:46:37 -0400 Subject: [PATCH] Remove gear3 integrator (#1221) Description The Gear3 integrator was not used anywhere in the code in any example or in any tests. This integrator never gave good performance and was actually not tested for years. I believe it is now time to fully delete it. I want to work on adding new integrators this year and this will require some more unification. I want to start by cleaning things before adding new things. Testing There were actually no test for gear3... Documentation I adapted the documentation but the gear3 integrator was never mentioned in the documentation. --- CHANGELOG.md | 6 ++ include/core/parameters_lagrangian.h | 3 +- include/dem/gear3_integrator.h | 125 --------------------------- source/core/parameters_lagrangian.cc | 13 ++- source/dem/CMakeLists.txt | 2 - source/dem/dem.cc | 3 - source/dem/gear3_integrator.cc | 110 ----------------------- source/fem-dem/cfd_dem_coupling.cc | 3 - 8 files changed, 12 insertions(+), 253 deletions(-) delete mode 100644 include/dem/gear3_integrator.h delete mode 100644 source/dem/gear3_integrator.cc diff --git a/CHANGELOG.md b/CHANGELOG.md index 45cbccb623..2989f249fa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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-08-05 + +### Removed + +- MINOR Removed the gear3 DEM integrator. It was never used, it did not possess any unit test and it was not even clear if it still worked. [#1221](https://github.com/chaos-polymtl/lethe/pull/1211) + ## [Master] - 2024-08-01 ### Added diff --git a/include/core/parameters_lagrangian.h b/include/core/parameters_lagrangian.h index 6bf69b94b4..cfa06c1c17 100644 --- a/include/core/parameters_lagrangian.h +++ b/include/core/parameters_lagrangian.h @@ -297,8 +297,7 @@ namespace Parameters enum class IntegrationMethod { velocity_verlet, - explicit_euler, - gear3 + explicit_euler } integration_method; // Disable particle contacts to optimize performance diff --git a/include/dem/gear3_integrator.h b/include/dem/gear3_integrator.h deleted file mode 100644 index 8f93a026f7..0000000000 --- a/include/dem/gear3_integrator.h +++ /dev/null @@ -1,125 +0,0 @@ -/* --------------------------------------------------------------------- - * - * Copyright (C) 2019 - 2024 by the Lethe authors - * - * This file is part of the Lethe library - * - * The Lethe library is free software; you can use it, redistribute - * it, and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * The full text of the license can be found in the file LICENSE at - * the top level of the Lethe distribution. - * - * --------------------------------------------------------------------- - * - */ - -#include -#include - -#include - -using namespace dealii; - -#ifndef gear3_integrator_h -# define gear3_integrator_h - -/** - * Implementation of a gear3 scheme for the integration - * of the particle motion. Note that reinitilization of force and torque is also - * integrated into integration class - * - * @note Gear3 is a third-order predictor-correcton integration scheme. In gear3, - * acceleration, velocity and position of particles are updated using the - * following method. b is the first derivative of acceleration - * - * Prediction: - * b(n+1,prediction) = b(n) - * a(n+1,prediction) = a(n) + b(n) * dt - * v(n+1,prediction) = v(n) + a(n) * dt + 1/2 * b(n) * dt ^ 2 - * x(n+1,prediction) = x(n) + v(n) * dt + 1/2 * a(n) * dt ^ 2 + 1/6 * b(n) * dt - * ^ 3 - * - * a(n+1,correction) = F(n+1) / m - * delata_a(n+1) = a(n+1,correction) - a(n+1,prediction) - * - * Correction: - * ┌ ┐ ┌ ┐ ┌ ┐ - * | x(n+1,correction) | | x(n+1,prediction) | | eta1 * dt ^ 2 | - * | v(n+1,correction) | = | v(n+1,prediction) | + | eta2 * dt | * delata_a(n+1) - * | a(n+1,correction) | | a(n+1,prediction) | | eta3 | - * | b(n+1,correction) | | b(n+1,prediction) | | eta4 * dt ^ -1 | - * └ ┘ └ ┘ └ ┘ - * where eta1 - eta4 are gear3 method coefficients, eta1 = 1/12, eta2 = 5/12, - * eta3 = 1, eta4 = 1 - * - * @author Shahab Golshan, Bruno Blais, Polytechnique Montreal 2019- - */ - -template -class Gear3Integrator : public Integrator -{ -public: - Gear3Integrator() - {} - - /** - * Carries out integrating of new particles' location after insertion. - * - * @param particle_handler The particle handler whose particle motion we wish - * to integrate - * @param body_force A constant volumetric body force applied to all particles - * @param time_step The value of the time step used for the integration - * @param torque Torque acting on particles - * @param force Force acting on particles - * @param MOI A container of moment of inertia of particles - */ - virtual void - integrate_half_step_location( - Particles::ParticleHandler &particle_handler, - const Tensor<1, 3> &body_force, - const double time_step, - const std::vector> &torque, - const std::vector> &force, - const std::vector &MOI) override; - - /** - * Carries out the integration of the motion of all - * particles by using the Gear3 method. - * - * @param particle_handler The particle handler whose particle motion we wish - * to integrate - * @param body_force A constant volumetric body force applied to all particles - * @param time_step The value of the time step used for the integration - * @param torque Torque acting on particles - * @param force Force acting on particles - * @param MOI A container of moment of inertia of particles - */ - virtual void - integrate(Particles::ParticleHandler &particle_handler, - const Tensor<1, 3> &body_force, - const double time_step, - std::vector> &torque, - std::vector> &force, - const std::vector &MOI) override; - - virtual void - integrate(Particles::ParticleHandler &particle_handler, - const Tensor<1, 3> &body_force, - const double time_step, - std::vector> &torque, - std::vector> &force, - const std::vector &MOI, - const parallel::distributed::Triangulation &triangulation, - AdaptiveSparseContacts &sparse_contacts_object) override; - -private: - Point predicted_location; - Tensor<1, dim> corrected_accereration; - Tensor<1, dim> acceleration_deviation; - Point corrected_location; - double correction; -}; - -#endif diff --git a/source/core/parameters_lagrangian.cc b/source/core/parameters_lagrangian.cc index c00e62b2c2..e88e89645f 100644 --- a/source/core/parameters_lagrangian.cc +++ b/source/core/parameters_lagrangian.cc @@ -699,12 +699,11 @@ namespace Parameters "Choosing rolling resistance torque model" "Choices are ."); - prm.declare_entry( - "integration method", - "velocity_verlet", - Patterns::Selection("velocity_verlet|explicit_euler|gear3"), - "Choosing integration method" - "Choices are ."); + prm.declare_entry("integration method", + "velocity_verlet", + Patterns::Selection("velocity_verlet|explicit_euler"), + "Choosing integration method" + "Choices are ."); prm.enter_subsection("adaptive sparse contacts"); { @@ -912,8 +911,6 @@ namespace Parameters integration_method = IntegrationMethod::velocity_verlet; else if (integration == "explicit_euler") integration_method = IntegrationMethod::explicit_euler; - else if (integration == "gear3") - integration_method = IntegrationMethod::gear3; else { throw(std::runtime_error("Invalid integration method ")); diff --git a/source/dem/CMakeLists.txt b/source/dem/CMakeLists.txt index 7ceacee583..af6400e41f 100644 --- a/source/dem/CMakeLists.txt +++ b/source/dem/CMakeLists.txt @@ -12,7 +12,6 @@ add_library(lethe-dem find_cell_neighbors.cc find_contact_detection_step.cc force_chains_visualization.cc - gear3_integrator.cc grid_motion.cc input_parameter_inspection.cc insertion.cc @@ -63,7 +62,6 @@ add_library(lethe-dem ../../include/dem/find_cell_neighbors.h ../../include/dem/find_contact_detection_step.h ../../include/dem/force_chains_visualization.h - ../../include/dem/gear3_integrator.h ../../include/dem/grid_motion.h ../../include/dem/input_parameter_inspection.h ../../include/dem/insertion.h diff --git a/source/dem/dem.cc b/source/dem/dem.cc index 8b6f392068..94a14e1778 100644 --- a/source/dem/dem.cc +++ b/source/dem/dem.cc @@ -6,7 +6,6 @@ #include #include #include -#include #include #include #include @@ -314,8 +313,6 @@ DEMSolver::set_integrator_type() return std::make_shared>(); case ModelParameters::IntegrationMethod::explicit_euler: return std::make_shared>(); - case ModelParameters::IntegrationMethod::gear3: - return std::make_shared>(); default: throw(std::runtime_error("Invalid integration method.")); } diff --git a/source/dem/gear3_integrator.cc b/source/dem/gear3_integrator.cc deleted file mode 100644 index a578d2083c..0000000000 --- a/source/dem/gear3_integrator.cc +++ /dev/null @@ -1,110 +0,0 @@ -#include - -#include - -using namespace DEM; - -template -void -Gear3Integrator::integrate_half_step_location( - Particles::ParticleHandler & /*particle_handler*/, - const Tensor<1, 3> & /*body_force*/, - const double /*time_step*/, - const std::vector> & /*torque*/, - const std::vector> & /*force*/, - const std::vector & /*MOI*/) -{} - -template -void -Gear3Integrator::integrate( - Particles::ParticleHandler & /*particle_handler*/, - const Tensor<1, 3> & /*g*/, - const double /*dt*/, - std::vector> & /*torque*/, - std::vector> & /*force*/, - const std::vector & /*MOI*/) -{ - /* -for (auto particle = particle_handler.begin(); - particle != particle_handler.end(); - ++particle) - { - // Get the total array view to the particle properties once to improve - // efficiency - auto particle_properties = particle->get_properties(); - - // Updating particle location, velocity, acceleration and derivative of - // acceleration: - for (int d = 0; d < dim; ++d) - { - // Finding corrected acceleration - corrected_accereration[d] = - g[d] + particle_properties[PropertiesIndex::force_x + d] / - particle_properties[PropertiesIndex::mass]; - - // Reinitializing force - particle_properties[PropertiesIndex::force_x + d] = 0; - - // Calculation of acceleration deviation - acceleration_deviation[d] = - corrected_accereration[d] - - particle_properties[PropertiesIndex::acc_x + d]; - - // Corrector - corrected_location[d] = - predicted_location[d] + - acceleration_deviation[d] * (0.0833 * dt * dt); - particle_properties[PropertiesIndex::v_x + d] = - particle_properties[PropertiesIndex::v_x + d] + - acceleration_deviation[d] * (0.4167 * dt); - particle_properties[PropertiesIndex::acc_x + d] = - particle_properties[PropertiesIndex::v_x + d] + - acceleration_deviation[d]; - particle_properties[PropertiesIndex::acc_derivative_x + d] += - acceleration_deviation[d] / dt; - - // Angular velocity - particle_properties[PropertiesIndex::omega_x + d] += - dt * (particle_properties[PropertiesIndex::M_x + d] / - particle_properties[PropertiesIndex::mom_inertia]); - - // Reinitializing torque - particle_properties[PropertiesIndex::M_x + d] = 0; - } - particle->set_location(corrected_location); - } - */ -} - -// Gear 3 not implemented for adaptive sparse contacts -template -void -Gear3Integrator::integrate( - Particles::ParticleHandler &particle_handler, - const Tensor<1, 3> &g, - const double dt, - std::vector> &torque, - std::vector> &force, - const std::vector &MOI, - const parallel::distributed::Triangulation & /* triangulation */, - AdaptiveSparseContacts & /* sparse_contacts_object */) -{ - auto action_manager = DEMActionManager::get_action_manager(); - - bool use_default_function = - !action_manager->check_sparse_contacts_enabled() || - action_manager->check_mobility_status_reset(); - - if (use_default_function) - { - integrate(particle_handler, g, dt, torque, force, MOI); - return; - } - - throw std::runtime_error( - "Adaptive sparse contacts not supported with explicit Gear 3 integrator, use Verlet integrator."); -} - -template class Gear3Integrator<2>; -template class Gear3Integrator<3>; diff --git a/source/fem-dem/cfd_dem_coupling.cc b/source/fem-dem/cfd_dem_coupling.cc index 42fe80a5d9..f996920e9b 100644 --- a/source/fem-dem/cfd_dem_coupling.cc +++ b/source/fem-dem/cfd_dem_coupling.cc @@ -2,7 +2,6 @@ #include #include -#include #include #include #include @@ -200,8 +199,6 @@ CFDDEMSolver::set_integrator_type() return std::make_shared>(); case ModelParameters::IntegrationMethod::explicit_euler: return std::make_shared>(); - case ModelParameters::IntegrationMethod::gear3: - return std::make_shared>(); default: throw(std::runtime_error("Invalid integration method.")); }