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:869
@ LOG_DEBUG
Detailed debugging information.
Definition logging.h:32
BCType
Defines the general mathematical/physical Category of a boundary.
Definition variables.h:309
@ INLET
Definition variables.h:316
@ FARFIELD
Definition variables.h:317
@ OUTLET
Definition variables.h:315
@ PERIODIC
Definition variables.h:318
BoundaryFaceConfig boundary_faces[6]
Definition variables.h:1099
BCHandlerType
Defines the specific computational "strategy" for a boundary handler.
Definition variables.h:329
@ BC_HANDLER_PERIODIC_DRIVEN_INITIAL_FLUX
Definition variables.h:343
@ BC_HANDLER_PERIODIC_DRIVEN_CONSTANT_FLUX
Definition variables.h:342
BCHandlerType handler_type
Definition variables.h:393
BCType mathematical_type
Definition variables.h:392
BCFace
Identifies the six logical faces of a structured computational block.
Definition variables.h:287
@ BC_FACE_NEG_X
Definition variables.h:288
@ BC_FACE_POS_Z
Definition variables.h:290
@ BC_FACE_POS_Y
Definition variables.h:289
@ BC_FACE_NEG_Z
Definition variables.h:290
@ BC_FACE_POS_X
Definition variables.h:288
@ BC_FACE_NEG_Y
Definition variables.h:289
Holds the complete configuration for one of the six boundary faces.
Definition variables.h:390
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:384
PetscErrorCode(* PreStep)(BoundaryCondition *self, BCContext *ctx, PetscReal *local_inflow, PetscReal *local_outflow)
Definition variables.h:382
PetscErrorCode(* Destroy)(BoundaryCondition *self)
Definition variables.h:386
PetscErrorCode(* Initialize)(BoundaryCondition *self, BCContext *ctx)
Definition variables.h:381
PetscErrorCode(* UpdateUbcs)(BoundaryCondition *self, BCContext *ctx)
Definition variables.h:385
PetscErrorCode(* Apply)(BoundaryCondition *self, BCContext *ctx)
Definition variables.h:383
BCPriorityType priority
Definition variables.h:379
@ BC_PRIORITY_WALL
Definition variables.h:351
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 Apply_InletVelocity(BoundaryCondition *self, BCContext *ctx)
Applies a Cartesian inlet velocity through the common face-layout path.
static PetscErrorCode PreStep_InletConstantVelocity(BoundaryCondition *self, BCContext *ctx, PetscReal *in, PetscReal *out)
Update constant-inlet data required before the next solver step.
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:349
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 579 of file BC_Handlers.c.

580{
581 PetscErrorCode ierr;
582 PetscFunctionBeginUser;
583
584 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "BoundaryCondition is NULL");
585
586 InletParabolicData *data = NULL;
587 ierr = PetscMalloc1(1, &data); CHKERRQ(ierr);
588 bc->data = (void*)data;
589
595 bc->UpdateUbcs = NULL;
597
598 PetscFunctionReturn(0);
599}
static PetscErrorCode Initialize_InletParabolicProfile(BoundaryCondition *self, BCContext *ctx)
Initialize the geometric data used to evaluate a parabolic inlet profile.
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 1188 of file BC_Handlers.c.

1189{
1190 PetscErrorCode ierr;
1191 PetscFunctionBeginUser;
1192
1193 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "BoundaryCondition is NULL");
1194
1195 InletProfileFileData *data = NULL;
1196 ierr = PetscMalloc1(1, &data); CHKERRQ(ierr);
1197 data->n1 = 0;
1198 data->n2 = 0;
1199 data->profile = NULL;
1200 data->min_speed = 0.0;
1201 data->max_speed = 0.0;
1202 data->source_file = NULL;
1203 bc->data = (void*)data;
1204
1210 bc->UpdateUbcs = NULL;
1212
1213 PetscFunctionReturn(0);
1214}
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.
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 1420 of file BC_Handlers.c.

1421{
1422 PetscFunctionBeginUser;
1423
1424 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition is NULL");
1425
1426 // This handler has the highest priority to ensure it runs after
1427 // all inflow fluxes have been calculated.
1429
1430 // Assign function pointers
1431 bc->Initialize = NULL; // No initialization needed
1435 bc->UpdateUbcs = NULL;
1436 bc->Destroy = NULL; // No private data to destroy
1437
1438 bc->data = NULL;
1439
1440 PetscFunctionReturn(0);
1441}
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:352
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 1935 of file BC_Handlers.c.

1935 {
1936 PetscFunctionBeginUser;
1937
1938 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition is NULL");
1940
1941 // Assign function pointers
1942 bc->Initialize = NULL; // No initialization needed
1943 bc->PreStep = NULL;
1944 bc->Apply = NULL;
1945 bc->PostStep = NULL;
1946 bc->UpdateUbcs = NULL;
1947 bc->Destroy = NULL; // No private data to destroy
1948
1949 bc->data = NULL;
1950
1951 PetscFunctionReturn(0);
1952}
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 2101 of file BC_Handlers.c.

2102{
2103 PetscErrorCode ierr;
2104 PetscFunctionBeginUser;
2105
2106 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition object is NULL in Create_PeriodicDrivenConstantFlux");
2107
2108 // --- Allocate the private data structure ---
2109 DrivenFluxData *data = NULL;
2110 ierr = PetscNew(&data); CHKERRQ(ierr);
2111 // Initialize fields to safe default values
2112 data->direction = ' ';
2113 data->targetVolumetricFlux = 0.0;
2114 data->isMasterController = PETSC_FALSE;
2115 data->enforceSeamFlux = PETSC_FALSE;
2116 data->lastBulkCorrectionStep = -1;
2117
2118 // Attach the private data to the generic handler object
2119 bc->data = (void*)data;
2120
2121 // --- Configure the handler's properties and methods ---
2122
2123 // Set priority: Using BC_PRIORITY_INLET ensures this handler's PreStep runs
2124 // before other handlers (like outlets) that might depend on its calculations.
2125 // It is the caller's responsibility that there are no Inlets called along with driven periodic to avoid clash.
2127
2128 // Assign the function pointers to the implementations in this file.
2132 bc->PostStep = NULL; // This handler has no action after the main solver step.
2133 bc->UpdateUbcs = NULL; // The boundary value is not flow-dependent (it's periodic).
2135
2136 PetscFunctionReturn(0);
2137}
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 2447 of file BC_Handlers.c.

2448{
2449 PetscErrorCode ierr;
2450 PetscFunctionBeginUser;
2451
2452 if (!bc) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_NULL, "Input BoundaryCondition object is NULL in Create_PeriodicDrivenInitial");
2453
2454 // --- Allocate the private data structure ---
2455 DrivenFluxData *data = NULL;
2456 ierr = PetscNew(&data); CHKERRQ(ierr);
2457 // Initialize fields to safe default values
2458 data->direction = ' ';
2459 data->targetVolumetricFlux = 0.0;
2460 data->isMasterController = PETSC_FALSE;
2461 data->enforceSeamFlux = PETSC_FALSE;
2462 data->lastBulkCorrectionStep = -1;
2463
2464 // Attach the private data to the generic handler object
2465 bc->data = (void*)data;
2466
2467 // --- Configure the handler's properties and methods ---
2468
2469 // Same priority reasoning as the constant-flux handler: PreStep must run
2470 // before any handler that depends on the controller's corrections.
2472
2475 bc->Apply = Apply_PeriodicDrivenConstant; // Boundary trim is target-agnostic.
2476 bc->PostStep = NULL; // This handler has no action after the main solver step.
2477 bc->UpdateUbcs = NULL; // The boundary value is not flow-dependent (it's periodic).
2478 bc->Destroy = Destroy_PeriodicDrivenConstant; // Same private data layout.
2479
2480 PetscFunctionReturn(0);
2481}
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: