Orchestrates a single time step of the Eulerian fluid solver.
This function is the refactored, high-level entry point for advancing the fluid state from time t_n to t_{n+1}. It is a direct adaptation of the legacy Flow_Solver, but it now takes the master SimCtx as its primary argument to eliminate dependencies on global variables.
27{
28 PetscErrorCode ierr;
30 PetscInt level = usermg->
mglevels - 1;
32 PetscReal tm_s, tm_e, tp_e, tpr_e;
33
34 PetscFunctionBeginUser;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
91 ierr = PetscTime(&tm_s); CHKERRQ(ierr);
92
94
96
97 ierr =
ImpRK(user, NULL, NULL); CHKERRQ(ierr);
98 } else {
99
101
102 ierr =
RungeKutta(user, NULL, NULL); CHKERRQ(ierr);
103 }
104
105 ierr = PetscTime(&tm_e); CHKERRQ(ierr);
107
108
109
110
111 PetscReal unorm, pnorm, phinorm;
112 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
113 VecNorm(user[bi].Ucont, NORM_2, &unorm);
114 VecNorm(user[bi].P, NORM_2, &pnorm);
115 VecNorm(user[bi].Phi,NORM_2,&phinorm);
116 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"Before Correction (Block %d): Ucont Norm = %e, P Norm = %e Phi Norm = %e \n", bi, unorm, pnorm, phinorm);
119 }
120
121 unorm = 0.0;
122 pnorm = 0.0;
123 phinorm = 0.0;
124
125
126
127
128
129
130
132
135 } else {
136
138 }
139
140 ierr = PetscTime(&tp_e); CHKERRQ(ierr);
142
143
144
145
146
147
148
150 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
153
155
157
158
160 }
161
162 ierr = PetscTime(&tpr_e); CHKERRQ(ierr);
164
165
166
167
168
169 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
170 VecNorm(user[bi].Ucont, NORM_2, &unorm);
171 VecNorm(user[bi].P, NORM_2, &pnorm);
172 VecNorm(user[bi].Phi,NORM_2,&phinorm);
173 LOG_ALLOW(
GLOBAL,
LOG_DEBUG,
"After Correction (Block %d): Ucont Norm = %e, P Norm = %e, Phi Norm = %e\n", bi, unorm, pnorm,phinorm);
174 }
175
176
177
178
179
180
181 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
183
184
185
187
188
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210 }
211
212
213
215 simCtx->
step, tm_e - tm_s, tp_e - tm_e, tpr_e - tp_e, tpr_e - tm_s);
216
219 PetscFunctionReturn(0);
220}
PetscErrorCode ImpRK(UserCtx *user, IBMNodes *ibm, FSInfo *fsi)
Advances the momentum equations using an iterative explicit Runge-Kutta scheme.
PetscErrorCode RungeKutta(UserCtx *user, IBMNodes *ibm, FSInfo *fsi)
Advances the momentum equations using an explicit 4th-order Runge-Kutta scheme.
#define GLOBAL
Scope for global logging across all processes.
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
#define PROFILE_FUNCTION_END
Marks the end of a profiled code block.
#define LOG_PROFILE_MSG(scope, fmt,...)
PetscErrorCode LOG_CONTINUITY_METRICS(UserCtx *user)
Logs continuity metrics for a single block to a file.
@ LOG_INFO
Informational messages about program execution.
@ LOG_WARNING
Non-critical issues that warrant attention.
@ LOG_DEBUG
Detailed debugging information.
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled code block (typically a function).
PetscErrorCode Projection(UserCtx *user)
Corrects the contravariant velocity field Ucont to be divergence-free using the gradient of the press...
PetscErrorCode UpdatePressure(UserCtx *user)
Updates the pressure field P with the pressure correction Phi computed by the Poisson solver.
PetscErrorCode PoissonSolver_MG(UserMG *usermg)
Solves the pressure-Poisson equation using a geometric multigrid method.
PetscErrorCode Divergence(UserCtx *user)
PetscErrorCode UpdateLocalGhosts(UserCtx *user, const char *fieldName)
Updates the local vector (including ghost points) from its corresponding global vector.
User-defined context containing data specific to a single computational grid level.
User-level context for managing the entire multigrid hierarchy.