PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
Data Structures | Typedefs | Functions
test_support.h File Reference

C test module for PICurv. More...

#include <stddef.h>
#include "variables.h"
Include dependency graph for test_support.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PicurvTestCase
 Named test case descriptor consumed by PicurvRunTests. More...
 

Typedefs

typedef PetscErrorCode(* PicurvTestFn) (void)
 Signature for a single C unit-test entry point.
 
typedef struct PicurvTestCase PicurvTestCase
 Named test case descriptor consumed by PicurvRunTests.
 

Functions

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 PicurvCreateMinimalContexts (SimCtx **simCtx_out, UserCtx **user_out, PetscInt mx, PetscInt my, PetscInt mz)
 Creates minimal PETSc/solver contexts used by isolated kernel tests.
 
PetscErrorCode PicurvDestroyMinimalContexts (SimCtx **simCtx, UserCtx **user)
 Destroys contexts previously created by PicurvCreateMinimalContexts.
 
PetscErrorCode PicurvPopulateIdentityMetrics (UserCtx *user)
 Fills metric vectors with identity metrics for Cartesian-reference tests.
 
PetscErrorCode PicurvCreateSwarmPair (UserCtx *user, PetscInt nlocal, const char *post_field_name)
 Creates paired runtime/post swarms with optional extra post-processing field registration.
 
PetscErrorCode PicurvMakeTempDir (char *path, size_t path_len)
 Creates a unique temporary directory path and materializes the directory.
 
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 PicurvAssertIntEqual (PetscInt expected, PetscInt actual, const char *context)
 Asserts two integer values are exactly equal for test validation.
 
PetscErrorCode PicurvAssertBool (PetscBool value, const char *context)
 Asserts a boolean condition is true for test validation.
 
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.
 

Detailed Description

C test module for PICurv.

Definition in file test_support.h.


Data Structure Documentation

◆ PicurvTestCase

struct PicurvTestCase

Named test case descriptor consumed by PicurvRunTests.

Definition at line 17 of file test_support.h.

Data Fields
const char * name
PicurvTestFn fn

Typedef Documentation

◆ PicurvTestFn

typedef PetscErrorCode(* PicurvTestFn) (void)

Signature for a single C unit-test entry point.

Definition at line 14 of file test_support.h.

◆ PicurvTestCase

Named test case descriptor consumed by PicurvRunTests.

Function Documentation

◆ PicurvRunTests()

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.

Executes a table of unit tests and reports aggregated pass/fail status.

Definition at line 53 of file test_support.c.

54{
55 PetscFunctionBeginUser;
56
57 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "==> Running %s (%zu tests)\n", suite_name, case_count));
58 for (size_t i = 0; i < case_count; ++i) {
59 PetscCall(PetscPrintf(PETSC_COMM_WORLD, " -> %s\n", cases[i].name));
60 PetscCall(cases[i].fn());
61 PetscCall(PetscPrintf(PETSC_COMM_WORLD, " [PASS] %s\n", cases[i].name));
62 }
63
64 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "==> %s complete\n", suite_name));
65 PetscFunctionReturn(0);
66}
Here is the caller graph for this function:

◆ PicurvCreateMinimalContexts()

PetscErrorCode PicurvCreateMinimalContexts ( SimCtx **  simCtx_out,
UserCtx **  user_out,
PetscInt  mx,
PetscInt  my,
PetscInt  mz 
)

Creates minimal PETSc/solver contexts used by isolated kernel tests.

Creates minimal PETSc/solver contexts used by isolated kernel tests.

Definition at line 100 of file test_support.c.

101{
102 SimCtx *simCtx = NULL;
103 UserCtx *user = NULL;
104
105 PetscFunctionBeginUser;
106 if (!simCtx_out || !user_out) {
107 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Output pointers cannot be NULL.");
108 }
109
110 PetscCall(PetscCalloc1(1, &simCtx));
111 PetscCall(PetscCalloc1(1, &user));
112
113 PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD, &simCtx->rank));
114 simCtx->block_number = 1;
115 simCtx->dt = 0.1;
116 simCtx->tiout = 2;
117 simCtx->forceScalingFactor = 1.0;
118 simCtx->LoggingFrequency = 1;
119 simCtx->exec_mode = EXEC_MODE_SOLVER;
121 simCtx->poisson = 0;
122 simCtx->ren = 1.0;
123 simCtx->schmidt_number = 1.0;
124 simCtx->StartStep = 0;
125 simCtx->StepsToRun = 1;
126 simCtx->step = 1;
127 simCtx->np = 0;
128 PetscCall(PetscStrncpy(simCtx->euler_subdir, "euler", sizeof(simCtx->euler_subdir)));
129 PetscCall(PetscStrncpy(simCtx->particle_subdir, "particles", sizeof(simCtx->particle_subdir)));
130 PetscCall(PetscStrncpy(simCtx->output_dir, "/tmp", sizeof(simCtx->output_dir)));
131 PetscCall(PetscStrncpy(simCtx->restart_dir, "/tmp", sizeof(simCtx->restart_dir)));
132
133 user->simCtx = simCtx;
134 user->_this = 0;
135 user->IM = mx;
136 user->JM = my;
137 user->KM = mz;
138
139 PetscCall(DMDACreate3d(PETSC_COMM_WORLD,
140 DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE,
141 DMDA_STENCIL_BOX,
142 mx, my, mz,
143 PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,
144 1, 1,
145 NULL, NULL, NULL,
146 &user->da));
147 PetscCall(DMSetUp(user->da));
148 PetscCall(DMDASetUniformCoordinates(user->da, 0.0, (PetscReal)(mx - 1), 0.0, (PetscReal)(my - 1), 0.0, (PetscReal)(mz - 1)));
149
150 PetscCall(DMDACreate3d(PETSC_COMM_WORLD,
151 DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE,
152 DMDA_STENCIL_BOX,
153 mx, my, mz,
154 PETSC_DECIDE, PETSC_DECIDE, PETSC_DECIDE,
155 3, 1,
156 NULL, NULL, NULL,
157 &user->fda));
158 PetscCall(DMSetUp(user->fda));
159 PetscCall(DMDASetUniformCoordinates(user->fda, 0.0, (PetscReal)(mx - 1), 0.0, (PetscReal)(my - 1), 0.0, (PetscReal)(mz - 1)));
160 PetscCall(DMDAGetLocalInfo(user->fda, &user->info));
161
162 PetscCall(DMCreateGlobalVector(user->da, &user->P));
163 PetscCall(DMCreateLocalVector(user->da, &user->lP));
164 PetscCall(DMCreateGlobalVector(user->da, &user->Nvert));
165 PetscCall(DMCreateLocalVector(user->da, &user->lNvert));
166 PetscCall(DMCreateGlobalVector(user->da, &user->ParticleCount));
167 PetscCall(DMCreateLocalVector(user->da, &user->lParticleCount));
168 PetscCall(DMCreateGlobalVector(user->da, &user->Psi));
169 PetscCall(DMCreateLocalVector(user->da, &user->lPsi));
170 PetscCall(DMCreateGlobalVector(user->da, &user->Qcrit));
171 PetscCall(DMCreateGlobalVector(user->da, &user->P_nodal));
172 PetscCall(DMCreateGlobalVector(user->da, &user->Psi_nodal));
173
174 PetscCall(DMCreateGlobalVector(user->fda, &user->Ucat));
175 PetscCall(DMCreateLocalVector(user->fda, &user->lUcat));
176 PetscCall(DMCreateGlobalVector(user->fda, &user->Ucont));
177 PetscCall(DMCreateLocalVector(user->fda, &user->lUcont));
178 PetscCall(DMCreateGlobalVector(user->fda, &user->Csi));
179 PetscCall(DMCreateLocalVector(user->fda, &user->lCsi));
180 PetscCall(DMCreateGlobalVector(user->fda, &user->Eta));
181 PetscCall(DMCreateLocalVector(user->fda, &user->lEta));
182 PetscCall(DMCreateGlobalVector(user->fda, &user->Zet));
183 PetscCall(DMCreateLocalVector(user->fda, &user->lZet));
184 PetscCall(DMCreateGlobalVector(user->fda, &user->Cent));
185 PetscCall(DMCreateLocalVector(user->fda, &user->lCent));
186 PetscCall(DMCreateGlobalVector(user->fda, &user->Ucat_nodal));
187
188 PetscCall(VecZeroEntries(user->P));
189 PetscCall(VecZeroEntries(user->Nvert));
190 PetscCall(VecZeroEntries(user->ParticleCount));
191 PetscCall(VecZeroEntries(user->Psi));
192 PetscCall(VecZeroEntries(user->Ucat));
193 PetscCall(VecZeroEntries(user->Ucont));
194 PetscCall(VecZeroEntries(user->Cent));
195
196 PetscCall(PicurvPopulateIdentityMetrics(user));
197
198 *simCtx_out = simCtx;
199 *user_out = user;
200 PetscFunctionReturn(0);
201}
PetscErrorCode PicurvPopulateIdentityMetrics(UserCtx *user)
Shared test-support routine.
Vec lCent
Definition variables.h:785
Vec P_nodal
Definition variables.h:814
Vec Zet
Definition variables.h:785
PetscReal schmidt_number
Definition variables.h:653
PetscMPIInt rank
Definition variables.h:594
PetscInt block_number
Definition variables.h:656
Vec lNvert
Definition variables.h:764
char euler_subdir[PETSC_MAX_PATH_LEN]
Definition variables.h:613
PetscReal forceScalingFactor
Definition variables.h:667
SimCtx * simCtx
Back-pointer to the master simulation context.
Definition variables.h:741
PetscInt KM
Definition variables.h:747
PetscInt tiout
Definition variables.h:603
Vec lZet
Definition variables.h:785
Vec Csi
Definition variables.h:785
PetscReal ren
Definition variables.h:638
PetscInt _this
Definition variables.h:751
char output_dir[PETSC_MAX_PATH_LEN]
Definition variables.h:612
PetscReal dt
Definition variables.h:606
PetscInt StepsToRun
Definition variables.h:602
Vec Ucat_nodal
Definition variables.h:815
Vec lPsi
Definition variables.h:810
PetscInt np
Definition variables.h:683
Vec Ucont
Definition variables.h:764
PetscInt StartStep
Definition variables.h:601
@ MOMENTUM_SOLVER_EXPLICIT_RK
Definition variables.h:462
Vec Qcrit
Definition variables.h:816
Vec lParticleCount
Definition variables.h:809
PetscInt poisson
Definition variables.h:634
char particle_subdir[PETSC_MAX_PATH_LEN]
Definition variables.h:614
Vec Eta
Definition variables.h:785
Vec lCsi
Definition variables.h:785
Vec Ucat
Definition variables.h:764
Vec ParticleCount
Definition variables.h:809
PetscInt JM
Definition variables.h:747
Vec Psi_nodal
Definition variables.h:817
Vec lUcont
Definition variables.h:764
PetscInt step
Definition variables.h:599
DMDALocalInfo info
Definition variables.h:745
Vec lUcat
Definition variables.h:764
@ EXEC_MODE_SOLVER
Definition variables.h:564
PetscInt IM
Definition variables.h:747
Vec lEta
Definition variables.h:785
Vec Cent
Definition variables.h:785
Vec Nvert
Definition variables.h:764
ExecutionMode exec_mode
Definition variables.h:609
MomentumSolverType mom_solver_type
Definition variables.h:630
char restart_dir[PETSC_MAX_PATH_LEN]
Definition variables.h:611
PetscInt LoggingFrequency
Definition variables.h:710
Vec Psi
Definition variables.h:810
The master context for the entire simulation.
Definition variables.h:591
User-defined context containing data specific to a single computational grid level.
Definition variables.h:738
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PicurvDestroyMinimalContexts()

PetscErrorCode PicurvDestroyMinimalContexts ( SimCtx **  simCtx_ptr,
UserCtx **  user_ptr 
)

Destroys contexts previously created by PicurvCreateMinimalContexts.

Destroys contexts previously created by PicurvCreateMinimalContexts.

Definition at line 288 of file test_support.c.

289{
290 UserCtx *user = NULL;
291 SimCtx *simCtx = NULL;
292
293 PetscFunctionBeginUser;
294 if (user_ptr) {
295 user = *user_ptr;
296 }
297 if (simCtx_ptr) {
298 simCtx = *simCtx_ptr;
299 }
300
301 if (user) {
302 PetscCall(DestroyDMIfSet(&user->swarm));
303 PetscCall(DestroyDMIfSet(&user->post_swarm));
304
305 PetscCall(DestroyVecIfSet(&user->P));
306 PetscCall(DestroyVecIfSet(&user->lP));
307 PetscCall(DestroyVecIfSet(&user->Phi));
308 PetscCall(DestroyVecIfSet(&user->lPhi));
309 PetscCall(DestroyVecIfSet(&user->Nvert));
310 PetscCall(DestroyVecIfSet(&user->lNvert));
311 PetscCall(DestroyVecIfSet(&user->ParticleCount));
312 PetscCall(DestroyVecIfSet(&user->lParticleCount));
313 PetscCall(DestroyVecIfSet(&user->Psi));
314 PetscCall(DestroyVecIfSet(&user->lPsi));
315 PetscCall(DestroyVecIfSet(&user->Qcrit));
316 PetscCall(DestroyVecIfSet(&user->P_nodal));
317 PetscCall(DestroyVecIfSet(&user->Psi_nodal));
318 PetscCall(DestroyVecIfSet(&user->Ucat));
319 PetscCall(DestroyVecIfSet(&user->lUcat));
320 PetscCall(DestroyVecIfSet(&user->Ucont));
321 PetscCall(DestroyVecIfSet(&user->lUcont));
322 PetscCall(DestroyVecIfSet(&user->Csi));
323 PetscCall(DestroyVecIfSet(&user->lCsi));
324 PetscCall(DestroyVecIfSet(&user->Eta));
325 PetscCall(DestroyVecIfSet(&user->lEta));
326 PetscCall(DestroyVecIfSet(&user->Zet));
327 PetscCall(DestroyVecIfSet(&user->lZet));
328 PetscCall(DestroyVecIfSet(&user->Aj));
329 PetscCall(DestroyVecIfSet(&user->lAj));
330 PetscCall(DestroyVecIfSet(&user->IAj));
331 PetscCall(DestroyVecIfSet(&user->lIAj));
332 PetscCall(DestroyVecIfSet(&user->JAj));
333 PetscCall(DestroyVecIfSet(&user->lJAj));
334 PetscCall(DestroyVecIfSet(&user->KAj));
335 PetscCall(DestroyVecIfSet(&user->lKAj));
336 PetscCall(DestroyVecIfSet(&user->Diffusivity));
337 PetscCall(DestroyVecIfSet(&user->lDiffusivity));
338 PetscCall(DestroyVecIfSet(&user->DiffusivityGradient));
339 PetscCall(DestroyVecIfSet(&user->lDiffusivityGradient));
340 PetscCall(DestroyVecIfSet(&user->Nu_t));
341 PetscCall(DestroyVecIfSet(&user->lNu_t));
342 PetscCall(DestroyVecIfSet(&user->Cent));
343 PetscCall(DestroyVecIfSet(&user->lCent));
344 PetscCall(DestroyVecIfSet(&user->Ucat_nodal));
345
346 PetscCall(DestroyDMIfSet(&user->da));
347 PetscCall(DestroyDMIfSet(&user->fda));
348 PetscCall(PetscFree(user));
349 if (user_ptr) {
350 *user_ptr = NULL;
351 }
352 }
353
354 if (simCtx) {
355 PetscCall(PetscFree(simCtx->pps));
356 PetscCall(PetscFree(simCtx));
357 if (simCtx_ptr) {
358 *simCtx_ptr = NULL;
359 }
360 }
361
362 PetscFunctionReturn(0);
363}
static PetscErrorCode DestroyDMIfSet(DM *dm)
Test-local routine.
static PetscErrorCode DestroyVecIfSet(Vec *vec)
Test-local routine.
Vec lDiffusivityGradient
Definition variables.h:768
Vec KAj
Definition variables.h:789
Vec Phi
Definition variables.h:764
DM post_swarm
Definition variables.h:813
Vec lIAj
Definition variables.h:787
Vec DiffusivityGradient
Definition variables.h:768
Vec lPhi
Definition variables.h:764
Vec lNu_t
Definition variables.h:792
Vec Nu_t
Definition variables.h:792
Vec IAj
Definition variables.h:787
Vec JAj
Definition variables.h:788
Vec Diffusivity
Definition variables.h:767
Vec lAj
Definition variables.h:785
PostProcessParams * pps
Definition variables.h:725
Vec lDiffusivity
Definition variables.h:767
Vec lJAj
Definition variables.h:788
Vec lKAj
Definition variables.h:789
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PicurvPopulateIdentityMetrics()

PetscErrorCode PicurvPopulateIdentityMetrics ( UserCtx user)

Fills metric vectors with identity metrics for Cartesian-reference tests.

Fills metric vectors with identity metrics for Cartesian-reference tests.

Definition at line 206 of file test_support.c.

207{
208 Cmpnts ***csi = NULL;
209 Cmpnts ***eta = NULL;
210 Cmpnts ***zet = NULL;
211
212 PetscFunctionBeginUser;
213 PetscCall(DMDAVecGetArray(user->fda, user->Csi, &csi));
214 PetscCall(DMDAVecGetArray(user->fda, user->Eta, &eta));
215 PetscCall(DMDAVecGetArray(user->fda, user->Zet, &zet));
216
217 for (PetscInt k = user->info.zs; k < user->info.zs + user->info.zm; ++k) {
218 for (PetscInt j = user->info.ys; j < user->info.ys + user->info.ym; ++j) {
219 for (PetscInt i = user->info.xs; i < user->info.xs + user->info.xm; ++i) {
220 csi[k][j][i].x = 1.0; csi[k][j][i].y = 0.0; csi[k][j][i].z = 0.0;
221 eta[k][j][i].x = 0.0; eta[k][j][i].y = 1.0; eta[k][j][i].z = 0.0;
222 zet[k][j][i].x = 0.0; zet[k][j][i].y = 0.0; zet[k][j][i].z = 1.0;
223 }
224 }
225 }
226
227 PetscCall(DMDAVecRestoreArray(user->fda, user->Csi, &csi));
228 PetscCall(DMDAVecRestoreArray(user->fda, user->Eta, &eta));
229 PetscCall(DMDAVecRestoreArray(user->fda, user->Zet, &zet));
230
231 PetscCall(DMGlobalToLocalBegin(user->fda, user->Csi, INSERT_VALUES, user->lCsi));
232 PetscCall(DMGlobalToLocalEnd(user->fda, user->Csi, INSERT_VALUES, user->lCsi));
233 PetscCall(DMGlobalToLocalBegin(user->fda, user->Eta, INSERT_VALUES, user->lEta));
234 PetscCall(DMGlobalToLocalEnd(user->fda, user->Eta, INSERT_VALUES, user->lEta));
235 PetscCall(DMGlobalToLocalBegin(user->fda, user->Zet, INSERT_VALUES, user->lZet));
236 PetscCall(DMGlobalToLocalEnd(user->fda, user->Zet, INSERT_VALUES, user->lZet));
237 PetscCall(DMGlobalToLocalBegin(user->da, user->Nvert, INSERT_VALUES, user->lNvert));
238 PetscCall(DMGlobalToLocalEnd(user->da, user->Nvert, INSERT_VALUES, user->lNvert));
239 PetscCall(DMGlobalToLocalBegin(user->da, user->P, INSERT_VALUES, user->lP));
240 PetscCall(DMGlobalToLocalEnd(user->da, user->P, INSERT_VALUES, user->lP));
241 PetscCall(DMGlobalToLocalBegin(user->da, user->Psi, INSERT_VALUES, user->lPsi));
242 PetscCall(DMGlobalToLocalEnd(user->da, user->Psi, INSERT_VALUES, user->lPsi));
243 PetscCall(DMGlobalToLocalBegin(user->fda, user->Ucat, INSERT_VALUES, user->lUcat));
244 PetscCall(DMGlobalToLocalEnd(user->fda, user->Ucat, INSERT_VALUES, user->lUcat));
245 PetscCall(DMGlobalToLocalBegin(user->fda, user->Ucont, INSERT_VALUES, user->lUcont));
246 PetscCall(DMGlobalToLocalEnd(user->fda, user->Ucont, INSERT_VALUES, user->lUcont));
247 PetscCall(DMGlobalToLocalBegin(user->fda, user->Cent, INSERT_VALUES, user->lCent));
248 PetscCall(DMGlobalToLocalEnd(user->fda, user->Cent, INSERT_VALUES, user->lCent));
249 PetscFunctionReturn(0);
250}
PetscScalar x
Definition variables.h:101
PetscScalar z
Definition variables.h:101
PetscScalar y
Definition variables.h:101
A 3D point or vector with PetscScalar components.
Definition variables.h:100
Here is the caller graph for this function:

◆ PicurvCreateSwarmPair()

PetscErrorCode PicurvCreateSwarmPair ( UserCtx user,
PetscInt  nlocal,
const char *  post_field_name 
)

Creates paired runtime/post swarms with optional extra post-processing field registration.

Creates paired runtime/post swarms with optional extra post-processing field registration.

Definition at line 255 of file test_support.c.

256{
257 PetscFunctionBeginUser;
258 if (!user) {
259 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "UserCtx cannot be NULL.");
260 }
261
262 PetscCall(DMCreate(PETSC_COMM_WORLD, &user->swarm));
263 PetscCall(DMSetType(user->swarm, DMSWARM));
264 PetscCall(DMSetDimension(user->swarm, 3));
265 PetscCall(DMSwarmSetType(user->swarm, DMSWARM_BASIC));
266 PetscCall(DMSwarmSetCellDM(user->swarm, user->da));
267 PetscCall(RegisterSwarmFieldForTests(user->swarm, "position", 3, PETSC_REAL));
268 PetscCall(RegisterSwarmFieldForTests(user->swarm, "velocity", 3, PETSC_REAL));
269 PetscCall(RegisterSwarmFieldForTests(user->swarm, "weight", 3, PETSC_REAL));
270 PetscCall(RegisterSwarmFieldForTests(user->swarm, "Psi", 1, PETSC_REAL));
271 PetscCall(DMSwarmFinalizeFieldRegister(user->swarm));
272 PetscCall(DMSwarmSetLocalSizes(user->swarm, nlocal, 0));
273
274 PetscCall(DMCreate(PETSC_COMM_WORLD, &user->post_swarm));
275 PetscCall(DMSetType(user->post_swarm, DMSWARM));
276 PetscCall(DMSetDimension(user->post_swarm, 3));
277 PetscCall(DMSwarmSetType(user->post_swarm, DMSWARM_BASIC));
278 PetscCall(DMSwarmSetCellDM(user->post_swarm, user->da));
279 PetscCall(RegisterSwarmFieldForTests(user->post_swarm, post_field_name, 1, PETSC_REAL));
280 PetscCall(DMSwarmFinalizeFieldRegister(user->post_swarm));
281 PetscCall(DMSwarmSetLocalSizes(user->post_swarm, nlocal, 0));
282 PetscFunctionReturn(0);
283}
static PetscErrorCode RegisterSwarmFieldForTests(DM swarm, const char *field_name, PetscInt field_dim, PetscDataType dtype)
Test-local routine.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PicurvMakeTempDir()

PetscErrorCode PicurvMakeTempDir ( char *  path,
size_t  path_len 
)

Creates a unique temporary directory path and materializes the directory.

Creates a unique temporary directory path and materializes the directory.

Definition at line 83 of file test_support.c.

84{
85 PetscFunctionBeginUser;
86 if (!path || path_len < 24) {
87 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Temp directory buffer is missing or too small.");
88 }
89
90 PetscCall(PetscSNPrintf(path, path_len, "/tmp/picurv-test-XXXXXX"));
91 if (!mkdtemp(path)) {
92 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN, "mkdtemp failed for '%s': %s", path, strerror(errno));
93 }
94 PetscFunctionReturn(0);
95}
Here is the caller graph for this function:

◆ PicurvEnsureDir()

PetscErrorCode PicurvEnsureDir ( const char *  path)

Ensures a directory exists, creating it if required.

Ensures a directory exists, creating it if required.

Definition at line 71 of file test_support.c.

72{
73 PetscFunctionBeginUser;
74 if (mkdir(path, 0777) != 0 && errno != EEXIST) {
75 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN, "Failed to create directory '%s': %s", path, strerror(errno));
76 }
77 PetscFunctionReturn(0);
78}
Here is the caller graph for this function:

◆ PicurvAssertRealNear()

PetscErrorCode PicurvAssertRealNear ( PetscReal  expected,
PetscReal  actual,
PetscReal  tol,
const char *  context 
)

Asserts two real values are within tolerance for test validation.

Asserts two real values are within tolerance for test validation.

Definition at line 368 of file test_support.c.

369{
370 PetscFunctionBeginUser;
371 if (PetscAbsReal(expected - actual) > tol) {
372 PetscCall(PetscPrintf(PETSC_COMM_WORLD,
373 "[FAIL] %s | expected=%0.12e actual=%0.12e tol=%0.12e\n",
374 context, (double)expected, (double)actual, (double)tol));
375 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Assertion failed.");
376 }
377 PetscFunctionReturn(0);
378}
Here is the caller graph for this function:

◆ PicurvAssertIntEqual()

PetscErrorCode PicurvAssertIntEqual ( PetscInt  expected,
PetscInt  actual,
const char *  context 
)

Asserts two integer values are exactly equal for test validation.

Asserts two integer values are exactly equal for test validation.

Definition at line 383 of file test_support.c.

384{
385 PetscFunctionBeginUser;
386 if (expected != actual) {
387 PetscCall(PetscPrintf(PETSC_COMM_WORLD,
388 "[FAIL] %s | expected=%" PetscInt_FMT " actual=%" PetscInt_FMT "\n",
389 context, expected, actual));
390 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Assertion failed.");
391 }
392 PetscFunctionReturn(0);
393}
Here is the caller graph for this function:

◆ PicurvAssertBool()

PetscErrorCode PicurvAssertBool ( PetscBool  value,
const char *  context 
)

Asserts a boolean condition is true for test validation.

Asserts a boolean condition is true for test validation.

Definition at line 398 of file test_support.c.

399{
400 PetscFunctionBeginUser;
401 if (!value) {
402 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "[FAIL] %s\n", context));
403 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Assertion failed.");
404 }
405 PetscFunctionReturn(0);
406}
Here is the caller graph for this function:

◆ PicurvAssertFileExists()

PetscErrorCode PicurvAssertFileExists ( const char *  path,
const char *  context 
)

Asserts a filesystem path exists.

Asserts a filesystem path exists.

Definition at line 411 of file test_support.c.

412{
413 PetscBool exists = PETSC_FALSE;
414
415 PetscFunctionBeginUser;
416 PetscCall(PetscTestFile(path, 'r', &exists));
417 if (!exists) {
418 PetscCall(PetscPrintf(PETSC_COMM_WORLD, "[FAIL] %s | missing file: %s\n", context, path));
419 SETERRQ(PETSC_COMM_SELF, PETSC_ERR_FILE_OPEN, "Expected file is missing.");
420 }
421 PetscFunctionReturn(0);
422}
Here is the caller graph for this function:

◆ PicurvAssertVecConstant()

PetscErrorCode PicurvAssertVecConstant ( Vec  vec,
PetscScalar  expected,
PetscReal  tol,
const char *  context 
)

Asserts every entry of a vector equals a constant within tolerance.

Asserts every entry of a vector equals a constant within tolerance.

Definition at line 427 of file test_support.c.

428{
429 PetscReal vmin = 0.0;
430 PetscReal vmax = 0.0;
431
432 PetscFunctionBeginUser;
433 PetscCall(VecMin(vec, NULL, &vmin));
434 PetscCall(VecMax(vec, NULL, &vmax));
435 PetscCall(PicurvAssertRealNear((PetscReal)expected, vmin, tol, context));
436 PetscCall(PicurvAssertRealNear((PetscReal)expected, vmax, tol, context));
437 PetscFunctionReturn(0);
438}
PetscErrorCode PicurvAssertRealNear(PetscReal expected, PetscReal actual, PetscReal tol, const char *context)
Shared test-support routine.
Here is the call graph for this function:
Here is the caller graph for this function: