PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
test_support.h
Go to the documentation of this file.
1/**
2 * @file test_support.h
3 * @brief Shared declarations for the PICurv C test fixture and assertion layer.
4 */
5
6#ifndef PICURV_TEST_SUPPORT_H
7#define PICURV_TEST_SUPPORT_H
8
9#include <stddef.h>
10
11#include "variables.h"
12
13/** @brief Signature for a single C unit-test entry point. */
14typedef PetscErrorCode (*PicurvTestFn)(void);
15
16/** @brief Named test case descriptor consumed by `PicurvRunTests`. */
21
22/** @brief Executes a table of unit tests and reports aggregated pass/fail status. */
23PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count);
24
25/** @brief Creates minimal PETSc/solver contexts used by isolated kernel tests. */
26PetscErrorCode PicurvCreateMinimalContexts(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz);
27
28/** @brief Creates minimal PETSc/solver contexts with optional periodic DM boundaries. */
29PetscErrorCode PicurvCreateMinimalContextsWithPeriodicity(SimCtx **simCtx_out,
30 UserCtx **user_out,
31 PetscInt mx,
32 PetscInt my,
33 PetscInt mz,
34 PetscBool x_periodic,
35 PetscBool y_periodic,
36 PetscBool z_periodic);
37
38/** @brief Destroys contexts previously created by `PicurvCreateMinimalContexts`. */
39PetscErrorCode PicurvDestroyMinimalContexts(SimCtx **simCtx, UserCtx **user);
40
41/** @brief Builds a tiny runtime context through the real setup path for behavior-level tests. */
42PetscErrorCode PicurvBuildTinyRuntimeContext(const char *bcs_contents,
43 PetscBool enable_particles,
44 SimCtx **simCtx_out,
45 UserCtx **user_out,
46 char *tmpdir,
47 size_t tmpdir_len);
48
49/** @brief Finalizes and frees a runtime context built by `PicurvBuildTinyRuntimeContext`. */
50PetscErrorCode PicurvDestroyRuntimeContext(SimCtx **simCtx_ptr);
51
52/** @brief Populates cell center coordinates for a uniform grid on [0,1]^3. */
53PetscErrorCode PicurvPopulateUniformCellCenters(UserCtx *user);
54
55/** @brief Fills metric vectors with identity metrics for Cartesian-reference tests. */
56PetscErrorCode PicurvPopulateIdentityMetrics(UserCtx *user);
57
58/** @brief Creates paired runtime/post swarms with optional extra post-processing field registration. */
59PetscErrorCode PicurvCreateSwarmPair(UserCtx *user, PetscInt nlocal, const char *post_field_name);
60
61/** @brief Creates a unique temporary directory path and materializes the directory. */
62PetscErrorCode PicurvMakeTempDir(char *path, size_t path_len);
63
64/** @brief Recursively removes a temporary directory created by PicurvMakeTempDir. */
65PetscErrorCode PicurvRemoveTempDir(const char *path);
66
67/** @brief Ensures a directory exists, creating it if required. */
68PetscErrorCode PicurvEnsureDir(const char *path);
69
70/** @brief Asserts two real values are within tolerance for test validation. */
71PetscErrorCode PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context);
72
73/** @brief Asserts two integer values are exactly equal for test validation. */
74PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context);
75
76/** @brief Asserts a boolean condition is true for test validation. */
77PetscErrorCode PicurvAssertBool(PetscBool value, const char *context);
78
79/** @brief Asserts a filesystem path exists. */
80PetscErrorCode PicurvAssertFileExists(const char *path, const char *context);
81
82/** @brief Asserts every entry of a vector equals a constant within tolerance. */
83PetscErrorCode PicurvAssertVecConstant(Vec vec, PetscScalar expected, PetscReal tol, const char *context);
84
85#endif
PetscErrorCode PicurvMakeTempDir(char *path, size_t path_len)
Creates a unique temporary directory path and materializes the directory.
PetscErrorCode PicurvCreateMinimalContexts(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz)
Creates minimal PETSc/solver contexts used by isolated kernel tests.
PetscErrorCode PicurvEnsureDir(const char *path)
Ensures a directory exists, creating it if required.
PetscErrorCode PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context)
Asserts two real values are within tolerance for test validation.
PetscErrorCode PicurvDestroyMinimalContexts(SimCtx **simCtx, UserCtx **user)
Destroys contexts previously created by PicurvCreateMinimalContexts.
PetscErrorCode PicurvCreateMinimalContextsWithPeriodicity(SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz, PetscBool x_periodic, PetscBool y_periodic, PetscBool z_periodic)
Creates minimal PETSc/solver contexts with optional periodic DM boundaries.
PetscErrorCode(* PicurvTestFn)(void)
Signature for a single C unit-test entry point.
PetscErrorCode PicurvCreateSwarmPair(UserCtx *user, PetscInt nlocal, const char *post_field_name)
Creates paired runtime/post swarms with optional extra post-processing field registration.
PetscErrorCode PicurvDestroyRuntimeContext(SimCtx **simCtx_ptr)
Finalizes and frees a runtime context built by PicurvBuildTinyRuntimeContext.
PetscErrorCode PicurvRunTests(const char *suite_name, const PicurvTestCase *cases, size_t case_count)
Executes a table of unit tests and reports aggregated pass/fail status.
PetscErrorCode PicurvBuildTinyRuntimeContext(const char *bcs_contents, PetscBool enable_particles, SimCtx **simCtx_out, UserCtx **user_out, char *tmpdir, size_t tmpdir_len)
Builds a tiny runtime context through the real setup path for behavior-level tests.
PetscErrorCode PicurvPopulateUniformCellCenters(UserCtx *user)
Populates cell center coordinates for a uniform grid on [0,1]^3.
PetscErrorCode PicurvAssertFileExists(const char *path, const char *context)
Asserts a filesystem path exists.
PetscErrorCode PicurvAssertVecConstant(Vec vec, PetscScalar expected, PetscReal tol, const char *context)
Asserts every entry of a vector equals a constant within tolerance.
const char * name
PetscErrorCode PicurvAssertIntEqual(PetscInt expected, PetscInt actual, const char *context)
Asserts two integer values are exactly equal for test validation.
PetscErrorCode PicurvPopulateIdentityMetrics(UserCtx *user)
Fills metric vectors with identity metrics for Cartesian-reference tests.
PicurvTestFn fn
PetscErrorCode PicurvAssertBool(PetscBool value, const char *context)
Asserts a boolean condition is true for test validation.
PetscErrorCode PicurvRemoveTempDir(const char *path)
Recursively removes a temporary directory created by PicurvMakeTempDir.
Named test case descriptor consumed by PicurvRunTests.
Main header file for a complex fluid dynamics solver.
The master context for the entire simulation.
Definition variables.h:643
User-defined context containing data specific to a single computational grid level.
Definition variables.h:811