21 PetscReal expected_max = 0.0;
23 PetscFunctionBeginUser;
26 expected_max = ((PetscReal)(user->
IM - 1) / (PetscReal)user->
IM) + 1.0e-6;
36 PetscFunctionReturn(0);
48 PetscMPIInt rank = 0, size = 1;
50 PetscFunctionBeginUser;
51 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &rank));
52 PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD, &size));
59 PetscCall(
PicurvAssertBool((PetscBool)(boxes != NULL),
"root must receive gathered bounding boxes"));
61 PetscCall(
PicurvAssertBool((PetscBool)(boxes == NULL),
"non-root should have NULL pre-broadcast bbox pointer"));
65 PetscCall(
PicurvAssertBool((PetscBool)(boxes != NULL),
"all ranks must have bbox array after broadcast"));
67 for (PetscMPIInt r = 0; r < size; ++r) {
78 PetscFunctionReturn(0);
93 PetscFunctionBeginUser;
96 PetscCall(PetscOptionsSetValue(NULL,
"-im",
"4"));
97 PetscCall(PetscOptionsSetValue(NULL,
"-jm",
"4"));
98 PetscCall(PetscOptionsSetValue(NULL,
"-km",
"4"));
99 PetscCall(PetscOptionsSetValue(NULL,
"-xMins",
"0.0"));
100 PetscCall(PetscOptionsSetValue(NULL,
"-xMaxs",
"0.2"));
101 PetscCall(PetscOptionsSetValue(NULL,
"-yMins",
"0.0"));
102 PetscCall(PetscOptionsSetValue(NULL,
"-yMaxs",
"0.2"));
103 PetscCall(PetscOptionsSetValue(NULL,
"-zMins",
"0.0"));
104 PetscCall(PetscOptionsSetValue(NULL,
"-zMaxs",
"0.4"));
126 PetscErrorCode bad = 0;
129 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
131 PetscCall(PetscPopErrorHandler());
133 "L_ref <= 0 is refused rather than dividing by zero"));
136 PetscCall(PetscOptionsClearValue(NULL,
"-im"));
137 PetscCall(PetscOptionsClearValue(NULL,
"-jm"));
138 PetscCall(PetscOptionsClearValue(NULL,
"-km"));
139 PetscCall(PetscOptionsClearValue(NULL,
"-xMins"));
140 PetscCall(PetscOptionsClearValue(NULL,
"-xMaxs"));
141 PetscCall(PetscOptionsClearValue(NULL,
"-yMins"));
142 PetscCall(PetscOptionsClearValue(NULL,
"-yMaxs"));
143 PetscCall(PetscOptionsClearValue(NULL,
"-zMins"));
144 PetscCall(PetscOptionsClearValue(NULL,
"-zMaxs"));
146 PetscFunctionReturn(0);
159 {
"read-grid-generation-inputs-nondimensionalizes-bounds",
163 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv grid tests");
168 ierr =
PicurvRunTests(
"unit-grid", cases,
sizeof(cases) /
sizeof(cases[0]));
174 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.
Public interface for data input/output routines.
PetscErrorCode ReadGridGenerationInputs(UserCtx *user)
Parses command-line options for a programmatically generated grid for a SINGLE block.
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.
static PetscErrorCode TestReadGridGenerationInputsNonDimensionalizesBounds(void)
Tests that programmatic domain bounds are non-dimensionalized by L_ref.
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 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.
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.