PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Functions
ParticlePhysics.h File Reference

Header file for Particle related physics modules. More...

#include <petsc.h>
#include <petscdmswarm.h>
#include <stdbool.h>
#include <petscsys.h>
#include <math.h>
#include "variables.h"
#include "particle_field_catalog.h"
#include "logging.h"
#include "walkingsearch.h"
Include dependency graph for ParticlePhysics.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PetscErrorCode UpdateParticleField (ParticleFieldId field_id, PetscReal dt, PetscReal *psi_io, PetscReal diffusivity, PetscReal mean_val, PetscReal delta2, PetscReal C_model)
 Updates a single particle's field based on its state and physics model.
 
PetscErrorCode UpdateFieldForAllParticles (UserCtx *user, ParticleFieldId field_id)
 Loops over all local particles and updates a specified field.
 
PetscErrorCode UpdateAllParticleFields (UserCtx *user)
 Orchestrates the update of all physical properties for particles.
 
PetscErrorCode ComputeEulerianDiffusivity (UserCtx *user)
 Computes the effective diffusivity scalar field (Gamma_eff) on the Eulerian grid.
 
PetscErrorCode ComputeEulerianDiffusivityGradient (UserCtx *user)
 Computes the Eulerian gradient of the effective diffusivity field.
 

Detailed Description

Header file for Particle related physics modules.

This file contains declarations of functions responsible for solving for fields in the particle swarms within a simulation using PETSc's DMSwarm.

Definition in file ParticlePhysics.h.

Function Documentation

◆ UpdateParticleField()

PetscErrorCode UpdateParticleField ( ParticleFieldId  field_id,
PetscReal  dt,
PetscReal *  psi_io,
PetscReal  diffusivity,
PetscReal  mean_val,
PetscReal  delta2,
PetscReal  C_model 
)

Updates a single particle's field based on its state and physics model.

Implements the IEM (Interaction by Exchange with the Mean) model for scalar mixing. Physics: dPsi/dt = -Omega * (Psi - Psi_mean) Solution: Psi_new = Psi_mean + (Psi_old - Psi_mean) * exp(-Omega * dt)

Parameters
field_idTyped particle-field identity.
dtTime
psi_ioPointer
diffusivityParticle
mean_valLocal
delta2Squared mixing length: the host cell volume to the power 2/3, the volume floored at 1e-14 first.
C_modelModel
Returns
PetscErrorCode 0 on success.

Updates a single particle's field based on its state and physics model.

See also
UpdateParticleField()

Definition at line 36 of file ParticlePhysics.c.

43{
44 PetscFunctionBeginUser;
45
46 if (field_id == PARTICLE_FIELD_ID_PSI) {
47 // The IEM model relaxes Psi exponentially toward its target, mean_val, over dt.
48 PetscReal decay = IEMDecayFactor(C_model, diffusivity, delta2, dt);
49
50 PetscReal psi_old = *psi_io;
51 *psi_io = mean_val + (psi_old - mean_val) * decay;
52 }
53
54 PetscFunctionReturn(0);
55}
static PetscReal IEMDecayFactor(PetscReal C_model, PetscReal diffusivity, PetscReal delta2, PetscReal dt)
IEM decay factor exp(-omega dt) over one step, omega = C D / delta2.
@ PARTICLE_FIELD_ID_PSI
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateFieldForAllParticles()

PetscErrorCode UpdateFieldForAllParticles ( UserCtx *  user,
ParticleFieldId  field_id 
)

Loops over all local particles and updates a specified field.

This function orchestrates the update of a single particle field across the entire local swarm. It gets access to the necessary particle data arrays and calls the UpdateParticleField kernel for each particle.

For Psi the IEM target is the host cell's limited linear reconstruction m + zeta g . (x - x_c): m and x_c are the cell's Psi mean and particle centroid weighted by each particle's relaxation weight 1 - exp(-omega_p dt), so every cell's Psi total is kept whatever the particles' rates; g is the gradient of the plain cell means; zeta in [0, 1] keeps every target within the extrema of all particles' Psi at the start of the step, so Psi stays within them. Collective for Psi.

Parameters
[in,out]userPointer to the UserCtx containing the swarm and simulation context.
[in]field_idTyped identity of the field to update.
Returns
PetscErrorCode 0 on success.

Loops over all local particles and updates a specified field.

See also
UpdateFieldForAllParticles()

Definition at line 250 of file ParticlePhysics.c.

