17 PetscBool within = PETSC_FALSE;
19 PetscFunctionBeginUser;
23 PetscCall(
PicurvAssertBool(within,
"cell (1,1,1) should be within the serial local grid"));
26 PetscCall(
PicurvAssertBool((PetscBool)!within,
"cell (3,1,1) should fall outside the valid local cell range"));
29 PetscFunctionReturn(0);
40 PetscInt idx = -1, idy = -1, idz = -1, steps = -1;
42 PetscFunctionBeginUser;
44 PetscCall(PetscMemzero(&particle,
sizeof(particle)));
52 PetscCall(
PicurvAssertIntEqual(1, idx,
"InitializeTraversalParameters should preserve prior i"));
53 PetscCall(
PicurvAssertIntEqual(1, idy,
"InitializeTraversalParameters should preserve prior j"));
54 PetscCall(
PicurvAssertIntEqual(1, idz,
"InitializeTraversalParameters should preserve prior k"));
55 PetscCall(
PicurvAssertIntEqual(0, steps,
"InitializeTraversalParameters should reset traversal steps"));
58 PetscFunctionReturn(0);
70 PetscFunctionBeginUser;
72 PetscCall(PetscMemzero(&cell,
sizeof(cell)));
83 PetscFunctionReturn(0);
89int main(
int argc,
char **argv)
98 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv particle kernel tests");
103 ierr =
PicurvRunTests(
"unit-particles", cases,
sizeof(cases) /
sizeof(cases[0]));
109 ierr = PetscFinalize();
static PetscErrorCode TestCheckCellWithinLocalGrid(void)
Test-local routine.
int main(int argc, char **argv)
Entry point for this unit-test binary.
static PetscErrorCode TestInitializeTraversalParameters(void)
Test-local routine.
static PetscErrorCode TestRetrieveCurrentCell(void)
Test-local routine.
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 PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
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 vertices[8]
Coordinates of the eight vertices of the cell.
Defines the vertices of a single hexahedral grid cell.
Defines a particle's core properties for Lagrangian tracking.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.
Header file for particle location functions using the walking search algorithm.
PetscErrorCode RetrieveCurrentCell(UserCtx *user, PetscInt idx, PetscInt idy, PetscInt idz, Cell *cell)
Retrieves the coordinates of the eight vertices of the current cell.
PetscErrorCode InitializeTraversalParameters(UserCtx *user, Particle *particle, PetscInt *idx, PetscInt *idy, PetscInt *idz, PetscInt *traversal_steps)
Initializes traversal parameters for locating a particle.
PetscErrorCode CheckCellWithinLocalGrid(UserCtx *user, PetscInt idx, PetscInt idy, PetscInt idz, PetscBool *is_within)
Checks if the current cell indices are within the local grid boundaries.