20#define TARGET_TEST_N 6
21#define TARGET_CELL_EXTENT 5
22#define TARGET_NODE_EXTENT 6
29 PetscFunctionBeginUser;
32 PetscFunctionReturn(0);
41 PetscInt local = 0, global = 0;
43 PetscFunctionBeginUser;
49 "P should resolve as cell-centered"));
51 if (simCtx->
size == 1) {
52 for (PetscInt dim = 0; dim < 3; ++dim) {
54 "cell-centered span must skip the index-zero dummy slot"));
56 "cell-centered span must skip the extra high-side slot"));
62 "cell-centered global point count"));
63 PetscCall(
PicurvAssertBool((PetscBool)(local <= global),
"local count cannot exceed global count"));
68 "Ucat shares the cell-centered domain regardless of dof"));
71 PetscFunctionReturn(0);
83 PetscFunctionBeginUser;
96 PetscFunctionReturn(0);
115 PetscFunctionBeginUser;
119 PETSC_TRUE, PETSC_FALSE, PETSC_FALSE));
122 "cell-centered count is unchanged by periodicity"));
125 "I-face loses its duplicate plane when i is periodic"));
128 "J-face keeps its node-like span when only i is periodic"));
131 "node-centered loses only the periodic direction"));
137 PETSC_TRUE, PETSC_TRUE, PETSC_TRUE));
140 "fully periodic node-centered domain has no duplicate planes"));
143 "fully periodic I-face domain has no duplicate planes"));
146 "fully periodic cell-centered domain is unchanged"));
148 PetscFunctionReturn(0);
157 PetscErrorCode staggered_ierr = 0;
158 PetscErrorCode classify_ierr = 0;
159 PetscBool node_like = PETSC_FALSE;
161 PetscFunctionBeginUser;
164 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
166 PetscCall(PetscPopErrorHandler());
168 "Ucont is component-staggered and must not resolve a pointwise domain"));
170 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
172 PetscCall(PetscPopErrorHandler());
174 "component-staggered layout has no single per-dimension classification"));
176 PetscCall(PetscPushErrorHandler(PetscIgnoreErrorHandler, NULL));
178 PetscCall(PetscPopErrorHandler());
180 "dimension index outside 0..2 must be rejected"));
183 PetscFunctionReturn(0);
193 PetscFunctionBeginUser;
198 "open fluid must pass the fluid mask"));
200 "values below the threshold must pass the fluid mask"));
202 "solid cells must fail the fluid mask"));
204 "the threshold itself is excluded, matching the existing Nvert < 0.1 rule"));
206 "a null plan must not admit points"));
209 PetscFunctionReturn(0);
227 PetscFunctionBeginUser;
231 for (PetscInt dim = 0; dim < 3; ++dim) {
232 PetscInt origin_start = 0;
233 PetscInt origin_count = 0;
238 "cell span start must be the owned-cell origin shifted by one"));
240 "cell span end must be the owned-cell extent shifted by one"));
244 PetscFunctionReturn(0);
262 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv spatial target tests");
267 ierr =
PicurvRunTests(
"unit-statistics-target", cases,
sizeof(cases) /
sizeof(cases[0]));
273 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 in Phase 2.
@ 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.