PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
test_runtime_kernels.c
Go to the documentation of this file.
1/**
2 * @file test_runtime_kernels.c
3 * @brief C test module for PICurv.
4 */
5
6#include "test_support.h"
7
8#include "BC_Handlers.h"
9#include "ParticleMotion.h"
10#include "ParticlePhysics.h"
11#include "ParticleSwarm.h"
12#include "initialcondition.h"
13#include "les.h"
14#include "runloop.h"
15#include "setup.h"
16#include "wallfunction.h"
17/**
18 * @brief Test-local routine.
19 */
20
22{
23 PetscInt particles_per_rank = -1;
24 PetscInt remainder = -1;
25
26 PetscFunctionBeginUser;
27 PetscCall(DistributeParticles(10, 0, 3, &particles_per_rank, &remainder));
28 PetscCall(PicurvAssertIntEqual(4, particles_per_rank, "rank 0 should receive one remainder particle"));
29 PetscCall(PicurvAssertIntEqual(1, remainder, "remainder should be reported correctly"));
30
31 PetscCall(DistributeParticles(10, 2, 3, &particles_per_rank, &remainder));
32 PetscCall(PicurvAssertIntEqual(3, particles_per_rank, "last rank should receive base particle count"));
33 PetscCall(PicurvAssertIntEqual(1, remainder, "remainder should remain unchanged across ranks"));
34 PetscFunctionReturn(0);
35}
36/**
37 * @brief Test-local routine.
38 */
39
41{
42 BoundingBox bbox;
43 Particle particle;
44
45 PetscFunctionBeginUser;
46 PetscCall(PetscMemzero(&bbox, sizeof(bbox)));
47 PetscCall(PetscMemzero(&particle, sizeof(particle)));
48
49 bbox.min_coords.x = 0.0;
50 bbox.min_coords.y = 0.0;
51 bbox.min_coords.z = 0.0;
52 bbox.max_coords.x = 1.0;
53 bbox.max_coords.y = 2.0;
54 bbox.max_coords.z = 3.0;
55
56 particle.loc.x = 0.25;
57 particle.loc.y = 1.0;
58 particle.loc.z = 2.5;
59 PetscCall(PicurvAssertBool(IsParticleInsideBoundingBox(&bbox, &particle), "particle should be inside bounding box"));
60
61 particle.loc.x = 1.5;
62 PetscCall(PicurvAssertBool((PetscBool)!IsParticleInsideBoundingBox(&bbox, &particle), "particle should be outside bounding box"));
63 PetscFunctionReturn(0);
64}
65/**
66 * @brief Test-local routine.
67 */
68
70{
71 Particle particle;
72 PetscReal distances[NUM_FACES] = {1.0, 3.0, 2.0, 2.0, 4.0, 1.0};
73 PetscReal clamped[NUM_FACES] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
74
75 PetscFunctionBeginUser;
76 PetscCall(PetscMemzero(&particle, sizeof(particle)));
77 PetscCall(UpdateParticleWeights(distances, &particle));
78 PetscCall(PicurvAssertRealNear(0.25, particle.weights.x, 1.0e-12, "x interpolation weight"));
79 PetscCall(PicurvAssertRealNear(0.5, particle.weights.y, 1.0e-12, "y interpolation weight"));
80 PetscCall(PicurvAssertRealNear(0.2, particle.weights.z, 1.0e-12, "z interpolation weight"));
81
82 PetscCall(UpdateParticleWeights(clamped, &particle));
83 PetscCall(PicurvAssertRealNear(0.5, particle.weights.x, 1.0e-12, "clamped x weight remains centered"));
84 PetscCall(PicurvAssertRealNear(0.5, particle.weights.y, 1.0e-12, "clamped y weight remains centered"));
85 PetscCall(PicurvAssertRealNear(0.5, particle.weights.z, 1.0e-12, "clamped z weight remains centered"));
86 PetscFunctionReturn(0);
87}
88/**
89 * @brief Test-local routine.
90 */
91
93{
94 SimCtx *simCtx = NULL;
95 UserCtx *user = NULL;
96 Particle particle;
97
98 PetscFunctionBeginUser;
99 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
100 simCtx->dt = 0.25;
101
102 PetscCall(PetscMemzero(&particle, sizeof(particle)));
103 particle.loc.x = 1.0;
104 particle.loc.y = -2.0;
105 particle.loc.z = 3.0;
106 particle.vel.x = 0.5;
107 particle.vel.y = -1.0;
108 particle.vel.z = 2.0;
109 particle.diffusivitygradient.x = 0.1;
110 particle.diffusivitygradient.y = 0.2;
111 particle.diffusivitygradient.z = -0.3;
112 particle.diffusivity = 0.0;
113
114 PetscCall(UpdateParticlePosition(user, &particle));
115 PetscCall(PicurvAssertRealNear(1.15, particle.loc.x, 1.0e-12, "x position update"));
116 PetscCall(PicurvAssertRealNear(-2.2, particle.loc.y, 1.0e-12, "y position update"));
117 PetscCall(PicurvAssertRealNear(3.425, particle.loc.z, 1.0e-12, "z position update"));
118
119 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
120 PetscFunctionReturn(0);
121}
122/**
123 * @brief Test-local routine.
124 */
125
126static PetscErrorCode TestUpdateParticleFieldIEMRelaxation(void)
127{
128 PetscReal psi = 1.0;
129 const PetscReal dt = 0.5;
130 const PetscReal diffusivity = 0.2;
131 const PetscReal mean_val = 3.0;
132 const PetscReal cell_vol = 8.0;
133 const PetscReal c_model = 2.0;
134 PetscReal unchanged = 7.0;
135
136 PetscFunctionBeginUser;
137 PetscCall(UpdateParticleField("Psi", dt, &psi, diffusivity, mean_val, cell_vol, c_model));
138 PetscCall(PicurvAssertRealNear(
139 mean_val + (1.0 - mean_val) * PetscExpReal(-(c_model * diffusivity / PetscPowReal(cell_vol, 0.6666667)) * dt),
140 psi,
141 1.0e-12,
142 "IEM update should match analytical relaxation"));
143
144 PetscCall(UpdateParticleField("UnrelatedField", dt, &unchanged, diffusivity, mean_val, cell_vol, c_model));
145 PetscCall(PicurvAssertRealNear(7.0, unchanged, 1.0e-12, "unknown field should remain unchanged"));
146 PetscFunctionReturn(0);
147}
148/**
149 * @brief Test-local routine.
150 */
151
153{
154 SimCtx *simCtx = NULL;
155 UserCtx *user = NULL;
156
157 PetscFunctionBeginUser;
158 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
159 PetscCall(VecSet(user->Ucont, 7.0));
160
161 PetscCall(SetInitialInteriorField(user, "P"));
162 PetscCall(PicurvAssertVecConstant(user->Ucont, 7.0, 1.0e-12, "non-Ucont request should not modify Ucont"));
163
164 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
165 PetscFunctionReturn(0);
166}
167/**
168 * @brief Test-local routine.
169 */
170
172{
173 SimCtx *simCtx = NULL;
174 UserCtx *user = NULL;
175 Cmpnts ***ucont = NULL;
176
177 PetscFunctionBeginUser;
178 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 5, 5, 5));
179 user->GridOrientation = 1;
181 simCtx->FieldInitialization = 1;
182 simCtx->InitialConstantContra.x = 0.0;
183 simCtx->InitialConstantContra.y = 0.0;
184 simCtx->InitialConstantContra.z = 2.0;
185 PetscCall(VecSet(user->Ucont, 0.0));
186
187 PetscCall(SetInitialInteriorField(user, "Ucont"));
188 PetscCall(DMDAVecGetArrayRead(user->fda, user->Ucont, &ucont));
189 PetscCall(PicurvAssertRealNear(0.0, ucont[1][1][1].x, 1.0e-12, "x contravariant component remains zero"));
190 PetscCall(PicurvAssertRealNear(0.0, ucont[1][1][1].y, 1.0e-12, "y contravariant component remains zero"));
191 PetscCall(PicurvAssertRealNear(2.0, ucont[1][1][1].z, 1.0e-12, "z contravariant component should match constant inlet magnitude"));
192 PetscCall(PicurvAssertRealNear(0.0, ucont[0][1][1].z, 1.0e-12, "boundary/ghost cell should remain unchanged"));
193 PetscCall(DMDAVecRestoreArrayRead(user->fda, user->Ucont, &ucont));
194
195 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
196 PetscFunctionReturn(0);
197}
198/**
199 * @brief Test-local routine.
200 */
201
202static PetscErrorCode TestWallNoSlipAndFreeSlipHelpers(void)
203{
204 Cmpnts wall_velocity = {0.0, 0.0, 0.0};
205 Cmpnts reference_velocity = {2.0, 4.0, 6.0};
206 Cmpnts boundary_velocity = {0.0, 0.0, 0.0};
207 Cmpnts free_slip_reference = {2.0, 3.0, 4.0};
208
209 PetscFunctionBeginUser;
210 noslip(NULL, 2.0, 1.0, wall_velocity, reference_velocity, &boundary_velocity, 1.0, 0.0, 0.0);
211 PetscCall(PicurvAssertRealNear(1.0, boundary_velocity.x, 1.0e-12, "no-slip interpolated x"));
212 PetscCall(PicurvAssertRealNear(2.0, boundary_velocity.y, 1.0e-12, "no-slip interpolated y"));
213 PetscCall(PicurvAssertRealNear(3.0, boundary_velocity.z, 1.0e-12, "no-slip interpolated z"));
214
215 freeslip(NULL, 2.0, 1.0, wall_velocity, free_slip_reference, &boundary_velocity, 1.0, 0.0, 0.0);
216 PetscCall(PicurvAssertRealNear(1.0, boundary_velocity.x, 1.0e-12, "free-slip interpolated normal component"));
217 PetscCall(PicurvAssertRealNear(3.0, boundary_velocity.y, 1.0e-12, "free-slip tangential y preserved"));
218 PetscCall(PicurvAssertRealNear(4.0, boundary_velocity.z, 1.0e-12, "free-slip tangential z preserved"));
219 PetscFunctionReturn(0);
220}
221/**
222 * @brief Test-local routine.
223 */
224
225static PetscErrorCode TestWallModelScalarHelpers(void)
226{
227 const PetscReal expected_smooth_e = PetscExpReal(0.41 * 5.5);
228 PetscReal e_coeff = 0.0;
229 PetscReal utau = 0.0;
230 PetscReal residual = 0.0;
231
232 PetscFunctionBeginUser;
233 e_coeff = E_coeff(0.1, 0.0, 1.0e-3);
234 PetscCall(PicurvAssertRealNear(expected_smooth_e, e_coeff, 1.0e-10, "smooth-wall E coefficient"));
235
236 utau = find_utau_hydset(1.0e-3, 1.0, 1.0e-2, 0.1, 0.0);
237 PetscCall(PicurvAssertBool((PetscBool)(utau > 0.0), "friction velocity should remain positive"));
238 residual = f_hydset(1.0e-3, 1.0, 1.0e-2, utau, 0.0);
239 PetscCall(PicurvAssertBool((PetscBool)(PetscAbsReal(residual) < 1.0e-5), "Newton solve residual should be small"));
240
241 PetscCall(PicurvAssertRealNear(0.0, nu_t(0.0), 1.0e-12, "eddy viscosity ratio at wall"));
242 PetscCall(PicurvAssertBool((PetscBool)(integrate_1(1.0e-3, 1.0e-2, 0.1, 0) > 0.0), "integral helper should be positive"));
243 PetscFunctionReturn(0);
244}
245/**
246 * @brief Test-local routine.
247 */
248
250{
251 SimCtx *simCtx = NULL;
252 UserCtx *user = NULL;
253
254 PetscFunctionBeginUser;
255 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
256 PetscCall(Validate_DrivenFlowConfiguration(user));
257 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
258 PetscFunctionReturn(0);
259}
260/**
261 * @brief Test-local routine.
262 */
263
265{
266 SimCtx *simCtx = NULL;
267 UserCtx *user = NULL;
268
269 PetscFunctionBeginUser;
270 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 4, 4, 4));
271 PetscCall(DMCreateGlobalVector(user->da, &user->CS));
272 simCtx->step = 2;
273 simCtx->StartStep = 0;
274 simCtx->les = CONSTANT_SMAGORINSKY;
275 simCtx->Const_CS = 0.17;
276
277 PetscCall(ComputeSmagorinskyConstant(user));
278 PetscCall(PicurvAssertVecConstant(user->CS, 0.17, 1.0e-12, "constant Smagorinsky branch should fill CS"));
279
280 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
281 PetscFunctionReturn(0);
282}
283/**
284 * @brief Test-local routine.
285 */
286
288{
289 SimCtx *simCtx = NULL;
290 UserCtx *user = NULL;
291
292 PetscFunctionBeginUser;
293 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 5, 5, 5));
294
295 PetscCall(DMCreateGlobalVector(user->fda, &user->Ucont_o));
296 PetscCall(DMCreateGlobalVector(user->fda, &user->Ucont_rm1));
297 PetscCall(DMCreateLocalVector(user->fda, &user->lUcont_o));
298 PetscCall(DMCreateLocalVector(user->fda, &user->lUcont_rm1));
299 PetscCall(DMCreateGlobalVector(user->fda, &user->Ucat_o));
300 PetscCall(DMCreateGlobalVector(user->da, &user->P_o));
301
302 PetscCall(VecSet(user->Ucont, 11.0));
303 PetscCall(VecSet(user->Ucont_o, 7.0));
304 PetscCall(VecSet(user->Ucont_rm1, 3.0));
305 PetscCall(VecSet(user->Ucat, 5.0));
306 PetscCall(VecSet(user->Ucat_o, -1.0));
307 PetscCall(VecSet(user->P, 9.0));
308 PetscCall(VecSet(user->P_o, -2.0));
309
310 PetscCall(UpdateSolverHistoryVectors(user));
311
312 PetscCall(PicurvAssertVecConstant(user->Ucont_o, 11.0, 1.0e-12, "Ucont_o should receive current Ucont"));
313 PetscCall(PicurvAssertVecConstant(user->Ucont_rm1, 7.0, 1.0e-12, "Ucont_rm1 should receive prior Ucont_o"));
314 PetscCall(PicurvAssertVecConstant(user->Ucat_o, 5.0, 1.0e-12, "Ucat_o should receive current Ucat"));
315 PetscCall(PicurvAssertVecConstant(user->P_o, 9.0, 1.0e-12, "P_o should receive current P"));
316 PetscCall(PicurvAssertVecConstant(user->lUcont_o, 11.0, 1.0e-12, "lUcont_o ghost sync should match Ucont_o"));
317 PetscCall(PicurvAssertVecConstant(user->lUcont_rm1, 7.0, 1.0e-12, "lUcont_rm1 ghost sync should match Ucont_rm1"));
318
319 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
320 PetscFunctionReturn(0);
321}
322/**
323 * @brief Test-local routine.
324 */
325
327{
328 SimCtx *simCtx = NULL;
329 UserCtx *user = NULL;
330 PetscInt xs = -1, ys = -1, zs = -1;
331 PetscInt xm = -1, ym = -1, zm = -1;
332
333 PetscFunctionBeginUser;
334 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 8, 6, 4));
335
336 PetscCall(GetOwnedCellRange(&user->info, 0, &xs, &xm));
337 PetscCall(GetOwnedCellRange(&user->info, 1, &ys, &ym));
338 PetscCall(GetOwnedCellRange(&user->info, 2, &zs, &zm));
339
340 PetscCall(PicurvAssertIntEqual(0, xs, "single-rank x cell-start index"));
341 PetscCall(PicurvAssertIntEqual(0, ys, "single-rank y cell-start index"));
342 PetscCall(PicurvAssertIntEqual(0, zs, "single-rank z cell-start index"));
343 PetscCall(PicurvAssertIntEqual(user->info.mx - 2, xm, "single-rank x owned cell count"));
344 PetscCall(PicurvAssertIntEqual(user->info.my - 2, ym, "single-rank y owned cell count"));
345 PetscCall(PicurvAssertIntEqual(user->info.mz - 2, zm, "single-rank z owned cell count"));
346
347 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
348 PetscFunctionReturn(0);
349}
350/**
351 * @brief Test-local routine.
352 */
353
355{
356 SimCtx *simCtx = NULL;
357 UserCtx *user = NULL;
358
359 PetscFunctionBeginUser;
360 PetscCall(PicurvCreateMinimalContexts(&simCtx, &user, 6, 6, 6));
361 PetscCall(ComputeAndStoreNeighborRanks(user));
362
363 PetscCall(PicurvAssertIntEqual(MPI_PROC_NULL, user->neighbors.rank_xm, "single-rank xm neighbor should be null"));
364 PetscCall(PicurvAssertIntEqual(MPI_PROC_NULL, user->neighbors.rank_xp, "single-rank xp neighbor should be null"));
365 PetscCall(PicurvAssertIntEqual(MPI_PROC_NULL, user->neighbors.rank_ym, "single-rank ym neighbor should be null"));
366 PetscCall(PicurvAssertIntEqual(MPI_PROC_NULL, user->neighbors.rank_yp, "single-rank yp neighbor should be null"));
367 PetscCall(PicurvAssertIntEqual(MPI_PROC_NULL, user->neighbors.rank_zm, "single-rank zm neighbor should be null"));
368 PetscCall(PicurvAssertIntEqual(MPI_PROC_NULL, user->neighbors.rank_zp, "single-rank zp neighbor should be null"));
369
370 PetscCall(PicurvDestroyMinimalContexts(&simCtx, &user));
371 PetscFunctionReturn(0);
372}
373/**
374 * @brief Entry point for this unit-test binary.
375 */
376
377int main(int argc, char **argv)
378{
379 PetscErrorCode ierr;
380 const PicurvTestCase cases[] = {
381 {"distribute-particles-remainder-handling", TestDistributeParticlesRemainderHandling},
382 {"is-particle-inside-bbox-basic-cases", TestIsParticleInsideBoundingBoxBasicCases},
383 {"update-particle-weights-computes-expected-ratios", TestUpdateParticleWeightsComputesExpectedRatios},
384 {"update-particle-position-without-brownian-contribution", TestUpdateParticlePositionWithoutBrownianContribution},
385 {"update-particle-field-iem-relaxation", TestUpdateParticleFieldIEMRelaxation},
386 {"set-initial-interior-field-ignores-non-ucont-request", TestSetInitialInteriorFieldIgnoresNonUcontRequest},
387 {"set-initial-interior-field-constant-profile-on-z-inlet", TestSetInitialInteriorFieldConstantProfileOnZInlet},
388 {"wall-noslip-and-freeslip-helpers", TestWallNoSlipAndFreeSlipHelpers},
389 {"wall-model-scalar-helpers", TestWallModelScalarHelpers},
390 {"validate-driven-flow-configuration-no-driven-handlers", TestValidateDrivenFlowConfigurationNoDrivenHandlers},
391 {"compute-smagorinsky-constant-constant-model", TestComputeSmagorinskyConstantConstantModel},
392 {"update-solver-history-vectors-shifts-states", TestUpdateSolverHistoryVectorsShiftsStates},
393 {"get-owned-cell-range-single-rank-accounting", TestGetOwnedCellRangeSingleRankAccounting},
394 {"compute-and-store-neighbor-ranks-single-rank", TestComputeAndStoreNeighborRanksSingleRank},
395 };
396
397 ierr = PetscInitialize(&argc, &argv, NULL, "PICurv runtime-kernel tests");
398 if (ierr) {
399 return (int)ierr;
400 }
401
402 ierr = PicurvRunTests("unit-runtime", cases, sizeof(cases) / sizeof(cases[0]));
403 if (ierr) {
404 PetscFinalize();
405 return (int)ierr;
406 }
407
408 ierr = PetscFinalize();
409 return (int)ierr;
410}
PetscErrorCode Validate_DrivenFlowConfiguration(UserCtx *user)
(Private) Validates all consistency rules for a driven flow (channel/pipe) setup.
Definition BC_Handlers.c:15
Header file for Particle Motion and migration related functions.
PetscErrorCode UpdateParticlePosition(UserCtx *user, Particle *particle)
Updates a particle's position based on its velocity and the timestep dt (stored in user->dt).
Header file for Particle related physics modules.
PetscErrorCode UpdateParticleField(const char *fieldName, PetscReal dt, PetscReal *psi_io, PetscReal diffusivity, PetscReal mean_val, PetscReal cell_vol, PetscReal C_model)
Updates a single particle's field based on its state and physics model.
Header file for Particle Swarm management functions.
PetscErrorCode UpdateParticleWeights(PetscReal *d, Particle *particle)
Updates a particle's interpolation weights based on distances to cell faces.
PetscErrorCode DistributeParticles(PetscInt numParticles, PetscMPIInt rank, PetscMPIInt size, PetscInt *particlesPerProcess, PetscInt *remainder)
Distributes particles evenly across MPI processes, handling any remainders.
PetscBool IsParticleInsideBoundingBox(const BoundingBox *bbox, const Particle *particle)
Checks if a particle's location is within a specified bounding box.
PetscErrorCode SetInitialInteriorField(UserCtx *user, const char *fieldName)
Sets the initial values for the INTERIOR of a specified Eulerian field.
PetscErrorCode ComputeSmagorinskyConstant(UserCtx *user)
Computes the dynamic Smagorinsky constant (Cs) for the LES model.
Definition les.c:30
PetscErrorCode UpdateSolverHistoryVectors(UserCtx *user)
Copies the current time step's solution fields into history vectors (e.g., U(t_n) -> U_o,...
Definition runloop.c:13
PetscErrorCode GetOwnedCellRange(const DMDALocalInfo *info_nodes, PetscInt dim, PetscInt *xs_cell_global_out, PetscInt *xm_cell_local_out)
Determines the global starting index and number of CELLS owned by the current processor in a specifie...
Definition setup.c:1640
PetscErrorCode ComputeAndStoreNeighborRanks(UserCtx *user)
Computes and stores the Cartesian neighbor ranks for the DMDA decomposition.
Definition setup.c:1737
static PetscErrorCode TestUpdateParticleFieldIEMRelaxation(void)
Test-local routine.
static PetscErrorCode TestSetInitialInteriorFieldConstantProfileOnZInlet(void)
Test-local routine.
static PetscErrorCode TestSetInitialInteriorFieldIgnoresNonUcontRequest(void)
Test-local routine.
int main(int argc, char **argv)
Entry point for this unit-test binary.
static PetscErrorCode TestDistributeParticlesRemainderHandling(void)
Test-local routine.
static PetscErrorCode TestGetOwnedCellRangeSingleRankAccounting(void)
Test-local routine.
static PetscErrorCode TestUpdateParticlePositionWithoutBrownianContribution(void)
Test-local routine.
static PetscErrorCode TestComputeAndStoreNeighborRanksSingleRank(void)
Test-local routine.
static PetscErrorCode TestValidateDrivenFlowConfigurationNoDrivenHandlers(void)
Test-local routine.
static PetscErrorCode TestWallNoSlipAndFreeSlipHelpers(void)
Test-local routine.
static PetscErrorCode TestComputeSmagorinskyConstantConstantModel(void)
Test-local routine.
static PetscErrorCode TestUpdateSolverHistoryVectorsShiftsStates(void)
Test-local routine.
static PetscErrorCode TestUpdateParticleWeightsComputesExpectedRatios(void)
Test-local routine.
static PetscErrorCode TestIsParticleInsideBoundingBoxBasicCases(void)
Test-local routine.
static PetscErrorCode TestWallModelScalarHelpers(void)
Test-local routine.
PetscErrorCode PicurvCreateMinimalContexts(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz)
Shared test-support routine.
PetscErrorCode PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context)
Shared test-support routine.
PetscErrorCode PicurvDestroyMinimalContexts(SimCtx **simCtx_ptr, UserCtx **user_ptr)
Shared test-support routine.
PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count)
Shared test-support routine.
PetscErrorCode PicurvAssertVecConstant(Vec vec, PetscScalar expected, PetscReal tol, const char *context)
Shared test-support routine.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Shared test-support routine.
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Shared test-support routine.
C test module for PICurv.
Named test case descriptor consumed by PicurvRunTests.
PetscMPIInt rank_zm
Definition variables.h:182
@ CONSTANT_SMAGORINSKY
Definition variables.h:449
Cmpnts vel
Definition variables.h:169
PetscMPIInt rank_yp
Definition variables.h:181
BCFace identifiedInletBCFace
Definition variables.h:758
PetscMPIInt rank_ym
Definition variables.h:181
PetscMPIInt rank_xp
Definition variables.h:180
PetscInt FieldInitialization
Definition variables.h:643
Vec lUcont_rm1
Definition variables.h:772
Cmpnts max_coords
Maximum x, y, z coordinates of the bounding box.
Definition variables.h:156
Cmpnts diffusivitygradient
Definition variables.h:174
PetscReal dt
Definition variables.h:606
RankNeighbors neighbors
Definition variables.h:750
Vec Ucont
Definition variables.h:764
PetscInt StartStep
Definition variables.h:601
Cmpnts min_coords
Minimum x, y, z coordinates of the bounding box.
Definition variables.h:155
PetscScalar x
Definition variables.h:101
Cmpnts loc
Definition variables.h:168
Vec lUcont_o
Definition variables.h:771
Vec Ucat_o
Definition variables.h:771
PetscMPIInt rank_xm
Definition variables.h:180
PetscScalar z
Definition variables.h:101
Vec Ucat
Definition variables.h:764
PetscReal Const_CS
Definition variables.h:678
Vec Ucont_o
Definition variables.h:771
Cmpnts InitialConstantContra
Definition variables.h:644
PetscMPIInt rank_zp
Definition variables.h:182
Vec Ucont_rm1
Definition variables.h:772
PetscReal diffusivity
Definition variables.h:173
PetscInt step
Definition variables.h:599
PetscInt GridOrientation
Definition variables.h:751
DMDALocalInfo info
Definition variables.h:745
PetscScalar y
Definition variables.h:101
Cmpnts weights
Definition variables.h:170
@ NUM_FACES
Definition variables.h:145
PetscInt les
Definition variables.h:676
Vec P_o
Definition variables.h:771
@ BC_FACE_NEG_Z
Definition variables.h:206
Defines a 3D axis-aligned bounding box.
Definition variables.h:154
A 3D point or vector with PetscScalar components.
Definition variables.h:100
Defines a particle's core properties for Lagrangian tracking.
Definition variables.h:165
The master context for the entire simulation.
Definition variables.h:591
User-defined context containing data specific to a single computational grid level.
Definition variables.h:738
double find_utau_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double initial_guess, double roughness_height)
Solves for friction velocity using Newton-Raphson iteration.
void noslip(UserCtx *user, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, double normal_x, double normal_y, double normal_z)
Applies no-slip wall boundary condition with linear interpolation.
double integrate_1(double kinematic_viscosity, double wall_distance, double friction_velocity, int integration_mode)
Integrates eddy viscosity profile from wall to distance y.
double f_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
Residual function for friction velocity equation (log-law with roughness)
double E_coeff(double friction_velocity, double roughness_height, double kinematic_viscosity)
Computes roughness-modified log-law coefficient E.
double nu_t(double yplus)
Computes turbulent eddy viscosity ratio (ν_t / ν)
void freeslip(UserCtx *user, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, double normal_x, double normal_y, double normal_z)
Applies free-slip wall boundary condition.