251{
252 PetscErrorCode ierr;
253 DM swarm = user->swarm;
254 DM da = user->da;
255 PetscInt n_local;
256 PetscReal dt = user->simCtx->dt;
257 PetscReal C_IEM = user->simCtx->iem_constant;
258
259 PetscReal *psi_arr = NULL;
260 PetscReal *diff_arr = NULL;
261 PetscReal *pos_arr = NULL;
262 PetscInt *cell_arr = NULL;
263 PetscInt64 *pid_arr = NULL;
264
265 PetscReal ***grid_aj = NULL;
266 Cmpnts ***grid_slope = NULL, ***grid_centroid = NULL, ***grid_moments = NULL;
267 Vec lslope = NULL, lcentroid = NULL, lmoments = NULL;
268
269 PetscBool accessed_eulerian = PETSC_FALSE;
270 const ParticleFieldDescriptor *descriptor = NULL;
271 const char *fieldName = NULL;
272
273 PetscFunctionBeginUser;
275
276 ierr = ParticleFieldGetDescriptor(field_id, &descriptor); CHKERRQ(ierr);
277 PetscCheck((descriptor->capabilities & PARTICLE_FIELD_CAPABILITY_MODEL_UPDATE) != 0,
278 PETSC_COMM_SELF, PETSC_ERR_SUP,
279 "Particle field '%s' has no registered model-update kernel.",
280 descriptor->canonical_name);
281 fieldName = descriptor->canonical_name;
282
283 // Relax toward the mean of the particles where they are now. The Eulerian Psi otherwise
284 // holds the previous step's scatter, taken before the particles moved and migrated; the
285 // scatter recounts the particles per cell itself. Collective, so it comes before the early
286 // return of ranks with no particles.
287 if (field_id == PARTICLE_FIELD_ID_PSI) {
288 Vec slope = NULL;
289
290 // Psi relaxation requires ghosted Eulerian mean and Jacobian fields.
291 PetscCheck(user->lPsi && user->lAj, PETSC_COMM_SELF, PETSC_ERR_ARG_WRONGSTATE, "UserCtx lPsi or lAj not initialized.");
292 ierr = ScatterAllParticleFieldsToEulerFields(user); CHKERRQ(ierr);
293 // The target is the cell's limited linear reconstruction m + zeta g . (x - xc), with m and
294 // xc weighted by each particle's relaxation weight so each cell's total is kept, and zeta
295 // keeping every target within the particles' Psi extrema (ComputeIEMTargetMoments).
296 // Relaxing to the stepped mean alone adds transport that does not vanish with refinement.
297 // A particle's cell is stored one index past its origin node, so the cell fields are read
298 // through ghosted copies.
299 // The scatter's count holds only this rank's particles in its ghost cells; the empty-cell
300 // test reads neighbours across subdomain seams, so their totals are fetched first.
301 ierr = UpdateLocalGhosts(user, FIELD_ID_PARTICLE_COUNT); CHKERRQ(ierr);
302 ierr = DMGetGlobalVector(user->fda, &slope); CHKERRQ(ierr);
303 ierr = ComputeCellScalarGradient(user, user->lPsi, user->lParticleCount, slope); CHKERRQ(ierr);
304 ierr = DMGetLocalVector(user->fda, &lslope); CHKERRQ(ierr);
305 ierr = DMGlobalToLocal(user->fda, slope, INSERT_VALUES, lslope); CHKERRQ(ierr);
306 ierr = DMRestoreGlobalVector(user->fda, &slope); CHKERRQ(ierr);
307 ierr = ComputeIEMTargetMoments(user, dt, C_IEM, lslope, &lmoments, &lcentroid); CHKERRQ(ierr);
308 }
309
310 ierr = DMSwarmGetLocalSize(swarm, &n_local); CHKERRQ(ierr);
311 if (n_local == 0) {
312 if (lslope) { ierr = DMRestoreLocalVector(user->fda, &lslope); CHKERRQ(ierr); }
313 if (lcentroid) { ierr = DMRestoreLocalVector(user->fda, &lcentroid); CHKERRQ(ierr); }
314 if (lmoments) { ierr = DMRestoreLocalVector(user->fda, &lmoments); CHKERRQ(ierr); }
316 PetscFunctionReturn(0);
317 }
318
319 ierr = DMSwarmGetField(swarm, fieldName, NULL, NULL, (void**)&psi_arr); CHKERRQ(ierr);
320 ierr = DMSwarmGetField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_PID), NULL, NULL, (void**)&pid_arr); CHKERRQ(ierr);
321
322 if (field_id == PARTICLE_FIELD_ID_PSI) {
323 ierr = DMSwarmGetField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_DIFFUSIVITY), NULL, NULL, (void**)&diff_arr); CHKERRQ(ierr);
324 ierr = DMSwarmGetField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_CELL_ID), NULL, NULL, (void**)&cell_arr); CHKERRQ(ierr);
325 ierr = DMSwarmGetField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_POSITION), NULL, NULL, (void**)&pos_arr); CHKERRQ(ierr);
326
327 ierr = DMDAVecGetArrayRead(da, user->lAj, &grid_aj); CHKERRQ(ierr);
328 ierr = DMDAVecGetArrayRead(user->fda, lslope, &grid_slope); CHKERRQ(ierr);
329 ierr = DMDAVecGetArrayRead(user->fda, lcentroid, &grid_centroid); CHKERRQ(ierr);
330 ierr = DMDAVecGetArrayRead(user->fda, lmoments, &grid_moments); CHKERRQ(ierr);
331 accessed_eulerian = PETSC_TRUE;
332 }
333
334 // The filter width depends only on the cell, and the particles are stored in cell order,
335 // so it is recomputed only when the cell changes.
336 PetscInt width_cell[3] = {-1, -1, -1};
337 PetscReal p_delta2 = 1.0;
338 for (PetscInt p = 0; p < n_local; ++p) {
339 PetscReal p_diff = 0.0;
340 PetscReal p_mean = 0.0;
341
342 if (field_id == PARTICLE_FIELD_ID_PSI) {
343 // Cell IDs are 0-based geometric indices; cell-centred storage starts at index 1
344 // (index 0 is the boundary slot), the shift the scatter applies when it writes lPsi.
345 PetscInt i = cell_arr[3*p + 0] + 1;
346 PetscInt j = cell_arr[3*p + 1] + 1;
347 PetscInt k = cell_arr[3*p + 2] + 1;
348
349 const Cmpnts g = grid_slope[k][j][i], c = grid_centroid[k][j][i], mz = grid_moments[k][j][i];
350 p_diff = diff_arr[p];
351 p_mean = mz.x + mz.y * (g.x * (pos_arr[3*p + 0] - c.x) + g.y * (pos_arr[3*p + 1] - c.y)
352 + g.z * (pos_arr[3*p + 2] - c.z));
353
354 if (i != width_cell[0] || j != width_cell[1] || k != width_cell[2]) {
355 // Aj is the reciprocal cell volume in the curvilinear-grid representation.
356 p_delta2 = IEMMixingLength2(grid_aj[k][j][i]);
357 width_cell[0] = i; width_cell[1] = j; width_cell[2] = k;
358 }
359 }
360
361 const PetscReal psi_old = psi_arr[p];
362 ierr = UpdateParticleField(field_id, dt, &psi_arr[p], p_diff, p_mean, p_delta2, C_IEM);
363 CHKERRQ(ierr);
364 LOG_PARTICLE(user->simCtx, pid_arr[p], "mix",
365 "%s %.10e -> %.10e | target %.10e | diffusivity %.6e mixing length^2 %.6e C %.4f dt %.6e\n",
366 fieldName, psi_old, psi_arr[p], p_mean, p_diff, p_delta2, C_IEM, dt);
367 }
368
369 ierr = DMSwarmRestoreField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_PID), NULL, NULL, (void**)&pid_arr); CHKERRQ(ierr);
370 ierr = DMSwarmRestoreField(swarm, fieldName, NULL, NULL, (void**)&psi_arr); CHKERRQ(ierr);
371
372 if (field_id == PARTICLE_FIELD_ID_PSI) {
373 ierr = DMSwarmRestoreField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_DIFFUSIVITY), NULL, NULL, (void**)&diff_arr); CHKERRQ(ierr);
374 ierr = DMSwarmRestoreField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_CELL_ID), NULL, NULL, (void**)&cell_arr); CHKERRQ(ierr);
375 ierr = DMSwarmRestoreField(swarm, ParticleFieldName(PARTICLE_FIELD_ID_POSITION), NULL, NULL, (void**)&pos_arr); CHKERRQ(ierr);
376 }
377
378 if (accessed_eulerian) {
379 ierr = DMDAVecRestoreArrayRead(da, user->lAj, &grid_aj); CHKERRQ(ierr);
380 ierr = DMDAVecRestoreArrayRead(user->fda, lslope, &grid_slope); CHKERRQ(ierr);
381 ierr = DMDAVecRestoreArrayRead(user->fda, lcentroid, &grid_centroid); CHKERRQ(ierr);
382 ierr = DMDAVecRestoreArrayRead(user->fda, lmoments, &grid_moments); CHKERRQ(ierr);
383 ierr = DMRestoreLocalVector(user->fda, &lslope); CHKERRQ(ierr);
384 ierr = DMRestoreLocalVector(user->fda, &lcentroid); CHKERRQ(ierr);
385 ierr = DMRestoreLocalVector(user->fda, &lmoments); CHKERRQ(ierr);
386 }
387
388 LOG_ALLOW(GLOBAL, LOG_DEBUG, "Updated particle physics for field '%s'.\n", fieldName);
389
391 PetscFunctionReturn(0);
392}
static PetscErrorCode ComputeCellScalarGradient(UserCtx *user, Vec lscalar, Vec lcount, Vec gradient)
Cartesian gradient of a cell-centred scalar at every owned physical cell.
static PetscReal IEMMixingLength2(PetscReal aj)
Squared IEM mixing length of a cell: its volume to the power 2/3, from the reciprocal volume Aj,...
static PetscErrorCode ComputeIEMTargetMoments(UserCtx *user, PetscReal dt, PetscReal C_model, Vec lslope, Vec *lmoments_out, Vec *lcentroid_out)
Per-cell quantities of the bounded, conservative IEM target.
PetscErrorCode UpdateParticleField(ParticleFieldId field_id, PetscReal dt, PetscReal *psi_io, PetscReal diffusivity, PetscReal mean_val, PetscReal delta2, PetscReal C_model)
Implementation of UpdateParticleField().
@ FIELD_ID_PARTICLE_COUNT
PetscErrorCode ScatterAllParticleFieldsToEulerFields(UserCtx *user)
Scatters a predefined set of particle fields to their corresponding Eulerian fields.
#define LOG_PARTICLE(simCtx, pid, stage, fmt,...)
Reports one particle at one stage of a step: the consolidated per-particle line.
Definition logging.h:355
#define GLOBAL
Scope for global logging across all processes.
Definition logging.h:46
#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:214
#define PROFILE_FUNCTION_END
Marks the end of a profiled code block.
Definition logging.h:1029
@ LOG_DEBUG
Detailed debugging information.
Definition logging.h:32
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled function: an always-on aggregate timer.
Definition logging.h:1000
const char * ParticleFieldName(ParticleFieldId field_id)
Return the canonical PETSc DMSwarm name for an ID.
@ PARTICLE_FIELD_ID_POSITION
@ PARTICLE_FIELD_ID_PID
@ PARTICLE_FIELD_ID_CELL_ID
@ PARTICLE_FIELD_ID_DIFFUSIVITY
@ PARTICLE_FIELD_CAPABILITY_MODEL_UPDATE
PetscErrorCode ParticleFieldGetDescriptor(ParticleFieldId field_id, const ParticleFieldDescriptor **descriptor)
Return immutable metadata for a valid particle field ID.
Immutable metadata for one persistent particle field.
PetscErrorCode UpdateLocalGhosts(UserCtx *user, FieldId field_id)
Updates the local vector (including ghost points) from its corresponding global vector.
Definition setup.c:2593
SimCtx * simCtx
Back-pointer to the master simulation context.
Definition variables.h:1160
PetscReal iem_constant
IEM mixing constant C_IEM in Omega = C_IEM Gamma / Delta^2 (default 2.0).
Definition variables.h:1006
PetscReal dt
Definition variables.h:933
PetscScalar x
Definition variables.h:145
Vec lParticleCount
Definition variables.h:1276
PetscScalar z
Definition variables.h:145
PetscScalar y
Definition variables.h:145
A 3D point or vector with PetscScalar components.
Definition variables.h:144
Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateAllParticleFields()

PetscErrorCode UpdateAllParticleFields ( UserCtx *  user)

Orchestrates the update of all physical properties for particles.

This function serves as the top-level entry point for updating particle-specific physical quantities after their position and the surrounding fluid velocity are known. It calls a sequence of more specific update routines for each property.

For example, it can be configured to update:

Parameters
[in,out]userPointer to the UserCtx containing the swarm and simulation context.
Returns
PetscErrorCode 0 on success.

Orchestrates the update of all physical properties for particles.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticlePhysics.h.

See also
UpdateAllParticleFields()

Definition at line 400 of file ParticlePhysics.c.

401{
402 PetscErrorCode ierr;
403 PetscFunctionBeginUser;
405
406 LOG_ALLOW(GLOBAL, LOG_INFO, "Updating all particle physical properties...\n");
407
409 // Verification profiles define Psi exactly, so bypass the model-driven update.
410 ierr = ApplyVerificationScalarOverrideToParticles(user); CHKERRQ(ierr);
411 LOG_ALLOW(GLOBAL, LOG_INFO, "Verification scalar override active; skipped model-driven Psi update.\n");
413 PetscFunctionReturn(0);
414 }
415
416 /* C_IEM = 0 switches micromixing off. The update is skipped rather than run with a
417 * zero rate: mean + (psi - mean) * 1 need not round-trip to psi exactly, and a passive
418 * label must stay bit-identical. */
419 if (user->simCtx->iem_constant == 0.0) {
420 LOG_ALLOW(GLOBAL, LOG_INFO, "IEM constant is zero; Psi is carried unchanged.\n");
421 } else {
422 ierr = UpdateFieldForAllParticles(user, PARTICLE_FIELD_ID_PSI); CHKERRQ(ierr);
423 }
424
425 LOG_ALLOW(GLOBAL, LOG_INFO, "All particle physical properties updated.\n");
426
428 PetscFunctionReturn(0);
429}
PetscErrorCode UpdateFieldForAllParticles(UserCtx *user, ParticleFieldId field_id)
Implementation of UpdateFieldForAllParticles().
@ LOG_INFO
Informational messages about program execution.
Definition logging.h:31
PetscErrorCode ApplyVerificationScalarOverrideToParticles(UserCtx *user)
Populates the particle Psi field from a verification-only source override.
PetscBool VerificationScalarOverrideActive(const SimCtx *simCtx)
Reports whether a verification-only scalar override is active.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeEulerianDiffusivity()

PetscErrorCode ComputeEulerianDiffusivity ( UserCtx *  user)

Computes the effective diffusivity scalar field (Gamma_eff) on the Eulerian grid.

This function calculates the total diffusivity used to drive the stochastic motion of particles (Scalar FDF). It combines molecular diffusion and turbulent diffusion.

Formula: Gamma_eff = nu/Sc + nu_t/Sc_t

Where:

  • nu = 1/Re (kinematic viscosity)
  • nu_t (eddy viscosity from LES/RANS model)
  • Sc (molecular Schmidt number)
  • Sc_t (turbulent Schmidt number)
Note
If turbulence models are disabled, nu_t is assumed to be 0.
This function updates the local ghost values of lDiffusivity at the end to ensure gradients can be computed correctly at subdomain boundaries.
Parameters
[in,out]userPointer to the user context containing grid data and simulation parameters.
Returns
PetscErrorCode 0 on success.

Computes the effective diffusivity scalar field (Gamma_eff) on the Eulerian grid.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/ParticlePhysics.h.

See also
ComputeEulerianDiffusivity()

Definition at line 437 of file ParticlePhysics.c.

438{
439 const SimCtx *simCtx = user->simCtx;
440 const DMDALocalInfo info = user->info;
441 // Grid uses indices 1 to M-2 for physical cells; index 0 and M-1 are boundary holders.
442 const PetscInt lo[3] = {PetscMax(info.xs, 1), PetscMax(info.ys, 1), PetscMax(info.zs, 1)};
443 const PetscInt hi[3] = {PetscMin(info.xs + info.xm, info.mx - 1), PetscMin(info.ys + info.ym, info.my - 1),
444 PetscMin(info.zs + info.zm, info.mz - 1)};
445 PetscReal ***diff_arr = NULL;
446 const PetscReal ***nut_arr = NULL;
447
448 PetscFunctionBeginUser;
450
454 PetscFunctionReturn(0);
455 }
456
457 // Gamma = nu / Sc + nu_t / Sc_t, with nu = 1/Re (0 when Re is unset or not positive) and the
458 // Schmidt numbers 1 and 0.7 when unset. The eddy viscosity enters only with LES; a dynamic
459 // model can give a slightly negative one, which is clipped to 0 so the Brownian amplitude
460 // sqrt(2 Gamma dt) stays real.
461 const PetscReal nu_molecular = (simCtx->ren > 1.0e-12) ? 1.0 / simCtx->ren : 0.0;
462 const PetscReal Sc = (simCtx->schmidt_number > 1.0e-6) ? simCtx->schmidt_number : 1.0;
463 const PetscReal Sct = (simCtx->Turbulent_schmidt_number > 1.0e-6) ? simCtx->Turbulent_schmidt_number : 0.7;
464 const PetscReal gamma_molecular = nu_molecular / Sc;
465 const PetscBool use_turbulence_model = simCtx->les ? PETSC_TRUE : PETSC_FALSE;
466
467 PetscCall(DMDAVecGetArray(user->da, user->Diffusivity, &diff_arr));
468 if (use_turbulence_model) PetscCall(DMDAVecGetArrayRead(user->da, user->Nu_t, (void *)&nut_arr));
469 for (PetscInt k = lo[2]; k < hi[2]; k++) {
470 for (PetscInt j = lo[1]; j < hi[1]; j++) {
471 for (PetscInt i = lo[0]; i < hi[0]; i++) {
472 PetscReal gamma_turbulent = 0.0;
473 if (use_turbulence_model) gamma_turbulent = PetscMax(nut_arr[k][j][i], 0.0) / Sct;
474 diff_arr[k][j][i] = gamma_molecular + gamma_turbulent;
475 }
476 }
477 }
478 if (use_turbulence_model) PetscCall(DMDAVecRestoreArrayRead(user->da, user->Nu_t, (void *)&nut_arr));
479 PetscCall(DMDAVecRestoreArray(user->da, user->Diffusivity, &diff_arr));
480
481 // The diffusivity gradient and the particle interpolation read the periodic dummy cells and
482 // the ghosts.
483 const FieldId periodic_fields[] = {FIELD_ID_DIFFUSIVITY};
484 PetscCall(SynchronizePeriodicCellFields(user, 1, periodic_fields));
485 PetscCall(UpdateLocalGhosts(user, FIELD_ID_DIFFUSIVITY));
487 PetscFunctionReturn(0);
488}
PetscErrorCode SynchronizePeriodicCellFields(UserCtx *user, PetscInt num_fields, const FieldId field_ids[])
Synchronizes periodic endpoint cells for a list of cell-centered fields.
FieldId
Compile-time identity for a catalogued Eulerian field.
@ FIELD_ID_DIFFUSIVITY
PetscReal schmidt_number
Definition variables.h:1005
PetscReal Turbulent_schmidt_number
Definition variables.h:1005
PetscReal ren
Definition variables.h:965
Vec Diffusivity
Definition variables.h:1200
DMDALocalInfo info
Definition variables.h:1169
PetscInt les
Active LES closure; an LESModelType value.
Definition variables.h:1041
The master context for the entire simulation.
Definition variables.h:916
PetscErrorCode ApplyVerificationDiffusivityOverride(UserCtx *user)
Populates the Eulerian diffusivity field from a verification-only source override.
PetscBool VerificationDiffusivityOverrideActive(const SimCtx *simCtx)
Reports whether a verification-only diffusivity override is active.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeEulerianDiffusivityGradient()

PetscErrorCode ComputeEulerianDiffusivityGradient ( UserCtx *  user)

Computes the Eulerian gradient of the effective diffusivity field.

Reads the scalar diffusivity field and writes a vector gradient field used by particle stochastic transport updates.

Parameters
[in,out]userPointer to user context containing diffusivity vectors.
Returns
PetscErrorCode 0 on success.

Computes the Eulerian gradient of the effective diffusivity field.

See also
ComputeEulerianDiffusivityGradient()

Definition at line 565 of file ParticlePhysics.c.

566{
567 PetscFunctionBeginUser;
569 // Central differences read the neighbours across subdomain and periodic seams.
570 PetscCall(UpdateLocalGhosts(user, FIELD_ID_DIFFUSIVITY));
571 PetscCall(ComputeCellScalarGradient(user, user->lDiffusivity, NULL, user->DiffusivityGradient));
572 // A particle within half a cell of a periodic seam interpolates across it, reading the
573 // periodic dummy cells, which the gradient's owned-cell loop does not write.
574 const FieldId periodic_fields[] = {FIELD_ID_DIFFUSIVITY_GRADIENT};
575 PetscCall(SynchronizePeriodicCellFields(user, 1, periodic_fields));
576 // Particles near subdomain boundaries interpolate the gradient, so its ghosts are filled.
579 PetscFunctionReturn(0);
580}
@ FIELD_ID_DIFFUSIVITY_GRADIENT
Vec DiffusivityGradient
Definition variables.h:1201
Vec lDiffusivity
Definition variables.h:1200
Here is the call graph for this function:
Here is the caller graph for this function: