PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
Loading...
Searching...
No Matches
Functions
BC_Handlers.h File Reference
#include "variables.h"
#include "logging.h"
Include dependency graph for BC_Handlers.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

PetscErrorCode Validate_DrivenFlowConfiguration (UserCtx *user)
 (Private) Validates all consistency rules for a driven flow (channel/pipe) setup.
 
PetscErrorCode Create_WallNoSlip (BoundaryCondition *bc)
 Configures a BoundaryCondition object to behave as a no-slip, stationary wall.
 
PetscErrorCode Create_InletConstantVelocity (BoundaryCondition *bc)
 Configures a BoundaryCondition object to behave as a constant velocity inlet.
 
PetscErrorCode Create_InletParabolicProfile (BoundaryCondition *bc)
 Configures a BoundaryCondition object for a parabolic inlet profile.
 
PetscErrorCode Create_InletProfileFromFile (BoundaryCondition *bc)
 Configures a BoundaryCondition object for a file-prescribed inlet profile.
 
PetscErrorCode Create_OutletConservation (BoundaryCondition *bc)
 Configures a BoundaryCondition object for conservative outlet treatment.
 
PetscErrorCode Create_PeriodicGeometric (BoundaryCondition *bc)
 Configures a BoundaryCondition object for geometric periodic coupling.
 
PetscErrorCode Create_PeriodicDrivenConstant (BoundaryCondition *bc)
 Configures a BoundaryCondition object for periodic driven-flow forcing.
 
PetscErrorCode Create_PeriodicDrivenInitial (BoundaryCondition *bc)
 Configures a BoundaryCondition object for initial-flux periodic driving.
 

Function Documentation

◆ Validate_DrivenFlowConfiguration()

PetscErrorCode Validate_DrivenFlowConfiguration ( UserCtx user)

(Private) Validates all consistency rules for a driven flow (channel/pipe) setup.

This function enforces a strict set of rules to ensure a driven flow simulation is configured correctly. It is called by the main BoundarySystem_Validate dispatcher.

The validation rules are checked in a specific order:

  1. Detect if any DRIVEN_ handler is active. If not, the function returns immediately.
  2. Ensure that no INLET, OUTLET, or FARFIELD boundary conditions exist anywhere in the domain, as they are physically incompatible with a pressure-driven flow model.
  3. Verify that both faces in the driven direction are of mathematical_type PERIODIC.
  4. Verify that both faces in the driven direction use the exact same DRIVEN_ handler type.
Parameters
userThe UserCtx for a single block.
Returns
PetscErrorCode 0 on success, non-zero PETSc error code on failure.

(Private) Validates all consistency rules for a driven flow (channel/pipe) setup.

Local to this translation unit.

Definition at line 15 of file BC_Handlers.c.

16{
17 PetscFunctionBeginUser;
18
19 // --- CHECK 1: Detect if a driven flow is active. ---
20 PetscBool is_driven_flow_active = PETSC_FALSE;
21 char driven_direction = ' ';
22 const char* first_driven_face_name = "";
23
24 for (int i = 0; i < 6; i++) {
25 BCHandlerType handler_type = user->boundary_faces[i].handler_type;
26 if (handler_type == BC_HANDLER_PERIODIC_DRIVEN_CONSTANT_FLUX ||
28 {
29 is_driven_flow_active = PETSC_TRUE;
30 first_driven_face_name = BCFaceToString((BCFace)i);
31
32 if (i <= 1) driven_direction = 'X';
33 else if (i <= 3) driven_direction = 'Y';
34 else driven_direction = 'Z';
35
36 break; // Exit loop once we've confirmed it's active and found the direction.
37 }
38 }
39
40 // If no driven flow handler is found, validation for this rule set is complete.
41 if (!is_driven_flow_active) {
42 PetscFunctionReturn(0);
43 }
44
45 LOG_ALLOW(GLOBAL, LOG_DEBUG, " - Driven Flow Handler detected on face %s. Applying driven flow validation rules...\n", first_driven_face_name);
46
47 // --- CHECK 2: Ensure no conflicting BCs (Inlet/Outlet/Far-field) are present. ---
48 LOG_ALLOW(GLOBAL, LOG_DEBUG, " - Checking for incompatible Inlet/Outlet/Far-field BCs...\n");
49 for (int i = 0; i < 6; i++) {
50 BCType math_type = user->boundary_faces[i].mathematical_type;
51 if (math_type == INLET || math_type == OUTLET || math_type == FARFIELD) {
52 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_USER_INPUT,
53 "Configuration Error: A DRIVEN flow handler is active, which is incompatible with the %s boundary condition found on face %s.",
54 BCTypeToString(math_type), BCFaceToString((BCFace)i));
55 }
56 }
57 LOG_ALLOW(GLOBAL, LOG_DEBUG, " ... No conflicting BC types found. OK.\n");
58
59 // --- CHECK 3: Ensure both ends of the driven direction have identical, valid setups. ---
60 LOG_ALLOW(GLOBAL, LOG_DEBUG, " - Validating symmetry and mathematical types for the '%c' direction...\n", driven_direction);
61
62 PetscInt neg_face_idx = 0, pos_face_idx = 0;
63 if (driven_direction == 'X') {
64 neg_face_idx = BC_FACE_NEG_X; pos_face_idx = BC_FACE_POS_X;
65 } else if (driven_direction == 'Y') {
66 neg_face_idx = BC_FACE_NEG_Y; pos_face_idx = BC_FACE_POS_Y;
67 } else { // 'Z'
68 neg_face_idx = BC_FACE_NEG_Z; pos_face_idx = BC_FACE_POS_Z;
69 }
70
71 BoundaryFaceConfig *neg_face_cfg = &user->boundary_faces[neg_face_idx];
72 BoundaryFaceConfig *pos_face_cfg = &user->boundary_faces[pos_face_idx];
73
74 // Rule 3a: Both faces must be PERIODIC.
75 if (neg_face_cfg->mathematical_type != PERIODIC || pos_face_cfg->mathematical_type != PERIODIC) {
76 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_USER_INPUT,
77 "Configuration Error: For a driven flow in the '%c' direction, both the %s and %s faces must be of mathematical_type PERIODIC.",
78 driven_direction, BCFaceToString((BCFace)neg_face_idx), BCFaceToString((BCFace)pos_face_idx));
79 }
80
81 // Rule 3b: Both faces must use the exact same handler type.
82 if (neg_face_cfg->handler_type != pos_face_cfg->handler_type) {
83 SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_USER_INPUT,
84 "Configuration Error: The DRIVEN handlers on the %s and %s faces of the '%c' direction do not match. Both must be the same type (e.g., both CONSTANT_FLUX).",
85 BCFaceToString((BCFace)neg_face_idx), BCFaceToString((BCFace)pos_face_idx), driven_direction);
86 }
87
88 LOG_ALLOW(GLOBAL, LOG_DEBUG, " ... Symmetry and mathematical types are valid. OK.\n");
89
90 PetscFunctionReturn(0);
91}
#define GLOBAL
Scope for global logging across all processes.
Definition logging.h:46
const char * BCFaceToString(BCFace face)
Returns the canonical log token for a boundary-face enum value.
Definition logging.c:671
#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:200
const char * BCTypeToString(BCType type)
Returns the canonical log token for a boundary mathematical type.
Definition logging.c:773
@ LOG_DEBUG
Detailed debugging information.
Definition logging.h:32
BCType
Defines the general mathematical/physical Category of a boundary.
Definition variables.h:283
@ INLET
Definition variables.h:290
@ FARFIELD
Definition variables.h:291
@ OUTLET
Definition variables.h:289
@ PERIODIC
Definition variables.h:292
BoundaryFaceConfig boundary_faces[6]
Definition variables.h:931
BCHandlerType
Defines the specific computational "strategy" for a boundary handler.
Definition variables.h:303
@ BC_HANDLER_PERIODIC_DRIVEN_INITIAL_FLUX
Definition variables.h:319
@ BC_HANDLER_PERIODIC_DRIVEN_CONSTANT_FLUX
Definition variables.h:318
BCHandlerType handler_type
Definition variables.h:369
BCType mathematical_type
Definition variables.h:368
BCFace
Identifies the six logical faces of a structured computational block.
Definition variables.h:261
@ BC_FACE_NEG_X
Definition variables.h:262
@ BC_FACE_POS_Z
Definition variables.h:264
@ BC_FACE_POS_Y
Definition variables.h:263
@ BC_FACE_NEG_Z
Definition variables.h:264
@ BC_FACE_POS_X
Definition variables.h:262
@ BC_FACE_NEG_Y
Definition variables.h:263
Holds the complete configuration for one of the six boundary faces.
Definition variables.h:366
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_WallNoSlip()

PetscErrorCode Create_WallNoSlip ( BoundaryCondition bc)

Configures a BoundaryCondition object to behave as a no-slip, stationary wall.

Parameters
[in,out]bcBoundary object whose callbacks and handler metadata are installed.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object to behave as a no-slip, stationary wall.

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

See also
Create_WallNoSlip()

Definition at line 114 of file BC_Handlers.c.

115{
116 PetscFunctionBeginUser;
117
118 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL,
119 "Input BoundaryCondition object is NULL in Create_WallNoSlip");
120
121 // ✅ Set priority
123
124 // Assign function pointers
125 bc->Initialize = NULL;
126 bc->PreStep = NULL;
128 bc->PostStep = NULL;
129 bc->UpdateUbcs = NULL;
130 bc->Destroy = NULL;
131
132 // No private data needed for this simple handler
133 bc->data = NULL;
134
135 PetscFunctionReturn(0);
136}
static PetscErrorCode Apply_WallNoSlip(BoundaryCondition *self, BCContext *ctx)
Apply no-slip velocity values to wall-adjacent cells for this boundary condition.
PetscErrorCode(* PostStep)(BoundaryCondition *self, BCContext *ctx, PetscReal *local_inflow, PetscReal *local_outflow)
Definition variables.h:360
PetscErrorCode(* PreStep)(BoundaryCondition *self, BCContext *ctx, PetscReal *local_inflow, PetscReal *local_outflow)
Definition variables.h:358
PetscErrorCode(* Destroy)(BoundaryCondition *self)
Definition variables.h:362
PetscErrorCode(* Initialize)(BoundaryCondition *self, BCContext *ctx)
Definition variables.h:357
PetscErrorCode(* UpdateUbcs)(BoundaryCondition *self, BCContext *ctx)
Definition variables.h:361
PetscErrorCode(* Apply)(BoundaryCondition *self, BCContext *ctx)
Definition variables.h:359
BCPriorityType priority
Definition variables.h:355
@ BC_PRIORITY_WALL
Definition variables.h:327
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_InletConstantVelocity()

PetscErrorCode Create_InletConstantVelocity ( BoundaryCondition bc)

Configures a BoundaryCondition object to behave as a constant velocity inlet.

Parameters
[in,out]bcBoundary object configured with the constant-velocity inlet callbacks.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object to behave as a constant velocity inlet.

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

See also
Create_InletConstantVelocity()

Definition at line 322 of file BC_Handlers.c.

