5#include <petscdmswarm.h>
10#include <petscdmcomposite.h>
11#include <petscerror.h>
36#define InterpolateFieldFromCornerToCenter(field, centfield, user) \
37 ( (void)sizeof(char[1 - 2*!!(!__builtin_types_compatible_p(typeof(field), typeof(centfield)))]),\
39 PetscReal ***: InterpolateFieldFromCornerToCenter_Scalar, \
40 Cmpnts ***: InterpolateFieldFromCornerToCenter_Vector \
41 )(field, centfield, user) )
56#define InterpolateFieldFromCenterToCorner(blockSize, centfield_ptr, corner_ptr, user_ctx) \
57 ( (blockSize) == 1 ? \
58 InterpolateFieldFromCenterToCorner_Scalar((PetscReal***)(centfield_ptr), (PetscReal***)(corner_ptr), (user_ctx)) : \
59 InterpolateFieldFromCenterToCorner_Vector((Cmpnts***)(centfield_ptr), (Cmpnts***)(corner_ptr), (user_ctx)) \
79#define InterpolateCornerToFaceCenter(corner_arr, faceX_arr, faceY_arr, faceZ_arr, user_ctx) \
80 _Generic((corner_arr), \
81 PetscReal***: InterpolateCornerToFaceCenter_Scalar, \
82 Cmpnts***: InterpolateCornerToFaceCenter_Vector \
83 )(corner_arr, faceX_arr, faceY_arr, faceZ_arr, user_ctx)
100#define TrilinearInterpolation(fieldPtr, i, j, k, a1, a2, a3, outPtr) \
101 _Generic((fieldPtr), \
102 PetscReal ***: TrilinearInterpolation_Scalar, \
103 Cmpnts ***: TrilinearInterpolation_Vector \
104 )(fieldPtr, i, j, k, a1, a2, a3, outPtr)
124 PetscReal ***fieldScal,
235 PetscReal ***field_arr,
236 PetscReal ***centfield_arr,
313 PetscReal ***centfield_arr,
314 PetscReal ***corner_arr,
338 DM gridSumDM, Vec gridSumVec);
358 DM dataDM, Vec sumVec, Vec avgVec);
383 Vec countVec, PetscBool recount, Vec meanVec);
405 Vec eulerFieldAverageVec);
443 PetscReal ***corner_arr,
444 PetscReal ***faceX_arr,
445 PetscReal ***faceY_arr,
446 PetscReal ***faceZ_arr,
Header file for Particle Swarm management functions.
Public interface for grid, solver, and metric setup routines.
PetscErrorCode AccumulateParticleField(DM swarm, ParticleFieldId particle_field_id, DM gridSumDM, Vec gridSumVec)
Accumulates a particle field (scalar or vector) into a target grid sum vector.
PetscErrorCode NormalizeGridVectorByCount(DM countDM, Vec countVec, DM dataDM, Vec sumVec, Vec avgVec)
Normalizes a grid vector of sums by a grid vector of counts to produce an average.
PetscErrorCode ScatterParticleFieldToEulerField(UserCtx *user, ParticleFieldId particle_field_id, Vec eulerFieldAverageVec)
Scatters a particle field (scalar or vector) to the corresponding Eulerian field average.
PetscErrorCode ScatterAllParticleFieldsToEulerFields(UserCtx *user)
Scatters a predefined set of particle fields to their corresponding Eulerian fields.
PetscErrorCode ScatterParticleFieldCellMean(UserCtx *user, ParticleFieldId particle_field_id, DM dataDM, Vec countVec, PetscBool recount, Vec meanVec)
Cell mean of a particle field: the field summed over each cell's particles, divided by the cell's cou...
The arrays one method's point evaluation reads.
PetscErrorCode TrilinearInterpolation_Vector(Cmpnts ***fieldVec, PetscInt i, PetscInt j, PetscInt k, PetscReal a1, PetscReal a2, PetscReal a3, Cmpnts *vec)
Trilinear interpolation of a vector from the eight entries (i..i+1, j..j+1, k..k+1).
PetscErrorCode InterpolateFieldFromCornerToCenter_Vector(Cmpnts ***field_arr, Cmpnts ***centfield_arr, UserCtx *user)
Safely interpolate a vector field from corner nodes (from the coordinate DM) to cell centers (from th...
PetscErrorCode InterpolateCornerToFaceCenter_Vector(Cmpnts ***corner_arr, Cmpnts ***faceX_arr, Cmpnts ***faceY_arr, Cmpnts ***faceZ_arr, UserCtx *user)
Interpolates a vector field from corner nodes to all face centers.
PetscErrorCode InterpolateFieldFromCornerToCenter_Scalar(PetscReal ***field_arr, PetscReal ***centfield_arr, UserCtx *user)
Safely interpolate a scalar field from corner nodes (from the coordinate DM) to cell centers (from th...
PetscErrorCode InterpolateAllFieldsToSwarm(UserCtx *user)
Interpolates the Eulerian fields the particles carry to every local particle.
PetscErrorCode InterpolateVelocityAtPoint(const VelocityPointInterpolator *interp, const PetscInt cell[3], const PetscReal weights[3], Cmpnts point, Cmpnts *u)
The velocity a particle at a point would be given: the value the swarm pass of the configured method ...
PetscErrorCode InterpolateVelocityAtPointEnd(VelocityPointInterpolator **interp)
Closes the arrays InterpolateVelocityAtPointBegin() opened.
PetscErrorCode TestCornerToCenterInterpolation(UserCtx *user)
Tests the InterpolateFieldFromCornerToCenter function by reproducing the Cent vector.
PetscErrorCode TrilinearInterpolation_Scalar(PetscReal ***fieldScal, PetscInt i, PetscInt j, PetscInt k, PetscReal a1, PetscReal a2, PetscReal a3, PetscReal *val)
Trilinear interpolation of a scalar from the eight entries (i..i+1, j..j+1, k..k+1).
PetscErrorCode InterpolateFieldFromCenterToCorner_Vector(Cmpnts ***centfield_arr, Cmpnts ***corner_arr, UserCtx *user)
Interpolates a vector field from cell centers to corner nodes.
PetscErrorCode InterpolateVelocityAtPointBegin(UserCtx *user, VelocityPointInterpolator **interp)
Opens the arrays for evaluating the particle velocity at points, with the configured interpolation me...
PetscErrorCode InterpolateCornerToFaceCenter_Scalar(PetscReal ***corner_arr, PetscReal ***faceX_arr, PetscReal ***faceY_arr, PetscReal ***faceZ_arr, UserCtx *user)
Interpolates a scalar field from corner nodes to all face centers.
PetscErrorCode InterpolateFieldFromCenterToCorner_Scalar(PetscReal ***centfield_arr, PetscReal ***corner_arr, UserCtx *user)
Interpolates a scalar field from cell centers to corner nodes.
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
ParticleFieldId
Compile-time identity for a persistent solver-particle field.
Main header file for a complex fluid dynamics solver.
A 3D point or vector with PetscScalar components.
User-defined context containing data specific to a single computational grid level.
Header file for particle location functions using the walking search algorithm.