13 if (!simCtx)
return PETSC_FALSE;
23 if (!simCtx)
return PETSC_FALSE;
35 PetscReal ***diff_arr = NULL;
36 const Cmpnts ***cent = NULL;
37 DMDALocalInfo info = user->
info;
38 PetscReal min_gamma = PETSC_MAX_REAL;
40 PetscFunctionBeginUser;
45 ierr = DMDAVecGetArray(user->
da, user->
Diffusivity, &diff_arr); CHKERRQ(ierr);
46 ierr = DMDAVecGetArrayRead(user->
fda, user->
Cent, ¢); CHKERRQ(ierr);
48 for (PetscInt k = info.zs; k < info.zs + info.zm; ++k) {
49 for (PetscInt j = info.ys; j < info.ys + info.ym; ++j) {
50 for (PetscInt i = info.xs; i < info.xs + info.xm; ++i) {
52 const PetscReal gamma =
55 diff_arr[k][j][i] = gamma;
56 min_gamma = PetscMin(min_gamma, gamma);
61 ierr = DMDAVecRestoreArrayRead(user->
fda, user->
Cent, ¢); CHKERRQ(ierr);
62 ierr = DMDAVecRestoreArray(user->
da, user->
Diffusivity, &diff_arr); CHKERRQ(ierr);
65 PetscReal global_min_gamma = 0.0;
66 ierr = MPI_Allreduce(&min_gamma, &global_min_gamma, 1, MPIU_REAL, MPI_MIN, PETSC_COMM_WORLD); CHKERRMPI(ierr);
68 if (global_min_gamma <= 0.0) {
69 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
70 "verification diffusivity override produced non-positive Gamma values (min=%g).",
71 (
double)global_min_gamma);
76 const char *periodic_fields[] = {
"Diffusivity"};
82 "Applied verification diffusivity override profile '%s' (gamma0=%g, slope_x=%g).\n",
87 PetscFunctionReturn(0);
96 PetscFunctionBeginUser;
97 if (!user) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
"UserCtx cannot be NULL.");
103 "Applied verification scalar override profile '%s' to particle field 'Psi'.\n",
105 PetscFunctionReturn(0);
PetscErrorCode SetAnalyticalScalarFieldOnParticles(UserCtx *user, const char *swarm_field_name)
Writes the configured verification scalar profile onto a particle swarm scalar field.
PetscErrorCode SynchronizePeriodicCellFields(UserCtx *user, PetscInt num_fields, const char *field_names[])
Synchronizes periodic endpoint cells for a list of cell-centered fields.
Logging utilities and macros for PETSc-based applications.
#define GLOBAL
Scope for global logging across all processes.
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
@ LOG_DEBUG
Detailed debugging information.
PetscErrorCode UpdateLocalGhosts(UserCtx *user, const char *fieldName)
Updates the local vector (including ghost points) from its corresponding global vector.
SimCtx * simCtx
Back-pointer to the master simulation context.
VerificationScalarConfig verificationScalar
VerificationDiffusivityConfig verificationDiffusivity
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.
PetscErrorCode ApplyVerificationDiffusivityOverride(UserCtx *user)
Fills the Eulerian diffusivity field from the configured verification profile.
PetscBool VerificationDiffusivityOverrideActive(const SimCtx *simCtx)
Reports whether the verification-only diffusivity override is enabled.
PetscErrorCode ApplyVerificationScalarOverrideToParticles(UserCtx *user)
Fills the particle Psi field from the configured verification scalar profile.
PetscBool VerificationScalarOverrideActive(const SimCtx *simCtx)
Reports whether the verification-only scalar override is enabled.