323{
324 PetscErrorCode ierr;
325 PetscFunctionBeginUser;
326
327 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "BoundaryCondition is NULL");
328
329 InletConstantData *data = NULL;
330 ierr = PetscMalloc1(1, &data); CHKERRQ(ierr);
331 bc->data = (void*)data;
332
338 bc->UpdateUbcs = NULL;
340
341 PetscFunctionReturn(0);
342}
static PetscErrorCode PreStep_InletConstantVelocity(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Update constant-inlet data required before the next solver step.
static PetscErrorCode Apply_InletConstantVelocity(BoundaryCondition *self, BCContext *ctx)
Impose the configured constant velocity on inlet boundary cells.
static PetscErrorCode Destroy_InletConstantVelocity(BoundaryCondition *self)
Release resources owned by a constant-velocity inlet boundary.
static PetscErrorCode Initialize_InletConstantVelocity(BoundaryCondition *self, BCContext *ctx)
Initialize persistent state for a constant-velocity inlet boundary.
static PetscErrorCode PostStep_InletConstantVelocity(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Perform post-step bookkeeping for a constant-velocity inlet boundary.
Private data structure for the Constant Velocity Inlet handler.
@ BC_PRIORITY_INLET
Definition variables.h:325
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_InletParabolicProfile()

PetscErrorCode Create_InletParabolicProfile ( BoundaryCondition bc)

Configures a BoundaryCondition object for a parabolic inlet profile.

The constructed handler computes inlet velocity as a profile function of transverse coordinates, typically used for laminar channel/pipe initialization.

Parameters
bcA pointer to the generic BoundaryCondition object to be configured.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object for a parabolic inlet profile.

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

See also
Create_InletParabolicProfile()

Definition at line 715 of file BC_Handlers.c.

716{
717 PetscErrorCode ierr;
718 PetscFunctionBeginUser;
719
720 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "BoundaryCondition is NULL");
721
722 InletParabolicData *data = NULL;
723 ierr = PetscMalloc1(1, &data); CHKERRQ(ierr);
724 bc->data = (void*)data;
725
731 bc->UpdateUbcs = NULL;
733
734 PetscFunctionReturn(0);
735}
static PetscErrorCode Initialize_InletParabolicProfile(BoundaryCondition *self, BCContext *ctx)
Initialize the geometric data used to evaluate a parabolic inlet profile.
static PetscErrorCode Apply_InletParabolicProfile(BoundaryCondition *self, BCContext *ctx)
Impose the evaluated parabolic velocity profile on inlet cells.
static PetscErrorCode PostStep_InletParabolicProfile(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Perform post-step bookkeeping for a parabolic inlet boundary.
static PetscErrorCode PreStep_InletParabolicProfile(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Refresh parabolic-inlet values required before the solver step.
static PetscErrorCode Destroy_InletParabolicProfile(BoundaryCondition *self)
Release resources owned by a parabolic inlet boundary.
Private data structure for the Parabolic Velocity Inlet handler.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_InletProfileFromFile()

PetscErrorCode Create_InletProfileFromFile ( BoundaryCondition bc)

Configures a BoundaryCondition object for a file-prescribed inlet profile.

The constructed handler reads a canonical PICSLICE scalar normal-speed profile and applies it through the existing inlet metric/sign convention.

Parameters
bcA pointer to the generic BoundaryCondition object to be configured.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object for a file-prescribed inlet profile.

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

See also
Create_InletProfileFromFile()

Definition at line 1292 of file BC_Handlers.c.

1293{
1294 PetscErrorCode ierr;
1295 PetscFunctionBeginUser;
1296
1297 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "BoundaryCondition is NULL");
1298
1299 InletProfileFileData *data = NULL;
1300 ierr = PetscMalloc1(1, &data); CHKERRQ(ierr);
1301 data->n1 = 0;
1302 data->n2 = 0;
1303 data->profile = NULL;
1304 data->min_speed = 0.0;
1305 data->max_speed = 0.0;
1306 data->source_file = NULL;
1307 bc->data = (void*)data;
1308
1314 bc->UpdateUbcs = NULL;
1316
1317 PetscFunctionReturn(0);
1318}
static PetscErrorCode Initialize_InletProfileFromFile(BoundaryCondition *self, BCContext *ctx)
Initializes a file-prescribed inlet profile handler for one boundary face.
static PetscErrorCode Destroy_InletProfileFromFile(BoundaryCondition *self)
Releases private storage owned by a file-prescribed inlet profile handler.
static PetscErrorCode PreStep_InletProfileFromFile(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Pre-step hook for the static file-prescribed inlet profile handler.
static PetscErrorCode PostStep_InletProfileFromFile(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Accumulates the applied inlet flux for a file-prescribed profile.
static PetscErrorCode Apply_InletProfileFromFile(BoundaryCondition *self, BCContext *ctx)
Applies the loaded PICSLICE scalar profile to Ucont and Ubcs on an inlet face.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_OutletConservation()

PetscErrorCode Create_OutletConservation ( BoundaryCondition bc)

Configures a BoundaryCondition object for conservative outlet treatment.

The constructed handler applies outlet updates that preserve the solver's global mass/flux consistency assumptions.

Parameters
bcA pointer to the generic BoundaryCondition object to be configured.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object for conservative outlet treatment.

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

See also
Create_OutletConservation()

Definition at line 1644 of file BC_Handlers.c.

1645{
1646 PetscFunctionBeginUser;
1647
1648 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition is NULL");
1649
1650 // This handler has the highest priority to ensure it runs after
1651 // all inflow fluxes have been calculated.
1653
1654 // Assign function pointers
1655 bc->Initialize = NULL; // No initialization needed
1659 bc->UpdateUbcs = NULL;
1660 bc->Destroy = NULL; // No private data to destroy
1661
1662 bc->data = NULL;
1663
1664 PetscFunctionReturn(0);
1665}
static PetscErrorCode Apply_OutletConservation(BoundaryCondition *self, BCContext *ctx)
(Handler Action) Applies mass conservation correction to the outlet face.
static PetscErrorCode PostStep_OutletConservation(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Update outlet-conservation state after a completed solver step.
static PetscErrorCode PreStep_OutletConservation(BoundaryCondition *self, BCContext *ctx, PetscReal *local_inflow_contribution, PetscReal *local_outflow_contribution)
Prepare the outlet-conservation correction before advancing the solver.
@ BC_PRIORITY_OUTLET
Definition variables.h:328
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_PeriodicGeometric()

PetscErrorCode Create_PeriodicGeometric ( BoundaryCondition bc)

Configures a BoundaryCondition object for geometric periodic coupling.

This constructor wires periodic boundary callbacks that exchange values across opposite faces according to the configured periodic directions.

Parameters
bcA pointer to the generic BoundaryCondition object to be configured.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object for geometric periodic coupling.

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

See also
Create_PeriodicGeometric()

Definition at line 2159 of file BC_Handlers.c.

2159 {
2160 PetscFunctionBeginUser;
2161
2162 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition is NULL");
2164
2165 // Assign function pointers
2166 bc->Initialize = NULL; // No initialization needed
2167 bc->PreStep = NULL;
2168 bc->Apply = NULL;
2169 bc->PostStep = NULL;
2170 bc->UpdateUbcs = NULL;
2171 bc->Destroy = NULL; // No private data to destroy
2172
2173 bc->data = NULL;
2174
2175 PetscFunctionReturn(0);
2176}
Here is the caller graph for this function:

◆ Create_PeriodicDrivenConstant()

PetscErrorCode Create_PeriodicDrivenConstant ( BoundaryCondition bc)

Configures a BoundaryCondition object for periodic driven-flow forcing.

This constructor wires the periodic callbacks that enforce a prescribed driving strategy (for example constant target flux) on a periodic direction pair.

Parameters
bcA pointer to the generic BoundaryCondition object to be configured.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object for periodic driven-flow forcing.

Local to this translation unit.

Definition at line 2325 of file BC_Handlers.c.

2326{
2327 PetscErrorCode ierr;
2328 PetscFunctionBeginUser;
2329
2330 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition object is NULL in Create_PeriodicDrivenConstantFlux");
2331
2332 // --- Allocate the private data structure ---
2333 DrivenFluxData *data = NULL;
2334 ierr = PetscNew(&data); CHKERRQ(ierr);
2335 // Initialize fields to safe default values
2336 data->direction = ' ';
2337 data->targetVolumetricFlux = 0.0;
2338 data->isMasterController = PETSC_FALSE;
2339 data->enforceSeamFlux = PETSC_FALSE;
2340 data->lastBulkCorrectionStep = -1;
2341
2342 // Attach the private data to the generic handler object
2343 bc->data = (void*)data;
2344
2345 // --- Configure the handler's properties and methods ---
2346
2347 // Set priority: Using BC_PRIORITY_INLET ensures this handler's PreStep runs
2348 // before other handlers (like outlets) that might depend on its calculations.
2349 // It is the caller's responsibility that there are no Inlets called along with driven periodic to avoid clash.
2351
2352 // Assign the function pointers to the implementations in this file.
2356 bc->PostStep = NULL; // This handler has no action after the main solver step.
2357 bc->UpdateUbcs = NULL; // The boundary value is not flow-dependent (it's periodic).
2359
2360 PetscFunctionReturn(0);
2361}
PetscBool enforceSeamFlux
PetscBool isMasterController
PetscInt lastBulkCorrectionStep
static PetscErrorCode Apply_PeriodicDrivenConstant(BoundaryCondition *self, BCContext *ctx)
Apply the configured constant driving term to the periodic boundary.
static PetscErrorCode Initialize_PeriodicDrivenConstant(BoundaryCondition *self, BCContext *ctx)
Initialize constant forcing data for a periodically driven boundary.
static PetscErrorCode Destroy_PeriodicDrivenConstant(BoundaryCondition *self)
Release resources owned by the constant periodic-driving boundary.
static PetscErrorCode PreStep_PeriodicDrivenConstant(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Prepare constant periodic-driving data before the solver step.
PetscReal targetVolumetricFlux
Private data structure shared by both periodic driven-flux handlers.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create_PeriodicDrivenInitial()

PetscErrorCode Create_PeriodicDrivenInitial ( BoundaryCondition bc)

Configures a BoundaryCondition object for initial-flux periodic driving.

Wires the same periodic callbacks as Create_PeriodicDrivenConstant(), but the target flux is measured from the field the run starts with rather than read from the bcs file, so this handler takes no target_flux parameter. The latched target is checkpointed so a restart holds the original value.

Parameters
bcA pointer to the generic BoundaryCondition object to be configured.
Returns
PetscErrorCode 0 on success.

Configures a BoundaryCondition object for initial-flux periodic driving.

Local to this translation unit.

Definition at line 2669 of file BC_Handlers.c.

2670{
2671 PetscErrorCode ierr;
2672 PetscFunctionBeginUser;
2673
2674 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition object is NULL in Create_PeriodicDrivenInitial");
2675
2676 // --- Allocate the private data structure ---
2677 DrivenFluxData *data = NULL;
2678 ierr = PetscNew(&data); CHKERRQ(ierr);
2679 // Initialize fields to safe default values
2680 data->direction = ' ';
2681 data->targetVolumetricFlux = 0.0;
2682 data->isMasterController = PETSC_FALSE;
2683 data->enforceSeamFlux = PETSC_FALSE;
2684 data->lastBulkCorrectionStep = -1;
2685
2686 // Attach the private data to the generic handler object
2687 bc->data = (void*)data;
2688
2689 // --- Configure the handler's properties and methods ---
2690
2691 // Same priority reasoning as the constant-flux handler: PreStep must run
2692 // before any handler that depends on the controller's corrections.
2694
2697 bc->Apply = Apply_PeriodicDrivenConstant; // Boundary trim is target-agnostic.
2698 bc->PostStep = NULL; // This handler has no action after the main solver step.
2699 bc->UpdateUbcs = NULL; // The boundary value is not flow-dependent (it's periodic).
2700 bc->Destroy = Destroy_PeriodicDrivenConstant; // Same private data layout.
2701
2702 PetscFunctionReturn(0);
2703}
static PetscErrorCode Initialize_PeriodicDrivenInitial(BoundaryCondition *self, BCContext *ctx)
Initialize forcing data for a periodic boundary driven to its initial flux.
static PetscErrorCode PreStep_PeriodicDrivenInitial(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Latch the initial-state flux once, then drive to it like a constant target.
Here is the call graph for this function:
Here is the caller graph for this function: