20 PetscReal expected_max = 0.0;
22 PetscFunctionBeginUser;
25 expected_max = ((PetscReal)(user->
IM - 1) / (PetscReal)user->
IM) + 1.0e-6;
35 PetscFunctionReturn(0);
47 PetscMPIInt rank = 0, size = 1;
49 PetscFunctionBeginUser;
50 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
51 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
58 PetscCall(
PicurvAssertBool((PetscBool)(boxes != NULL),
"root must receive gathered bounding boxes"));
60 PetscCall(
PicurvAssertBool((PetscBool)(boxes == NULL),
"non-root should have NULL pre-broadcast bbox pointer"));
64 PetscCall(
PicurvAssertBool((PetscBool)(boxes != NULL),
"all ranks must have bbox array after broadcast"));
66 for (PetscMPIInt r = 0; r < size; ++r) {
77 PetscFunctionReturn(0);
83int main(
int argc,
char **argv)
91 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv grid tests");
96 ierr =
PicurvRunTests(
"unit-grid", cases,
sizeof(cases) /
sizeof(cases[0]));
102 ierr = PetscFinalize();
Public interface for grid, solver, and metric setup routines.
PetscErrorCode BroadcastAllBoundingBoxes(UserCtx *user, BoundingBox **bboxlist)
Broadcasts the bounding box information collected on rank 0 to all other ranks.
PetscErrorCode ComputeLocalBoundingBox(UserCtx *user, BoundingBox *localBBox)
Computes the local bounding box of the grid on the current process.
PetscErrorCode GatherAllBoundingBoxes(UserCtx *user, BoundingBox **allBBoxes)
Gathers local bounding boxes from all MPI processes to rank 0.
static PetscErrorCode TestComputeLocalBoundingBoxUniformGrid(void)
Tests local bounding-box construction on a uniform grid.
static PetscErrorCode TestGatherAndBroadcastBoundingBoxes(void)
Tests collective gather and broadcast of rank-local bounding boxes.
int main(int argc, char **argv)
Runs the unit-grid PETSc test binary.
PetscErrorCode PicurvCreateMinimalContexts(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz)
Builds minimal SimCtx and UserCtx fixtures for C unit tests.
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 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 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.
Cmpnts max_coords
Maximum x, y, z coordinates of the bounding box.
Cmpnts min_coords
Minimum x, y, z coordinates of the bounding box.
Defines a 3D axis-aligned bounding box.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.