PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
Functions
verification_sources.h File Reference
#include "variables.h"
Include dependency graph for verification_sources.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PetscBool VerificationDiffusivityOverrideActive (const SimCtx *simCtx)
 Reports whether a verification-only diffusivity override is active.
 
PetscErrorCode ApplyVerificationDiffusivityOverride (UserCtx *user)
 Populates the Eulerian diffusivity field from a verification-only source override.
 

Function Documentation

◆ VerificationDiffusivityOverrideActive()

PetscBool VerificationDiffusivityOverrideActive ( const SimCtx simCtx)

Reports whether a verification-only diffusivity override is active.

Parameters
simCtxSimulation context.
Returns
PETSC_TRUE when a verification diffusivity source override is enabled.

Reports whether a verification-only diffusivity override is active.

Parameters
[in]simCtxSimulation context carrying parsed verification settings.
Returns
PETSC_TRUE when verification.sources.diffusivity is active.

Definition at line 12 of file verification_sources.c.

13{
14 if (!simCtx) return PETSC_FALSE;
15 return simCtx->verificationDiffusivity.enabled;
16}
VerificationDiffusivityConfig verificationDiffusivity
Definition variables.h:667
Here is the caller graph for this function:

◆ ApplyVerificationDiffusivityOverride()

PetscErrorCode ApplyVerificationDiffusivityOverride ( UserCtx user)

Populates the Eulerian diffusivity field from a verification-only source override.

Parameters
[in,out]userBlock-local context whose Diffusivity vector will be filled.
Returns
PetscErrorCode 0 on success.

Populates the Eulerian diffusivity field from a verification-only source override.

Parameters
[in,out]userBlock-local user context whose Diffusivity field is overridden.
Returns
PetscErrorCode 0 on success.

Definition at line 24 of file verification_sources.c.

25{
26 PetscErrorCode ierr;
27 SimCtx *simCtx = user->simCtx;
28 PetscReal ***diff_arr = NULL;
29 const Cmpnts ***cent = NULL;
30 DMDALocalInfo info = user->info;
31 PetscReal min_gamma = PETSC_MAX_REAL;
32
33 PetscFunctionBeginUser;
34
35 if (!VerificationDiffusivityOverrideActive(simCtx)) PetscFunctionReturn(0);
36
37 ierr = DMDAVecGetArray(user->da, user->Diffusivity, &diff_arr); CHKERRQ(ierr);
38 ierr = DMDAVecGetArrayRead(user->fda, user->Cent, &cent); CHKERRQ(ierr);
39
40 for (PetscInt k = info.zs; k < info.zs + info.zm; ++k) {
41 for (PetscInt j = info.ys; j < info.ys + info.ym; ++j) {
42 for (PetscInt i = info.xs; i < info.xs + info.xm; ++i) {
43 const PetscReal gamma =
45 simCtx->verificationDiffusivity.slope_x * cent[k][j][i].x;
46 diff_arr[k][j][i] = gamma;
47 min_gamma = PetscMin(min_gamma, gamma);
48 }
49 }
50 }
51
52 ierr = DMDAVecRestoreArrayRead(user->fda, user->Cent, &cent); CHKERRQ(ierr);
53 ierr = DMDAVecRestoreArray(user->da, user->Diffusivity, &diff_arr); CHKERRQ(ierr);
54
55 {
56 PetscReal global_min_gamma = 0.0;
57 ierr = MPI_Allreduce(&min_gamma, &global_min_gamma, 1, MPIU_REAL, MPI_MIN, PETSC_COMM_WORLD); CHKERRMPI(ierr);
58 if (global_min_gamma <= 0.0) {
59 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_ARG_WRONG,
60 "verification diffusivity override produced non-positive Gamma values (min=%g).",
61 (double)global_min_gamma);
62 }
63 }
64
65 ierr = UpdateLocalGhosts(user, "Diffusivity"); CHKERRQ(ierr);
67 "Applied verification diffusivity override profile '%s' (gamma0=%g, slope_x=%g).\n",
69 (double)simCtx->verificationDiffusivity.gamma0,
70 (double)simCtx->verificationDiffusivity.slope_x);
71
72 PetscFunctionReturn(0);
73}
#define GLOBAL
Scope for global logging across all processes.
Definition logging.h:45
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
Definition logging.h:199
@ LOG_DEBUG
Detailed debugging information.
Definition logging.h:31
PetscErrorCode UpdateLocalGhosts(UserCtx *user, const char *fieldName)
Updates the local vector (including ghost points) from its corresponding global vector.
Definition setup.c:1265
SimCtx * simCtx
Back-pointer to the master simulation context.
Definition variables.h:779
PetscScalar x
Definition variables.h:101
Vec Diffusivity
Definition variables.h:805
DMDALocalInfo info
Definition variables.h:783
Vec Cent
Definition variables.h:823
A 3D point or vector with PetscScalar components.
Definition variables.h:100
The master context for the entire simulation.
Definition variables.h:611
PetscBool VerificationDiffusivityOverrideActive(const SimCtx *simCtx)
Reports whether the verification-only diffusivity override is enabled.
Here is the call graph for this function:
Here is the caller graph for this function: