11#ifndef PICURV_EXPRESSION_H
12#define PICURV_EXPRESSION_H
61 PetscInt64 pid, PetscInt64 salt);
196 const PetscReal local[3],
const char *where, PetscReal *factor);
276 PetscReal physical_time);
290 PetscReal physical_time, PetscReal *factor);
306 PetscReal physical_time, PetscReal factor, PetscBool boundary_faces);
PetscErrorCode PicurvExpressionEvaluate(const PicurvExpression *expression, const PetscReal *values, const PicurvExpressionDrawKey *key, PetscReal *result)
Evaluate a compiled expression.
uint64_t PicurvMix64(uint64_t z)
splitmix64 finalizer: a bijective mix of 64 bits.
PicurvExpression * bulk
Target mean speed [m/s] in t, or NULL.
PetscErrorCode PicurvExpressionDestroy(PicurvExpression **expression)
Free a compiled expression.
PetscErrorCode PicurvSourceSetCellPressure(UserCtx *user, const PicurvExpression *pressure, Vec fraction, Vec length, PetscReal physical_time)
Set a block's pressure at every interior cell centre from an expression in Pa.
PetscErrorCode PicurvVelocitySourceCreate(const char *prefix, PetscBool on_face, PetscBool has_data, PicurvVelocitySource *source)
Read and compile a velocity source from the options database.
PetscBool bulk_time_dependent
PetscInt normal
Logical axis of the face normal.
PetscInt64 pid
Particle identity; draws are pure functions of it.
PetscErrorCode PicurvSourceAddFluxes(UserCtx *user, const PicurvVelocitySource *source, Vec fraction, Vec length, PetscReal physical_time, PetscReal factor, PetscBool boundary_faces)
Add a source's flux to every owned face of Ucont, evaluating it at each face centre.
PicurvDrawSpace
Disjoint key spaces of the keyed particle draws, so draws made for different purposes never coincide ...
@ PICURV_DRAW_SPACE_FIELD
An expression's default, per-field stream.
@ PICURV_DRAW_SPACE_BROWNIAN
Brownian increments; the salt is the step.
@ PICURV_DRAW_SPACE_INLET
Injection at an inlet: stream 0 counts per face cell, stream 1 distance in.
@ PICURV_DRAW_SPACE_NAMED_STREAM
uniform(k)/normal(k): a stream shared across fields.
@ PICURV_DRAW_SPACE_PLACEMENT
Seeding points; the salt is the rejection attempt.
PetscErrorCode PicurvSourceCellBulkFactor(UserCtx *user, const PicurvVelocitySource *source, Vec fraction, Vec length, PetscReal physical_time, PetscReal *factor)
Factor on a source's expressions that makes the volume mean of the whole field, along the source's ow...
PicurvSourceVariable
Variables a prescribed velocity source may use, in the order of values[].
@ PICURV_SOURCE_VAR_L_XI
Physical length of that xi grid line [m].
@ PICURV_SOURCE_VAR_L_ZETA
Physical length of that zeta grid line [m].
@ PICURV_SOURCE_VAR_XI
Arc-length fraction along the xi grid line, 0 at the - face.
@ PICURV_SOURCE_VAR_T
Physical time [s].
@ PICURV_SOURCE_VAR_R
On a face, distance from the face's centre [m].
@ PICURV_SOURCE_VAR_ZETA
Arc-length fraction along the zeta grid line.
@ PICURV_SOURCE_VAR_Y
Physical y [m].
@ PICURV_SOURCE_VAR_X
Physical x of the point [m].
@ PICURV_SOURCE_VAR_L_ETA
Physical length of that eta grid line [m].
@ PICURV_SOURCE_VAR_ETA
Arc-length fraction along the eta grid line.
@ PICURV_SOURCE_VAR_COUNT
@ PICURV_SOURCE_VAR_CELL_COUNT
Variables a source reads on every target.
@ PICURV_SOURCE_VAR_Z
Physical z [m].
PetscErrorCode PicurvExpressionUsesVariable(const PicurvExpression *expression, PetscInt index, PetscBool *uses)
Whether a compiled expression reads one of its variables.
PetscErrorCode PicurvVelocitySourceDestroy(PicurvVelocitySource *source)
Free a source's compiled expressions and bulk velocity.
PetscInt layer
Index along the normal of the face's metric and flux.
const char *const kPicurvSourceVariableNames[PICURV_SOURCE_VAR_COUNT]
Names of PicurvSourceVariable, in order.
PetscErrorCode PicurvVelocitySourceBulkFactor(const PicurvVelocitySource *source, PetscReal physical_time, const PetscReal local[3], const char *where, PetscReal *factor)
Factor on a source's expressions that makes a target's whole mean equal its bulk velocity.
PetscBool time_dependent
Some component reads t.
PetscReal PicurvUnitFromHash(uint64_t hash)
Uniform on [0, 1) from the top 53 bits of a hash.
PetscErrorCode PicurvVelocitySourceEvaluate(const PicurvVelocitySource *source, const PetscReal *values, const Cmpnts edges[3], Cmpnts *value)
Evaluate a source at one point.
PetscErrorCode PicurvSourceFaceSlotsCreate(UserCtx *user, BCFace face_id, Vec fraction, Vec length, PicurvSourceFaceSlots *slots)
Gather each owned slot of a boundary face: face-centre position, the grid-line fractions and lengths ...
PetscErrorCode PicurvExpressionCompile(const char *text, const char *const *names, PetscInt name_count, PetscBool allow_random, PicurvExpression **expression)
Compile one expression against a list of variable names.
uint64_t PicurvParticleDrawHash(PetscInt64 seed, PicurvDrawSpace space, uint64_t stream, PetscInt64 pid, PetscInt64 salt)
Hash that keys a particle draw: a pure function of its arguments, so a draw does not depend on the ra...
PetscInt64 salt
Event that produced the particle: 0 for the t=0 population.
PetscInt64 field
Field whose expression draws, the default stream's namespace.
static void PicurvSourceSetVariables(PetscReal *values, Cmpnts point, Cmpnts fraction, Cmpnts length, PetscReal L_ref)
Fill a source's position and grid-line variables at one point.
PetscErrorCode PicurvSourceFaceSlotsDestroy(PicurvSourceFaceSlots *slots)
Release what PicurvSourceFaceSlotsCreate() allocated.
PetscBool bulk_is_flow_rate
bulk is a volumetric flow rate [m^3/s] through a face instead.
PicurvSourceFrame
How a source's values are read.
@ PICURV_SOURCE_FRAME_NORMAL
One value: the speed into the domain through a face.
@ PICURV_SOURCE_FRAME_CONTRAVARIANT
Three values: the volume flux through the xi, eta, zeta faces; cells only.
@ PICURV_SOURCE_FRAME_CARTESIAN
Three values: x, y, z velocity components.
@ PICURV_SOURCE_FRAME_CURVILINEAR
Three values along the unit xi, eta, zeta grid-line directions.
PetscInt64 seed
Run seed (-particle_random_seed).
PetscInt count
1 for the normal frame, otherwise 3; 0 for staged data alone.
What a random draw is keyed on, besides the particle and its stream.
What a source reads at each boundary-face slot this rank owns, gathered once.
A prescribed velocity, for any target: one compiled expression per value, the frame they are in,...
Main header file for a complex fluid dynamics solver.
BCFace
Identifies the six logical faces of a structured computational block.
A 3D point or vector with PetscScalar components.
User-defined context containing data specific to a single computational grid level.