18 PetscFunctionBeginUser;
19 PetscCheck(head != NULL, PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"BC param list head cannot be NULL.");
20 PetscCall(PetscCalloc1(1, &
node));
21 PetscCall(PetscStrallocpy(key, &
node->key));
22 PetscCall(PetscStrallocpy(value, &
node->value));
24 cursor = &(*cursor)->
next;
27 PetscFunctionReturn(0);
36 PetscFunctionBeginUser;
37 if (!bc_ptr || !*bc_ptr) PetscFunctionReturn(0);
43 PetscCall(PetscFree(bc));
45 PetscFunctionReturn(0);
78 PetscErrorCode ierr_validate = 0;
80 PetscFunctionBeginUser;
85 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
87 PetscCall(PetscPopErrorHandler());
89 PetscCall(
PicurvAssertBool((PetscBool)(ierr_validate != 0),
"unpaired periodic faces should be rejected"));
91 PetscFunctionReturn(0);
101 const Cmpnts ***coor = NULL;
102 PetscReal expected_x = 0.0;
104 PetscFunctionBeginUser;
108 PetscCall(DMGetCoordinates(user->
da, &gcoor));
109 PetscCall(DMDAVecGetArrayRead(user->
fda, gcoor, &coor));
110 expected_x = coor[0][0][user->
info.mx - 2].
x - coor[0][0][0].
x;
111 PetscCall(DMDAVecRestoreArrayRead(user->
fda, gcoor, &coor));
122 PetscFunctionReturn(0);
132 PetscFunctionBeginUser;
142 "mixed-periodic X translation should have nonzero x component"));
144 "mixed-periodic Y translation should have nonzero y component"));
147 PetscFunctionReturn(0);
158 PetscErrorCode ierr_validate = 0;
160 PetscFunctionBeginUser;
164 PetscCall(DMGetCoordinates(user->
da, &gcoor));
165 PetscCall(DMDAVecGetArray(user->
fda, gcoor, &coor));
166 coor[1][1][user->
info.mx - 2].
y += 0.25;
167 PetscCall(DMDAVecRestoreArray(user->
fda, gcoor, &coor));
170 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
172 PetscCall(PetscPopErrorHandler());
174 PetscCall(
PicurvAssertBool((PetscBool)(ierr_validate != 0),
"varying seam translation should be rejected"));
176 PetscFunctionReturn(0);
187 const Cmpnts ***lcentx = NULL;
189 PetscReal translation, spacing;
191 PetscFunctionBeginUser;
196 spacing = translation / (PetscReal)(user->
info.mx - 2);
198 PetscCall(DMDAVecGetArray(user->
fda, user->
Centx, ¢x));
199 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; k++) {
200 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; j++) {
201 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; i++) {
202 centx[k][j][i] = (
Cmpnts){spacing * i, 2.0 + j, 3.0 + k};
206 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Centx, ¢x));
209 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
lCentx, &lcentx));
211 "translated Centx negative adjacent ghost"));
213 "translated Centx negative endpoint"));
215 "translated Centx positive endpoint"));
217 "translated Centx positive adjacent ghost"));
218 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
lCentx, &lcentx));
221 PetscFunctionReturn(0);
232 PetscReal ***nvert = NULL;
234 PetscFunctionBeginUser;
238 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &ucat));
239 PetscCall(DMDAVecGetArray(user->
da, user->
Nvert, &nvert));
240 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; k++) {
241 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; j++) {
242 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; i++) {
243 ucat[k][j][i] = (
Cmpnts){100.0 + i, 200.0 + i, 300.0 + i};
244 nvert[k][j][i] = 400.0 + i;
248 PetscCall(DMDAVecRestoreArray(user->
da, user->
Nvert, &nvert));
249 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &ucat));
254 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
lUcat, &ucat));
255 PetscCall(DMDAVecGetArrayRead(user->
da, user->
lNvert, &nvert));
257 "QUICK Ucat negative outer ghost"));
259 "QUICK Ucat positive outer ghost"));
261 "QUICK Nvert negative outer ghost"));
263 "QUICK Nvert positive outer ghost"));
264 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
lNvert, &nvert));
265 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
lUcat, &ucat));
268 PetscFunctionReturn(0);
277 PetscFunctionBeginUser;
279 PetscCall(
PicurvAssertBool((PetscBool)(bc != NULL),
"periodic geometric factory should allocate a handler"));
281 PetscCall(
PicurvAssertBool((PetscBool)(bc->
Apply == NULL),
"periodic geometric handler should not expose Apply"));
284 PetscFunctionReturn(0);
293 PetscReal ***aj = NULL;
294 PetscReal expected_neg_face = 0.0;
295 PetscReal expected_pos_face = 0.0;
296 PetscReal expected_neg_ghost = 0.0;
297 PetscReal expected_pos_ghost = 0.0;
299 PetscFunctionBeginUser;
304 PetscCall(DMDAVecGetArray(user->
da, user->
Aj, &aj));
305 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
306 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
307 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
308 aj[k][j][i] = 100.0 + (PetscReal)i;
312 PetscCall(DMDAVecRestoreArray(user->
da, user->
Aj, &aj));
313 PetscCall(DMGlobalToLocalBegin(user->
da, user->
Aj, INSERT_VALUES, user->
lAj));
314 PetscCall(DMGlobalToLocalEnd(user->
da, user->
Aj, INSERT_VALUES, user->
lAj));
315 PetscCall(DMDAVecGetArrayRead(user->
da, user->
lAj, &aj));
316 expected_neg_face = aj[2][2][user->
info.mx - 2];
317 expected_pos_face = aj[2][2][1];
318 expected_neg_ghost = expected_pos_face;
319 expected_pos_ghost = expected_neg_face;
320 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
lAj, &aj));
324 PetscCall(DMDAVecGetArrayRead(user->
da, user->
lAj, &aj));
325 PetscCall(
PicurvAssertRealNear(expected_neg_face, aj[2][2][0], 1.0e-12,
"NEG_X periodic metric face should copy from the opposite interior face"));
326 PetscCall(
PicurvAssertRealNear(expected_pos_face, aj[2][2][user->
info.mx - 1], 1.0e-12,
"POS_X periodic metric face should copy from the leading interior face"));
327 PetscCall(
PicurvAssertRealNear(expected_neg_ghost, aj[2][2][-1], 1.0e-12,
"cell-centered Aj negative ghost should retain PETSc wraparound"));
328 PetscCall(
PicurvAssertRealNear(expected_pos_ghost, aj[2][2][user->
info.mx], 1.0e-12,
"cell-centered Aj positive ghost should retain PETSc wraparound"));
329 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
lAj, &aj));
332 PetscFunctionReturn(0);
341 PetscReal ***p = NULL;
342 PetscReal ***cs = NULL;
343 PetscReal ***diffusivity = NULL;
348 PetscFunctionBeginUser;
353 PetscCall(DMCreateGlobalVector(user->
da, &user->
Nu_t));
354 PetscCall(DMCreateLocalVector(user->
da, &user->
lNu_t));
355 PetscCall(VecSet(user->
Nu_t, 5.0));
356 PetscCall(VecSet(user->
lNu_t, 0.0));
357 PetscCall(DMCreateGlobalVector(user->
da, &user->
CS));
358 PetscCall(DMCreateLocalVector(user->
da, &user->
lCs));
359 PetscCall(VecSet(user->
Phi, 3.0));
360 PetscCall(VecSet(user->
Nvert, 4.0));
362 PetscCall(DMDAVecGetArray(user->
da, user->
P, &p));
363 PetscCall(DMDAVecGetArray(user->
da, user->
CS, &cs));
364 PetscCall(DMDAVecGetArray(user->
da, user->
Diffusivity, &diffusivity));
365 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &ucat));
366 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
367 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
368 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
369 PetscReal value = (PetscReal)(i + 10 * j + 100 * k);
371 cs[k][j][i] = value + 4000.0;
372 diffusivity[k][j][i] = value + 5000.0;
373 ucat[k][j][i].
x = value + 1000.0;
374 ucat[k][j][i].
y = value + 2000.0;
375 ucat[k][j][i].
z = value + 3000.0;
379 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &p));
380 PetscCall(DMDAVecRestoreArray(user->
da, user->
CS, &cs));
381 PetscCall(DMDAVecRestoreArray(user->
da, user->
Diffusivity, &diffusivity));
382 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &ucat));
388 PetscCall(DMDAVecGetArrayRead(user->
da, user->
P, &p));
389 PetscCall(DMDAVecGetArrayRead(user->
da, user->
CS, &cs));
390 PetscCall(DMDAVecGetArrayRead(user->
da, user->
Diffusivity, &diffusivity));
391 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
Ucat, &ucat));
393 "x-periodic negative endpoint should copy the opposite interior value"));
395 "x-periodic positive endpoint should copy the leading interior value"));
397 "y-periodic negative endpoint should copy the opposite interior value"));
398 PetscCall(
PicurvAssertRealNear((PetscReal)((mx - 2) + 10 * (my - 2) + 200), p[2][0][0], 1.0e-12,
399 "ordered synchronization should propagate the opposite periodic corner"));
400 PetscCall(
PicurvAssertRealNear((PetscReal)((mx - 2) + 10 * (my - 2) + 1200), ucat[2][0][0].x, 1.0e-12,
401 "vector fields should use the same ordered periodic-corner protocol"));
402 PetscCall(
PicurvAssertRealNear((PetscReal)((mx - 2) + 10 * (my - 2) + 4200), cs[2][0][0], 1.0e-12,
403 "CS should use the ordered periodic-corner protocol"));
404 PetscCall(
PicurvAssertRealNear((PetscReal)((mx - 2) + 10 * (my - 2) + 5200), diffusivity[2][0][0], 1.0e-12,
405 "Diffusivity should use the ordered periodic-corner protocol"));
406 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
P, &p));
407 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
CS, &cs));
408 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
Diffusivity, &diffusivity));
409 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
Ucat, &ucat));
413 PetscFunctionReturn(0);
423 PetscReal ***iaj = NULL;
428 PetscFunctionBeginUser;
435 PetscCall(DMDAVecGetArray(user->
da, user->
IAj, &iaj));
436 PetscCall(DMDAVecGetArray(user->
fda, user->
Csi, &csi));
437 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; k++) {
438 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; j++) {
439 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; i++) {
440 PetscReal value = (PetscReal)(i + 10 * j + 100 * k);
441 iaj[k][j][i] = value;
442 csi[k][j][i] = (
Cmpnts){value + 1000.0, value + 2000.0, value + 3000.0};
446 PetscCall(DMDAVecRestoreArray(user->
da, user->
IAj, &iaj));
447 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Csi, &csi));
451 PetscCall(DMDAVecGetArrayRead(user->
da, user->
IAj, &iaj));
452 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
Csi, &csi));
454 "I-face negative seam should copy the opposite physical seam face"));
456 "I-face positive dummy should copy the leading physical face"));
458 "I-face field should use cell-style synchronization tangentially"));
459 PetscCall(
PicurvAssertRealNear((PetscReal)(mx - 2 + 10 * (my - 2) + 200), iaj[2][0][0], 1.0e-12,
460 "ordered face synchronization should propagate mixed-axis corners"));
461 PetscCall(
PicurvAssertRealNear((PetscReal)(mx - 2 + 10 * (my - 2) + 1200), csi[2][0][0].x, 1.0e-12,
462 "vector I-face fields should use the same ordered synchronization"));
463 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
IAj, &iaj));
464 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
Csi, &csi));
466 PetscCall(DMDAVecGetArrayRead(user->
da, user->
lIAj, &iaj));
468 "I-face negative adjacent ghost should be shifted to the prior face"));
470 "I-face positive adjacent ghost should be shifted to the next face"));
472 "I-face tangential ghosts should retain cell-style wraparound"));
473 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
lIAj, &iaj));
476 PetscFunctionReturn(0);
490 PetscFunctionBeginUser;
497 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucont, &ucont));
498 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; k++) {
499 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; j++) {
500 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; i++) {
501 PetscReal value = (PetscReal)(i + 10 * j + 100 * k);
502 ucont[k][j][i] = (
Cmpnts){value + 1000.0, value + 2000.0, value + 3000.0};
506 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucont, &ucont));
510 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
Ucont, &ucont));
512 "Ucont.x negative X seam should copy the opposite physical seam"));
514 "Ucont.y positive X dummy should copy the leading physical value"));
515 PetscCall(
PicurvAssertRealNear((PetscReal)(2 + 10 * (my - 2) + 3200), ucont[2][0][2].z, 1.0e-12,
516 "Ucont.z should synchronize tangentially in Y"));
517 PetscCall(
PicurvAssertRealNear((PetscReal)(mx - 2 + 10 * (my - 2) + 2200), ucont[2][0][0].y, 1.0e-12,
518 "ordered staggered synchronization should propagate mixed-axis corners"));
519 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
Ucont, &ucont));
521 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
lUcont, &ucont));
523 "Ucont.x should use face-normal X ghost repair"));
525 "Ucont.y should retain cell-style wraparound tangentially in X"));
527 "Ucont.x positive adjacent ghost should use the next face"));
529 "Ucont.y positive X ghost should retain cell-style wraparound"));
530 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
lUcont, &ucont));
533 PetscFunctionReturn(0);
543 Vec ucont_before = NULL;
544 Vec ucont_difference = NULL;
547 PetscReal ***p = NULL;
548 PetscReal difference_norm = 0.0;
551 PetscFunctionBeginUser;
554 PetscCall(VecSet(user->
Bcs.
Ubcs, 0.0));
556 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucat, &ucat));
557 PetscCall(DMDAVecGetArray(user->
fda, user->
Ucont, &ucont));
558 PetscCall(DMDAVecGetArray(user->
da, user->
P, &p));
559 for (PetscInt k = user->
info.zs; k < user->
info.zs + user->
info.zm; ++k) {
560 for (PetscInt j = user->
info.ys; j < user->
info.ys + user->
info.ym; ++j) {
561 for (PetscInt i = user->
info.xs; i < user->
info.xs + user->
info.xm; ++i) {
562 PetscReal value = (PetscReal)(i + 10 * j + 100 * k);
563 ucat[k][j][i].
x = value + 1000.0;
564 ucat[k][j][i].
y = value + 2000.0;
565 ucat[k][j][i].
z = value + 3000.0;
566 ucont[k][j][i].
x = value + 4000.0;
567 ucont[k][j][i].
y = value + 5000.0;
568 ucont[k][j][i].
z = value + 6000.0;
573 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucat, &ucat));
574 PetscCall(DMDAVecRestoreArray(user->
fda, user->
Ucont, &ucont));
575 PetscCall(DMDAVecRestoreArray(user->
da, user->
P, &p));
577 PetscCall(VecDuplicate(user->
Ucont, &ucont_before));
578 PetscCall(VecDuplicate(user->
Ucont, &ucont_difference));
579 PetscCall(VecCopy(user->
Ucont, ucont_before));
583 PetscCall(VecWAXPY(ucont_difference, -1.0, user->
Ucont, ucont_before));
584 PetscCall(VecNorm(ucont_difference, NORM_INFINITY, &difference_norm));
586 "post-projection cell finalization must preserve mixed-boundary Ucont"));
589 PetscCall(DMDAVecGetArrayRead(user->
fda, user->
Ucat, &ucat));
590 PetscCall(DMDAVecGetArrayRead(user->
da, user->
P, &p));
591 PetscCall(
PicurvAssertRealNear((PetscReal)((mx - 2) + 20 + 200 + 1000), ucat[2][2][0].x, 1.0e-12,
592 "mixed finalization should restore the negative x-periodic Ucat endpoint"));
594 "mixed finalization should extrapolate the non-periodic y dummy face"));
595 PetscCall(
PicurvAssertRealNear((PetscReal)(-((mx - 2) + 10 + 200 + 1000)), ucat[2][0][0].x, 1.0e-12,
596 "periodic synchronization should win at a mixed x-periodic/y-physical edge"));
598 "mixed finalization should restore the negative x-periodic pressure endpoint"));
599 PetscCall(DMDAVecRestoreArrayRead(user->
fda, user->
Ucat, &ucat));
600 PetscCall(DMDAVecRestoreArrayRead(user->
da, user->
P, &p));
602 PetscCall(VecDestroy(&ucont_difference));
603 PetscCall(VecDestroy(&ucont_before));
605 PetscFunctionReturn(0);
614 PetscFunctionBeginUser;
617 PetscCall(VecSet(user->
Ucont,0.0));
618 PetscCall(DMDAVecGetArray(user->
fda,user->
Ucont,&ucont));
619 for(PetscInt k=1;k<user->
info.mz-1;k++)
for(PetscInt j=1;j<user->
info.my-1;j++)
620 for(PetscInt i=1;i<mx-1;i++) ucont[k][j][i].x=(PetscReal)i;
621 PetscCall(DMDAVecRestoreArray(user->
fda,user->
Ucont,&ucont));
623 PetscCall(VecSet(user->
Ucat,-99.0));
628 PetscCall(DMDAVecGetArrayRead(user->
fda,user->
Ucat,&ucat));
629 PetscCall(
PicurvAssertRealNear(ucat[2][2][mx-2].x,ucat[2][2][0].x,1e-12,
"negative Ucat duplicate follows opposite independent cell"));
630 PetscCall(
PicurvAssertRealNear(ucat[2][2][1].x,ucat[2][2][mx-1].x,1e-12,
"positive Ucat duplicate follows leading independent cell"));
631 PetscCall(DMDAVecGetArrayRead(user->
fda,user->
lUcat,&lucat));
632 PetscCall(
PicurvAssertRealNear(ucat[2][2][0].x,lucat[2][2][0].x,1e-12,
"local negative Ucat endpoint matches corrected global"));
633 PetscCall(
PicurvAssertRealNear(ucat[2][2][mx-1].x,lucat[2][2][mx-1].x,1e-12,
"local positive Ucat endpoint matches corrected global"));
634 PetscCall(DMDAVecRestoreArrayRead(user->
fda,user->
lUcat,&lucat));
635 PetscCall(DMDAVecRestoreArrayRead(user->
fda,user->
Ucat,&ucat));
637 PetscFunctionReturn(0);
661 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv geometric-periodic tests");
666 ierr =
PicurvRunTests(
"unit-periodic", cases,
sizeof(cases) /
sizeof(cases[0]));
672 ierr = PetscFinalize();
PetscErrorCode PreparePeriodicQuickStencilFields(UserCtx *user, Vec local_vector_field, Vec local_scalar_field)
Repairs the outer adjacent periodic ghosts used by QUICK cell stencils.
PetscErrorCode ApplyMetricsPeriodicBCs(UserCtx *user)
(Orchestrator) Updates all metric-related fields in the local ghost cell regions for periodic boundar...
PetscErrorCode BoundarySystem_Validate(UserCtx *user)
(Public) Validates the consistency and compatibility of the parsed boundary condition system.
PetscErrorCode BoundaryCondition_Create(BCHandlerType handler_type, BoundaryCondition **new_bc_ptr)
(Private) Creates and configures a specific BoundaryCondition handler object.
PetscErrorCode SynchronizePeriodicStaggeredFields(UserCtx *user, PetscInt num_fields, const FieldId field_ids[])
Synchronizes persistent component-staggered vector fields.
PetscErrorCode FinalizePostProjectionCellFields(UserCtx *user)
Finalizes cell-centered fields after the projection step.
PetscErrorCode SynchronizePeriodicFaceFields(UserCtx *user, char face_direction, PetscInt num_fields, const FieldId field_ids[])
Synchronizes persistent fields belonging to one face family.
PetscErrorCode SynchronizePeriodicCellFields(UserCtx *user, PetscInt num_fields, const FieldId field_ids[])
Synchronizes periodic endpoint cells for a list of cell-centered fields.
FieldId
Compile-time identity for a catalogued Eulerian field.
PetscErrorCode ValidatePeriodicGeometry(UserCtx *user)
Validates that configured geometric periodic seams match by translation.
PetscErrorCode Contra2Cart(UserCtx *user)
Reconstructs Cartesian velocity (Ucat) at cell centers from contravariant velocity (Ucont) defined on...
PetscErrorCode UpdateLocalGhosts(UserCtx *user, FieldId field_id)
Updates the local vector (including ghost points) from its corresponding global vector.
The "virtual table" struct for a boundary condition handler object.
PetscErrorCode(* Destroy)(BoundaryCondition *self)
PetscErrorCode(* Initialize)(BoundaryCondition *self, BCContext *ctx)
PetscErrorCode(* Apply)(BoundaryCondition *self, BCContext *ctx)
static PetscErrorCode TestContra2CartPeriodicUcatFinalization(void)
Verifies reconstructed Ucat periodic duplicates and local values are finalized.
static void MarkXPeriodic(UserCtx *user)
Marks the x faces as periodic for periodic-transfer harnesses.
static PetscErrorCode AppendBCParam(BC_Param **head, const char *key, const char *value)
Appends one key/value pair to a linked list of boundary-condition parameters.
static PetscErrorCode TestPeriodicGeometricFactoryAssignment(void)
Tests periodic geometric factory construction.
static PetscErrorCode TestPeriodicFaceCenterCoordinateSynchronization(void)
Tests face-center coordinates remain geometrically continuous across a periodic seam.
int main(int argc, char **argv)
Runs the focused geometric-periodic PETSc test binary.
static PetscErrorCode TestPeriodicGeometryStoresTranslation(void)
Tests constant translational periodic geometry is accepted and stored.
static PetscErrorCode TestSynchronizePeriodicFaceFieldsCopiesMixedAxes(void)
Tests ordered persistent synchronization for an I-face scalar metric.
static PetscErrorCode TestFinalizePostProjectionCellFieldsMixedBoundaries(void)
Tests mixed-boundary post-projection cell finalization and Ucont preservation.
static PetscErrorCode TestPeriodicConfigurationRequiresPairedFaces(void)
Tests periodic configuration rejects an unpaired geometric periodic face.
static PetscErrorCode TestPeriodicQuickStencilPreparation(void)
Tests the dedicated QUICK outer-ghost repair for cell-centered inputs.
static PetscErrorCode TestSynchronizePeriodicCellFieldsCopiesMixedAxes(void)
Tests ordered cell-field synchronization across two periodic directions.
static PetscErrorCode TestPeriodicGeometryRejectsVaryingTranslation(void)
Tests non-translational seam geometry fails before metric construction.
static PetscErrorCode TestSynchronizePeriodicStaggeredFieldsCopiesMixedAxes(void)
Tests ordered persistent synchronization for component-staggered Ucont.
static PetscErrorCode DestroyBoundaryHandler(BoundaryCondition **bc_ptr)
Destroys one boundary-condition handler allocated by a periodic test.
static PetscErrorCode TestPeriodicGeometryStoresMixedTranslations(void)
Tests mixed periodic directions are validated and stored independently.
static PetscErrorCode TestApplyMetricsPeriodicBCsSynchronizesAj(void)
Tests periodic metric transfer through the aggregate periodic-metrics helper.
static void MarkYPeriodic(UserCtx *user)
Marks the y faces as periodic for periodic-transfer harnesses.
PetscErrorCode PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context)
Asserts that two real values agree within tolerance.
PetscErrorCode PicurvDestroyMinimalContexts(SimCtx **simCtx_ptr, UserCtx **user_ptr)
Destroys minimal SimCtx/UserCtx fixtures and all owned PETSc objects.
PetscErrorCode PicurvCreateMinimalContextsWithPeriodicity(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz, PetscBool x_periodic, PetscBool y_periodic, PetscBool z_periodic)
Builds minimal SimCtx and UserCtx fixtures for C unit tests with configurable periodicity.
PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count)
Runs a named C test suite and prints pass/fail progress markers.
PetscErrorCode PicurvAssertVecConstant(Vec vec, PetscScalar expected, PetscReal tol, const char *context)
Asserts that a PETSc vector is spatially constant within tolerance.
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Asserts that two integer values are equal.
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Asserts that one boolean condition is true.
Shared declarations for the PICurv C test fixture and assertion layer.
Named test case descriptor consumed by PicurvRunTests.
BoundaryFaceConfig boundary_faces[6]
@ BC_HANDLER_PERIODIC_GEOMETRIC
BCHandlerType handler_type
Vec Ubcs
Physical Cartesian velocity at boundary faces. Full 3D array but only boundary-face entries are meani...
Cmpnts periodic_translation[3]
PetscBool periodic_translation_valid[3]
A node in a linked list for storing key-value parameters from the bcs.dat file.
A 3D point or vector with PetscScalar components.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.
A generic C-style linked list node for integers.