21 PetscFunctionBeginUser;
33 PetscFunctionReturn(0);
45 PetscMPIInt rank = 0, size = 1;
47 PetscFunctionBeginUser;
48 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
49 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
56 PetscCall(
PicurvAssertBool((PetscBool)(boxes != NULL),
"root must receive gathered bounding boxes"));
58 PetscCall(
PicurvAssertBool((PetscBool)(boxes == NULL),
"non-root should have NULL pre-broadcast bbox pointer"));
62 PetscCall(
PicurvAssertBool((PetscBool)(boxes != NULL),
"all ranks must have bbox array after broadcast"));
64 for (PetscMPIInt r = 0; r < size; ++r) {
75 PetscFunctionReturn(0);
81int main(
int argc,
char **argv)
89 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv grid tests");
94 ierr =
PicurvRunTests(
"unit-grid", cases,
sizeof(cases) /
sizeof(cases[0]));
100 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)
Test-local routine.
static PetscErrorCode TestGatherAndBroadcastBoundingBoxes(void)
Test-local routine.
int main(int argc, char **argv)
Entry point for this unit-test binary.
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 PicurvAssertBool(PetscBool value, const char *context)
Shared test-support routine.
C test module for PICurv.
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.