SimVascular / SimVascular/svMultiPhysics

Refactor pic namespace to TimeIntegration class

Open
#459 4 comments 1 reaction 1 assignee View on GitHub

@Eleven7825 is already working on this.

Since Oct 31, 2025.

enhancement
Dominant language
C++
Stars
45
Forks
60
Avg merge
5d 23h
Merged PRs (30d)
11

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.