19#define TARGET_TEST_N 6
20#define TARGET_CELL_EXTENT 5
21#define TARGET_NODE_EXTENT 6
28 PetscFunctionBeginUser;
31 PetscFunctionReturn(0);
40 PetscInt local = 0, global = 0;
42 PetscFunctionBeginUser;
48 "P should resolve as cell-centered"));
50 if (simCtx->
size == 1) {
51 for (PetscInt dim = 0; dim < 3; ++dim) {
53 "cell-centered span must skip the index-zero dummy slot"));
55 "cell-centered span must skip the extra high-side slot"));
61 "cell-centered global point count"));
62 PetscCall(
PicurvAssertBool((PetscBool)(local <= global),
"local count cannot exceed global count"));
67 "Ucat shares the cell-centered domain regardless of dof"));
70 PetscFunctionReturn(0);
82 PetscFunctionBeginUser;
95 PetscFunctionReturn(0);
114 PetscFunctionBeginUser;
118 PETSC_TRUE, PETSC_FALSE, PETSC_FALSE));
121 "cell-centered count is unchanged by periodicity"));
124 "I-face loses its duplicate plane when i is periodic"));
127 "J-face keeps its node-like span when only i is periodic"));
130 "node-centered loses only the periodic direction"));
136 PETSC_TRUE, PETSC_TRUE, PETSC_TRUE));
139 "fully periodic node-centered domain has no duplicate planes"));
142 "fully periodic I-face domain has no duplicate planes"));
145 "fully periodic cell-centered domain is unchanged"));
147 PetscFunctionReturn(0);
156 PetscErrorCode staggered_ierr = 0;
157 PetscErrorCode classify_ierr = 0;
158 PetscBool node_like = PETSC_FALSE;
160 PetscFunctionBeginUser;
163 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
165 PetscCall(PetscPopErrorHandler());
167 "Ucont is component-staggered and must not resolve a pointwise domain"));
169 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
171 PetscCall(PetscPopErrorHandler());
173 "component-staggered layout has no single per-dimension classification"));
175 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
177 PetscCall(PetscPopErrorHandler());
179 "dimension index outside 0..2 must be rejected"));
182 PetscFunctionReturn(0);
192 PetscFunctionBeginUser;
197 "open fluid must pass the fluid mask"));
199 "values below the threshold must pass the fluid mask"));
201 "solid cells must fail the fluid mask"));
203 "the threshold itself is excluded, matching the existing Nvert < 0.1 rule"));
205 "a null plan must not admit points"));
208 PetscFunctionReturn(0);
226 PetscFunctionBeginUser;
230 for (PetscInt dim = 0; dim < 3; ++dim) {
231 PetscInt origin_start = 0;
232 PetscInt origin_count = 0;
237 "cell span start must be the owned-cell origin shifted by one"));
239 "cell span end must be the owned-cell extent shifted by one"));
243 PetscFunctionReturn(0);
261 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv spatial target tests");
266 ierr =
PicurvRunTests(
"unit-statistics-target", cases,
sizeof(cases) /
sizeof(cases[0]));
272 ierr = PetscFinalize();
@ FIELD_LAYOUT_CELL_CENTERED
@ FIELD_LAYOUT_COMPONENT_STAGGERED
FieldId
Compile-time identity for a catalogued Eulerian field.
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...
Spatial target resolution for the field-statistics pipeline.
#define PICURV_STATISTICS_FLUID_THRESHOLD
Threshold below which a cell counts as fluid for the default mask.
PetscBool SpatialTargetPlanMaskAllows(const SpatialTargetPlan *plan, PetscReal nvert_value)
Reports whether a point passes the plan's mask.
PicurvTargetKind kind
Spatial mapping; always pointwise.
@ PICURV_TARGET_POINTWISE
@ PICURV_STATISTICS_MASK_FLUID
PetscInt end[3]
Exclusive end per dimension (i, j, k).
PetscInt start[3]
Inclusive start per dimension (i, j, k).
PetscErrorCode SpatialTargetPlanLocalPointCount(const SpatialTargetPlan *plan, PetscInt *count)
Counts the points this rank contributes.
PetscErrorCode SpatialTargetPlanGlobalPointCount(const SpatialTargetPlan *plan, MPI_Comm comm, PetscInt *count)
Counts the points contributed across a communicator.
PetscErrorCode SpatialTargetPlanCreate(UserCtx *user, FieldId field_id, PicurvStatisticsMask mask, SpatialTargetPlan *plan)
Resolves the iteration domain for one field on one block.
PetscErrorCode PicurvLayoutDimensionIsNodeLike(FieldLayout layout, PetscInt dim, PetscBool *node_like)
Reports whether a layout is node-like in one dimension.
const FieldDescriptor * descriptor
Catalog metadata for the targeted field.
Resolved iteration domain for one field on one block.
static PetscErrorCode TestComponentStaggeredRejected(void)
Component-staggered fields cannot share one pointwise domain and are rejected.
static PetscErrorCode PlanCount(UserCtx *user, FieldId field_id, PetscInt *count)
Builds a plan and returns its global point count.
static PetscErrorCode TestPeriodicDirectionsDropDuplicatePlane(void)
Periodic directions must drop the wrapped duplicate plane.
int main(int argc, char **argv)
Entry point for the spatial target suite.
static PetscErrorCode TestCellCenteredExcludesBoundaryAndDummy(void)
Cell-centered fields must exclude the dummy slot and the extra high slot.
static PetscErrorCode TestFaceLayoutsAreNodeLikeInOwnDirection(void)
Each face family is node-like in exactly its own direction.
static PetscErrorCode TestFluidMaskThreshold(void)
The fluid mask admits fluid cells and rejects blanked ones at the documented threshold.
#define TARGET_CELL_EXTENT
#define TARGET_NODE_EXTENT
static PetscErrorCode TestCellSpanAgreesWithOwnedCellRange(void)
The cell-centered span must agree with the existing owned-cell helper.
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 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 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.
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.