Skip to content

Refactor pic namespace to TimeIntegration class #459

@Eleven7825

Description

@Eleven7825

Problem

Background

The pic namespace currently implements the Generalized α-Method for time integration (Predictor-Initiator-Corrector scheme). However, the name "PIC" is misleading as it's commonly associated with "Particle-In-Cell" methods in computational physics, not time integration schemes.

Related to: Ongoing OOP refactoring effort (see #442)

Current State

Location: Code/Source/solver/pic.h and Code/Source/solver/pic.cpp

The current namespace contains four functions implementing the Predictor-Initiator-Corrector
scheme:

namespace pic {                                                                                    
  void picp(Simulation* simulation);              // Predictor                                     
  void pici(Simulation* simulation, ...);         // Initiator                                     
  void picc(Simulation* simulation);              // Corrector                                     
  void pic_eth(Simulation* simulation);           // Helper for Taylor-Hood elements               
};                                                                                                 
                                                                                                   
Current usage (3 files):                                                                           
- main.cpp:319 - calls pic::picp()                                                                 
- Integrator.cpp:189 - calls pic::pici()                                                           
- Integrator.cpp:331 - calls pic::picc()                         

Solution

Refactor the pic namespace into a TimeIntegration class with clearer, self-documenting method names:

                                                                                                    
 class TimeIntegration {                                                                            
 public:                                                                                            
   /**                                                                                              
    * @brief Predictor step: predict solution at next time step                                     
    *                                                                                               
    * Sets up prediction for next time step using Generalized α-Method.                             
    * Updates An, Yn, Dn arrays.                                                                    
    */                                                                                              
   static void predict(Simulation* simulation);                                                     
                                                                                                    
   /**                                                                                              
    * @brief Initiator step: compute quantities at intermediate time levels                         
    *                                                                                               
    * Computes solution at n+α_m and n+α_f time levels for Generalized α-Method.                    
    *                                                                                               
    * @param Ag Acceleration at intermediate time level                                             
    * @param Yg Velocity at intermediate time level                                                 
    * @param Dg Displacement at intermediate time level                                             
    */                                                                                              
   static void initialize_step(Simulation* simulation,                                              
                               Array<double>& Ag,                                                   
                               Array<double>& Yg,                                                   
                               Array<double>& Dg);                                                  
                                                                                                    
   /**                                                                                              
    * @brief Corrector step: update solution and check convergence                                  
    *                                                                                               
    * Updates solution variables (An, Yn, Dn) and checks convergence criteria.                      
    * Also determines which equation to solve next.                                                 
    */                                                                                              
   static void correct(Simulation* simulation);                                                     
                                                                                                    
 private:                                                                                           
   /**                                                                                              
    * @brief Apply pressure correction for Taylor-Hood elements                                     
    *                                                                                               
    * Interpolates pressure at edge nodes for Taylor-Hood type elements.                            
    */                                                                                              
   static void correct_taylor_hood_pressure(Simulation* simulation);                                
 };                                                                                                 
                                                                                                    
 Call site updates:                                                                                 
 // Before                                                                                          
 pic::picp(simulation);                                                                             
 pic::pici(simulation, Ag, Yg, Dg);                                                                 
 pic::picc(simulation);                                                                             
                                                                                                    
 // After                                                                                           
 TimeIntegration::predict(simulation);                                                              
TimeIntegration::initialize_step(simulation, Ag, Yg, Dg);  
TimeIntegration::correct(simulation);                      

### Additional context

_No response_

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct and Contributing Guidelines

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions