18 double values[3][3][3];
19 double weights[3][3][3];
21 PetscFunctionBeginUser;
22 PetscCall(PetscMemzero(&simCtx,
sizeof(simCtx)));
23 for (PetscInt k = 0; k < 3; ++k) {
24 for (PetscInt j = 0; j < 3; ++j) {
25 for (PetscInt i = 0; i < 3; ++i) {
26 values[k][j][i] = 2.0;
27 weights[k][j][i] = 1.0;
34 "Simpson-rule filter should preserve a constant field"));
38 "box filter should preserve a constant field"));
40 for (PetscInt k = 0; k < 3; ++k) {
41 for (PetscInt j = 0; j < 3; ++j) {
42 for (PetscInt i = 0; i < 3; ++i) {
43 weights[k][j][i] = 0.0;
48 "box filter should return zero when all weights are zero"));
49 PetscFunctionReturn(0);
60 PetscFunctionBeginUser;
63 "TGV3D should require custom geometry"));
65 "ZERO_FLOW should not require custom geometry"));
74 PetscFunctionReturn(0);
87 PetscFunctionBeginUser;
89 PetscCall(VecDuplicate(user->
Ucont, &rct));
90 PetscCall(VecZeroEntries(rct));
100 PetscCall(DMDAVecGetArrayRead(user->
fda, rct, &rct_arr));
102 "driven flow source should update the x component"));
104 "driven flow source should leave the y component unchanged"));
106 "driven flow source should leave the z component unchanged"));
107 PetscCall(DMDAVecRestoreArrayRead(user->
fda, rct, &rct_arr));
109 PetscCall(VecDestroy(&rct));
111 PetscFunctionReturn(0);
126 ierr = PetscInitialize(&argc, &argv, NULL,
"PICurv solver utility tests");
131 ierr =
PicurvRunTests(
"unit-solver", cases,
sizeof(cases) /
sizeof(cases[0]));
137 ierr = PetscFinalize();
PetscBool AnalyticalTypeRequiresCustomGeometry(const char *analytical_type)
Reports whether an analytical type requires custom geometry/decomposition logic.
PetscErrorCode SetAnalyticalGridInfo(UserCtx *user)
Sets the grid domain and resolution for analytical solution cases.
PetscErrorCode ComputeDrivenChannelFlowSource(UserCtx *user, Vec Rct)
Applies a momentum source term to drive flow in a periodic channel or pipe.
double ApplyLESTestFilter(const SimCtx *simCtx, double values[3][3][3], double weights[3][3][3])
Applies a numerical "test filter" to a 3x3x3 stencil of data points.
int main(int argc, char **argv)
Entry point for this unit-test binary.
static PetscErrorCode TestDrivenChannelFlowSource(void)
Test-local routine.
static PetscErrorCode TestAnalyticalGeometrySelection(void)
Test-local routine.
static PetscErrorCode TestLESTestFilterPaths(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 PicurvAssertBool(PetscBool value, const char *context)
Shared test-support routine.
C test module for PICurv.
Named test case descriptor consumed by PicurvRunTests.
BoundaryFaceConfig boundary_faces[6]
PetscReal forceScalingFactor
@ BC_HANDLER_PERIODIC_DRIVEN_CONSTANT_FLUX
BCHandlerType handler_type
PetscReal bulkVelocityCorrection
char AnalyticalSolutionType[PETSC_MAX_PATH_LEN]
PetscReal drivingForceMagnitude
A 3D point or vector with PetscScalar components.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.