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) )
64#define InterpolateFieldFromCenterToCorner(blockSize, centfield_ptr, corner_ptr, user_ctx) \
65 ( (blockSize) == 1 ? \
66 InterpolateFieldFromCenterToCorner_Scalar_Petsc((PetscReal***)(centfield_ptr), (PetscReal***)(corner_ptr), (user_ctx)) : \
67 InterpolateFieldFromCenterToCorner_Vector_Petsc((Cmpnts***)(centfield_ptr), (Cmpnts***)(corner_ptr), (user_ctx)) \
87#define InterpolateCornerToFaceCenter(corner_arr, faceX_arr, faceY_arr, faceZ_arr, user_ctx) \
88 _Generic((corner_arr), \
89 PetscReal***: InterpolateCornerToFaceCenter_Scalar, \
90 Cmpnts***: InterpolateCornerToFaceCenter_Vector \
91 )(corner_arr, faceX_arr, faceY_arr, faceZ_arr, user_ctx)
109#define PieceWiseLinearInterpolation(fieldName, fieldPtr, i, j, k, outPtr) \
110 _Generic((fieldPtr), \
111 PetscReal ***: PieceWiseLinearInterpolation_Scalar, \
112 Cmpnts ***: PieceWiseLinearInterpolation_Vector \
113 )(fieldName, fieldPtr, i, j, k, outPtr)
130#define TrilinearInterpolation(fieldName, fieldPtr, i, j, k, a1, a2, a3, outPtr) \
131 _Generic((fieldPtr), \
132 PetscReal ***: TrilinearInterpolation_Scalar, \
133 Cmpnts ***: TrilinearInterpolation_Vector \
134 )(fieldName, fieldPtr, i, j, k, a1, a2, a3, outPtr)
152 const char *fieldName,
153 PetscReal ***fieldScal,
176 const char *fieldName,
218 Vec fieldLocal_cellCentered,
219 const char *fieldName,
220 const char *swarmOutFieldName);
274 PetscReal ***centfield,
319 PetscReal ***centfield_arr,
378 PetscReal ***centfield_arr,
379 PetscReal ***corner_arr,
398 DM *targetDM, PetscInt *expected_dof);
422 DM gridSumDM, Vec gridSumVec);
442 DM dataDM, Vec sumVec, Vec avgVec);
463 const char *particleFieldName,
464 Vec eulerFieldAverageVec);
502 PetscReal ***corner_arr,
503 PetscReal ***faceX_arr,
504 PetscReal ***faceY_arr,
505 PetscReal ***faceZ_arr,
Header file for Particle Motion and migration related functions.
Public interface for grid, solver, and metric setup routines.
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 AccumulateParticleField(DM swarm, const char *particleFieldName, DM gridSumDM, Vec gridSumVec)
Accumulates a particle field (scalar or vector) into a target grid sum vector.
PetscErrorCode GetScatterTargetInfo(UserCtx *user, const char *particleFieldName, DM *targetDM, PetscInt *expected_dof)
Determines the target Eulerian DM and expected DOF for scattering a given particle field.
PetscErrorCode ScatterAllParticleFieldsToEulerFields(UserCtx *user)
Scatters a predefined set of particle fields to their corresponding Eulerian fields.
PetscErrorCode ScatterParticleFieldToEulerField(UserCtx *user, const char *particleFieldName, Vec eulerFieldAverageVec)
Scatters a particle field (scalar or vector) to the corresponding Eulerian field average.
PetscErrorCode InterpolateFieldFromCenterToCorner_Vector(Cmpnts ***field_arr, Cmpnts ***centfield_arr, UserCtx *user)
Interpolates a vector field from cell centers to corner nodes.
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 InterpolateAllFieldsToSwarm(UserCtx *user)
Interpolates all relevant fields from the DMDA to the DMSwarm.
PetscErrorCode InterpolateFieldFromCenterToCorner_Scalar(PetscReal ***field_arr, PetscReal ***centfield_arr, UserCtx *user)
Interpolates a scalar field from cell centers to corner nodes.
PetscErrorCode TrilinearInterpolation_Vector(const char *fieldName, Cmpnts ***fieldVec, PetscInt i, PetscInt j, PetscInt k, PetscReal a1, PetscReal a2, PetscReal a3, Cmpnts *vec)
Computes the trilinear interpolated vector (e.g., velocity) at a given point.
PetscErrorCode InterpolateFieldFromCenterToCorner_Vector_Petsc(Cmpnts ***centfield_arr, Cmpnts ***corner_arr, UserCtx *user)
Interpolates a vector field from cell centers to corner nodes.
PetscErrorCode InterpolateParticleVelocities(UserCtx *user)
Interpolates particle velocities using trilinear interpolation.
PetscErrorCode TrilinearInterpolation_Scalar(const char *fieldName, PetscReal ***fieldScal, PetscInt i, PetscInt j, PetscInt k, PetscReal a1, PetscReal a2, PetscReal a3, PetscReal *val)
Computes the trilinear interpolated scalar at a given point.
PetscErrorCode InterpolateFieldFromCornerToCenter_Vector(Cmpnts ***field, Cmpnts ***centfield, UserCtx *user)
Safely interpolate a vector field from corner nodes (from the coordinate DM) to cell centers (from th...
PetscErrorCode InterpolateFieldFromCornerToCenter_Scalar(PetscReal ***field, PetscReal ***centfield, UserCtx *user)
Safely interpolate a scalar field from corner nodes (from the coordinate DM) to cell centers (from th...
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 InterpolateEulerFieldToSwarm(UserCtx *user, Vec fieldLocal_cellCentered, const char *fieldName, const char *swarmOutFieldName)
Interpolates a cell-centered field (scalar or vector) onto DMSwarm particles, using a robust,...
PetscErrorCode InterpolateFieldFromCenterToCorner_Scalar_Petsc(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.
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.