PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
|
#include <petscpf.h>
#include <petscdmswarm.h>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <petsctime.h>
#include <petscdmcomposite.h>
#include "variables.h"
#include "ParticleSwarm.h"
#include "walkingsearch.h"
#include "grid.h"
#include "logging.h"
#include "io.h"
#include "setup.h"
#include "interpolation.h"
Go to the source code of this file.
Macros | |
#define | SetLocalCartesianField(fieldName, fieldValue, coor, FieldInitialization, Constant) |
Generic macro to select the appropriate local Cartesian field setter based on field type. | |
Functions | |
PetscErrorCode | SetLocalCartesianField_Scalar (const char *fieldName, PetscReal *scalarField, Cmpnts *coor, PetscInt FieldInitialization, PetscReal Constant) |
Sets the local Cartesian scalar field based on input coordinates. | |
PetscErrorCode | SetLocalCartesianField_Vector (const char *fieldName, Cmpnts *vecField, Cmpnts *coor, PetscInt FieldInitialization, PetscReal Constant) |
Sets the local Cartesian vector field based on input coordinates. | |
PetscErrorCode | SetAnalyticalCartesianField (UserCtx *user, const char *fieldName) |
Sets an analytical Cartesian field (scalar or vector) for cell centers based on a field name. | |
PetscErrorCode | SetAnalyticalContravariantField (UserCtx *user, const char *fieldName) |
Sets an analytical contravariant field (Ucont) at nodes, where each component is evaluated using the physical coordinates of its respective face center. | |
PetscErrorCode | SetAnalyticalSolution (Vec tempVec, PetscInt FieldInitialization) |
Applies the analytical solution to the position vector. | |
PetscErrorCode | ApplyAnalyticalBC (UserCtx *user, const char *fieldName) |
Applies analytical boundary conditions to a specified global vector or scalar field. | |
PetscErrorCode | SetInitialInteriorField (UserCtx *user, const char *fieldName) |
Sets the initial values for the INTERIOR of a specified Eulerian field. | |
#define SetLocalCartesianField | ( | fieldName, | |
fieldValue, | |||
coor, | |||
FieldInitialization, | |||
Constant | |||
) |
Generic macro to select the appropriate local Cartesian field setter based on field type.
This macro dispatches to:
fieldName | Field name for logging. |
fieldValue | Pointer to the cell's field value (either Cmpnts* or PetscReal*). |
coor | Pointer to the coordinate (Cmpnts*) to be used in the computation. |
Definition at line 33 of file AnalyticalSolution.h.
PetscErrorCode SetLocalCartesianField_Scalar | ( | const char * | fieldName, |
PetscReal * | scalarField, | ||
Cmpnts * | coor, | ||
PetscInt | FieldInitialization, | ||
PetscReal | Constant | ||
) |
Sets the local Cartesian scalar field based on input coordinates.
This function computes the scalar field value by combining the sine of the input coordinate values. In this example, the scalar field is computed as the sum of the sine functions of the x, y, and z coordinates.
[in] | fieldName | Pointer to a string representing the field name (for logging purposes). |
[in,out] | scalarField | Pointer to the PetscReal where the computed scalar field value will be stored. |
[in] | coor | Pointer to the Cmpnts structure containing the input coordinate values. |
PetscErrorCode SetLocalCartesianField_Vector | ( | const char * | fieldName, |
Cmpnts * | vecField, | ||
Cmpnts * | coor, | ||
PetscInt | FieldInitialization, | ||
PetscReal | Constant | ||
) |
Sets the local Cartesian vector field based on input coordinates.
This function computes the vector components by applying the sine function to the input coordinate values along the x, y, and z directions.
[in] | fieldName | Pointer to a string representing the field name (for logging purposes). |
[in,out] | vecField | Pointer to the Cmpnts structure where the computed vector field will be stored. |
[in] | coor | Pointer to the Cmpnts structure containing the input coordinate values. |
PetscErrorCode SetAnalyticalCartesianField | ( | UserCtx * | user, |
const char * | fieldName | ||
) |
Sets an analytical Cartesian field (scalar or vector) for cell centers based on a field name.
This function looks up the field within the user context by comparing the provided field name against the supported names:
If the field is found, the function verifies that the DM block size matches the expected value (3 for vector fields and 1 for scalar fields), retrieves local DM information for both the coordinate DM (da) and the cell-centered DM (fda), interpolates the corner-based coordinates (from da) to cell centers, and then updates the field using the generic helper macro SetLocalCartesianField. Interior cells are updated with the interpolated coordinates, and boundary cells are updated using the original coordinate data.
If the field name is not found in the user context, the function throws an error.
[in] | user | Pointer to the UserCtx structure containing: |
[in] | fieldName | Name of the field to update. |
PetscErrorCode SetAnalyticalContravariantField | ( | UserCtx * | user, |
const char * | fieldName | ||
) |
Sets an analytical contravariant field (Ucont) at nodes, where each component is evaluated using the physical coordinates of its respective face center.
This function:
[in] | user | Pointer to the UserCtx structure. |
[in] | fieldName | Name of the field to update (currently only "Ucont"). |
PetscErrorCode SetAnalyticalSolution | ( | Vec | tempVec, |
PetscInt | FieldInitialization | ||
) |
Applies the analytical solution to the position vector.
This function updates each entry in the provided PETSc vector by computing its sine, thereby replacing each position with sin(position).
tempVec | The PETSc Vec containing particle positions which will be used to store the velocities. |
PetscErrorCode ApplyAnalyticalBC | ( | UserCtx * | user, |
const char * | fieldName | ||
) |
Applies analytical boundary conditions to a specified global vector or scalar field.
This function acts as a dispatcher based on the fieldName. It determines the appropriate DM and Vec from the UserCtx and calls field-specific helper routines (e.g., ApplyAnalyticalBC_Vector, ApplyAnalyticalBC_Scalar) to set boundary values according to a predefined analytical function (e.g., sin(coord)).
This should be called AFTER setting interior values and BEFORE updating local ghosts.
[in] | user | Pointer to the UserCtx containing DMs, coordinates, and field Vecs. |
[in] | fieldName | Name of the field to apply BCs to ("Ucat", "Ucont", "P", "Nvert"). |
PetscErrorCode SetInitialInteriorField | ( | UserCtx * | user, |
const char * | fieldName | ||
) |
Sets the initial values for the INTERIOR of a specified Eulerian field.
This function initializes the interior nodes of Ucont
based on a profile selected by user->FieldInitialization
. It explicitly skips any node that lies on a global boundary, as those values are set by the Boundary System's Initialize
methods.
The initialization is directional, aligned with the primary INLET face that was identified by the parser. This ensures the initial flow is physically meaningful.
Supported user->FieldInitialization
profiles for "Ucont":
uin
. Other contravariant components are zero.user | The main UserCtx struct, containing all simulation data and configuration. |
fieldName | A string ("Ucont" or "P") identifying which field to initialize. |
Definition at line 30 of file initialcondition.c.