Modélisation Physique (Simulation Bris de Barrage)

Environnement de Programmation Scientifique

Ce projet est motivé par mon expérience de travail pour la compagnie CAE (leader mondial en simulation) ainsi que mon expérience au centre de recherche calcul appliqué (CERCA projet transfert technologique). 

Le but est de créer un environnement de programmation qui utilise des pratiques modernes de développement logiciel (Orientée-Objet OO) dans le domaine la modélisation physique. Cette approche largement utilisé en logiciel commercial est très bien adapté en programmation scientifique puisque les abstractions (sous forme de concepts math et physique) sont “built-in” inhérentes au problème ce qui rend la modélisation (OON Orientée-Objet Numérique) de tel système naturelle. 

C++ est le langage adopté pour ce projet, supporte les concepts Orientée-Objet (OO) et offre des performances de calcul satisfaisante. Depuis les 10 dernières années le langage a évolué (C++11/14/17/20) avec l’ajout de nouveaux outils pour le rendre encore plus performant. 

Motivation

Créer un environnement de programmation pour la solution numérique des équations de St-Venant unidimensionnel sur le problème du bris de barrage par méthode aux différences finies explicites. Architecture orientée objet dont l’objectif principal est de fournir un environnement de programmation pour le prototypage rapide d’algorithmes physiques pour la validation sur le problème du bris de barrage. Dans les projets industriels, on est souvent appelé à tester ou à expérimenter différents scénarios, ce type d’environnement répond à ce besoin. Permet d’accélerer la phase de prototypage.

Approche

L’approche qui est adoptée est basée sur la technologie Orientée-Objet Numérique (OON) ou de type «Framework», qui consiste à définir une couche de ‘class’ de haut niveau qui définissent les concepts du système que l’on veut modéliser et de laisser l’usager compléter ou définir l’application. Un ensemble d’interfaces définissent les différentes composantes ou fonctionnalité du système (frontières des concepts du système). Celles-ci deviennent la porte d’entrée afin de construire une application. Le développeur qui a l’intention d’utiliser le « Framework » doit fournir une implémentation des interfaces (composantes).

Environnement de programmation

Mise au point d’un environnement de programmation (différence finies) qui solutionne les équations St-Venant 1D par méthode explicite sur le problème du bris de barrage. La principale caractéristique de cet environnement est la facilité à développer/programmer de nouveaux algos (schémas numériques) et de les valider avec un minimum d’effort. Ce type de problème est utilisé pour tester la stabilité de schémas numérique.

Les quatre interfaces définissent les composantes du système et doivent être implémentées par l’utilisateur qui veut utiliser le « framework ». Le nom de chacune de celles-ci est explicite, par exemple, IPhysicalConfiguration pour spécifier les conditions initiales du système. Ci-dessous un tableau

InterfaceMethodEArguments
IPhysicalConfigurationconfigure()PhysicalSystem ps
IPhysicalAlgorithmcalculate()Simulation sim, PhysicalSystem ps
IPhysicalMeasurementtake() toString() toSql()Simulation sim PhysicalSystem ps
IFinalReportreport()Simulation sim PhysicalSystem ps
Interfaces du système (frontière entre les composantes)

Galerie

Exemples de code

  GlobalDiscretization* w_globalDisscr = new GlobalDiscretization();
  PhysicalSystem* physicalSystem = nullptr;
  IPhysicalAlgorithm* w_phyAlgo = nullptr;
  IPhysicalConfiguration* w_phyConfig = nullptr;
  DataStore* w_dataStore = nullptr;
  IPhysicalMeasurement* w_phyMeasurement = nullptr;
  IFinalReport* w_simReport = nullptr;
        
   // Now create the simulation environment that the user
   // has defined using the appropriate factory methods
   try 
   {
     // Create a new Physical System Factory
     std::cout << "Creating the physical system...\n";

     PhysicalSystemFactory* w_PhySysF = PhysicalSystemFactory::getInstance();
     physicalSystem = dynamic_cast<DamBreakSystem*>( w_PhySysF->create( w_globalDisscr));
     g_pLogger->write2File( "PhysicalSystem created successfully");
     std::cout << "created\n";

    // Configure the objects in the physical system
    std::cout << "Configuring system using < " 
        + g_pSimulation->getPhysicalConfigurationClass() + ">...\n";
     Class* setupClazz = Class::forName( g_pSimulation->getPhysicalConfigurationClass());
      w_phyConfig = (IPhysicalConfiguration*)setupClazz->newInstance();
      w_phyConfig->configure( physicalSystem);
      g_pLogger->write2File( "PhysicalSystem configured successfully");
   
      // Define the algorithm class to be used per iteration on the PhysicalSystem
      std::cout << "Configuring Algorithm using < " 
           + g_pSimulation->getPhysicalAlgorithmClass() + ">...\n";
      Class* algorithmClazz = Class::forName( g_pSimulation->getPhysicalAlgorithmClass());
       w_phyAlgo = (IPhysicalAlgorithm*)algorithmClazz->newInstance();
       g_pLogger->write2File( "PhysicalAlgorithm created successfully");
   ....
  };

References

An Extensible C++ Framework for One-Dimensional Open Channel Flow Simulation  – J. Belanger (in preparation)

Abstract In this report we provide an introduction to ODE, then present an extensible Object-Oriented framework – written in C++ – with emphasis on the reusability of modules for ODE solvers. The ability to extend this API to accommodate new algorithms as they are developed is particularly attractive. This facilitates our work to find the best numerical method, and speed the development of a dedicated simulator for specific cases.

voir article

A C++ Differential Equations Solver using Object-Oriented Numerics” – J. Belanger Elligno Inc. Technical Report no. TR-2016-01 (September 2016)

Abstract Over the last few years we have been migrating a small library of numerical code originally written in C to C++. In this report, we present the mathematical abstractions used and how object-oriented programming techniques are applied for scientific software design. Finally implementations details are provided including relationship between data structure. The result is tight, readable code that is easy to maintain and extend. Example with Shallow water equations is drawn from our prototype C++ based environment.

voir article

“Validating Shock Capturing Schemes On The Dam Break Problem” – J. Belanger, Elligno Inc. Technical report no. TR1-2007-01 (March 2007)

Abstract In this report we discuss some numerical techniques for approximating the Shallow-water equations. In particular finite difference schemes, adaptation of Roe’s approximate Riemann solver and the HLL scheme of (Harten-Lax-Van Leer) with the objective of accurately approximating the solution of Shallow-water equations over variable topography. Some tests are presented as preliminary validation of the proposed framework. Satisfactory comparisons have been obtained. This report shows progress towards a more complete validation of the schemes and demonstrate a critical need to improve procedure if such progress is to be sustained.

voir article