PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
picsolver.c File Reference
#include "simulation.h"
Include dependency graph for picsolver.c:

Go to the source code of this file.

Macros

#define __FUNCT__   "main"
 

Functions

int main (int argc, char **argv)
 

Macro Definition Documentation

◆ __FUNCT__

#define __FUNCT__   "main"

Definition at line 23 of file picsolver.c.

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 24 of file picsolver.c.

25{
26 PetscErrorCode ierr;
27 SimCtx *simCtx = NULL; // The single, top-level context object
28
29 // === I. INITIALIZE =======================================================
30 ierr = PetscInitialize(&argc, &argv, (char *)0, "PIC-Solver"); CHKERRQ(ierr);
31
32 // === II. CONFIGURE =======================================================
33 // Create and populate the entire simulation configuration from command line.
34 ierr = CreateSimulationContext(argc, argv, &simCtx); CHKERRQ(ierr);
35 // == IIB. SET EXECUTION MODE (SOLVER vs POST-PROCESSOR) =====
37 // == IIC. CONFIGURE SIMULATION ENVIRONMENT & DIRECTORIES =====
38 ierr = SetupSimulationEnvironment(simCtx); CHKERRQ(ierr);
39
40 // === III. SETUP ==========================================================
41 // Build the simulation environment step-by-step.
42
43 // 1. Setup the multi-grid hierarchy, DMs, and PETSc vectors/solvers.
44 ierr = SetupGridAndSolvers(simCtx); CHKERRQ(ierr);
45
46 // 2. Setup the boundary condition handlers for the flow solver.
47 ierr = SetupBoundaryConditions(simCtx); CHKERRQ(ierr);
48
49 // 3. Setup domain decomposition info needed for particle migration.
50 ierr = SetupDomainRankInfo(simCtx); CHKERRQ(ierr);
51
52 // 4. Setup Initial State of Eulerian Fields
53 ierr = InitializeEulerianState(simCtx); CHKERRQ(ierr);
54
55 // 5. If requested, initialize the Lagrangian Particle Swarm.
56 if (simCtx->np > 0) {
57 ierr = InitializeParticleSwarm(simCtx); CHKERRQ(ierr);
58 }
59
60 LOG_ALLOW(GLOBAL,LOG_INFO," Setup Completed.\n");
61
62
63 /*
64 * --- IBM/FSI FEATURE HOOK (Currently Inactive) ---
65 * The logic for initializing immersed bodies would be enabled here.
66 * The `-immersed` command-line flag would control this block.
67 *
68 if (simCtx->immersed) {
69 ierr = InitializeImmersedBoundary(simCtx); CHKERRQ(ierr);
70 }
71 */
72
73 // === IV. EXECUTE =========================================================
74 // Display a summary banner and run the main time-stepping loop.
75
76 ierr = DisplayBanner(simCtx); CHKERRQ(ierr);
77
78 if (!simCtx->OnlySetup) {
79 // This function will contain the main time loop, orchestrating
80 // the flow solve and particle advection steps.
81
82 if(simCtx->StartStep == 0){
83 if(simCtx->np>0){
84 ierr = PerformInitializedParticleSetup(simCtx); CHKERRQ(ierr);
85 }else{
86 // Write the initial Eulerian fields.
87 UserCtx *user = simCtx->usermg.mgctx[simCtx->usermg.mglevels-1].user;
88 for(PetscInt bi = 0; bi < simCtx->block_number; bi++){
89 ierr = WriteSimulationFields(&user[bi]);
90 }
91 }
92 }else{
93 ierr = FinalizeRestartState(simCtx); CHKERRQ(ierr);
94 }
95
96 //********************PROFILING ROUTINES ****************************
97 // Before the first step, clear all counters accumulated during setup
98 // to ensure the Timestep 1 profile is clean.
99 ierr = ProfilingLogTimestepSummary(simCtx->step);
100 ierr = ProfilingResetTimestepCounters(); CHKERRQ(ierr);
101 //*******************************************************************
102
103 if(simCtx->StepsToRun > 0){
104 ierr = AdvanceSimulation(simCtx); CHKERRQ(ierr);
105 }else{
106 LOG_ALLOW(GLOBAL,LOG_INFO,"Initial setup complete.No steps to run.Exiting!.\n");
107 }
108 }else{
109 LOG_ALLOW(GLOBAL,LOG_INFO,"SETUP ONLY MODE enabled. Skipping time loop.\n");
110 }
111
112 // == V. REPORT FIELDS ===========================
113
114 // === V. FINALIZE =========================================================
115 // Cleanly destroy all objects and free all memory.
116
117 ierr = ProfilingFinalize(simCtx); CHKERRQ(ierr);
118 // ierr = FinalizeSimulation(simCtx); CHKERRQ(ierr);
119 ierr = PetscFinalize();
120
121 return ierr;
122}
PetscErrorCode InitializeParticleSwarm(SimCtx *simCtx)
Perform particle swarm initialization, particle-grid interaction, and related operations.
PetscErrorCode InitializeEulerianState(SimCtx *simCtx)
High-level orchestrator to set the complete initial state of the Eulerian solver.
PetscErrorCode WriteSimulationFields(UserCtx *user)
Writes simulation fields to files.
Definition io.c:1536
PetscErrorCode DisplayBanner(SimCtx *simCtx)
Displays a structured banner summarizing the simulation configuration.
Definition io.c:2082
#define GLOBAL
Scope for global logging across all processes.
Definition logging.h:47
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
Definition logging.h:201
PetscErrorCode ProfilingFinalize(SimCtx *simCtx)
the profiling excercise and build a profiling summary which is then printed to a log file.
Definition logging.c:1106
@ LOG_INFO
Informational messages about program execution.
Definition logging.h:32
PetscErrorCode ProfilingResetTimestepCounters(void)
Definition logging.c:1037
PetscErrorCode ProfilingLogTimestepSummary(PetscInt step)
Logs the performance summary for the current timestep and resets timers.
Definition logging.c:1047
PetscErrorCode SetupDomainRankInfo(SimCtx *simCtx)
Sets up the full rank communication infrastructure, including neighbor ranks and bounding box exchang...
Definition setup.c:1981
PetscErrorCode SetupGridAndSolvers(SimCtx *simCtx)
The main orchestrator for setting up all grid-related components.
Definition setup.c:857
PetscErrorCode SetupSimulationEnvironment(SimCtx *simCtx)
Verifies and prepares the complete I/O environment for a simulation run.
Definition setup.c:558
PetscErrorCode CreateSimulationContext(int argc, char **argv, SimCtx **p_simCtx)
Allocates and populates the master SimulationContext object.
Definition setup.c:44
PetscErrorCode SetupBoundaryConditions(SimCtx *simCtx)
(Orchestrator) Sets up all boundary conditions for the simulation.
Definition setup.c:1354
PetscErrorCode AdvanceSimulation(SimCtx *simCtx)
Executes the main time-marching loop for the particle simulation.
Definition simulation.c:307
PetscErrorCode FinalizeRestartState(SimCtx *simCtx)
Performs post-load/post-init consistency checks for a restarted simulation.
Definition simulation.c:242
PetscErrorCode PerformInitializedParticleSetup(SimCtx *simCtx)
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
Definition simulation.c:95
UserCtx * user
Definition variables.h:427
PetscInt block_number
Definition variables.h:593
UserMG usermg
Definition variables.h:631
PetscInt StepsToRun
Definition variables.h:549
PetscInt np
Definition variables.h:616
PetscInt StartStep
Definition variables.h:548
PetscBool OnlySetup
Definition variables.h:553
PetscInt mglevels
Definition variables.h:434
PetscInt step
Definition variables.h:546
@ EXEC_MODE_SOLVER
Definition variables.h:511
MGCtx * mgctx
Definition variables.h:437
ExecutionMode exec_mode
Definition variables.h:556
The master context for the entire simulation.
Definition variables.h:538
User-defined context containing data specific to a single computational grid level.
Definition variables.h:661
Here is the call graph for this function: