28 PetscFunctionBeginUser;
37 ierr = VecCopy(user->
Ucont, user->
Ucont_o); CHKERRQ(ierr);
43 ierr = VecCopy(user->
Ucat, user->
Ucat_o); CHKERRQ(ierr);
44 ierr = VecCopy(user->
P, user->
P_o); CHKERRQ(ierr);
48 ierr = VecCopy(user->
Nvert, user->
Nvert_o); CHKERRQ(ierr);
59 ierr = DMGlobalToLocalBegin(user->
fda, user->
Ucont_o, INSERT_VALUES, user->
lUcont_o); CHKERRQ(ierr);
60 ierr = DMGlobalToLocalEnd(user->
fda, user->
Ucont_o, INSERT_VALUES, user->
lUcont_o); CHKERRQ(ierr);
66 ierr = DMGlobalToLocalBegin(user->
da, user->
Nvert_o, INSERT_VALUES, user->
lNvert_o); CHKERRQ(ierr);
67 ierr = DMGlobalToLocalEnd(user->
da, user->
Nvert_o, INSERT_VALUES, user->
lNvert_o); CHKERRQ(ierr);
75 PetscFunctionReturn(0);
79#define __FUNCT__ "PerformInitialSetup"
102 PetscFunctionBeginUser;
134 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
146 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
152 PetscFunctionReturn(0);
157#define __FUNCT__ "AdvanceSimulation"
188 const PetscInt StartStep = simCtx->
StartStep;
189 const PetscInt StepsToRun = simCtx->
StepsToRun;
190 const PetscInt OutputFreq = simCtx->
OutputFreq;
191 const PetscReal dt = simCtx->
dt;
194 PetscInt removed_local_ob, removed_global_ob;
195 PetscInt removed_local_lost, removed_global_lost;
197 PetscFunctionBeginUser;
200 StepsToRun, StartStep, simCtx->
StartTime, dt);
203 for (PetscInt step = StartStep; step < StartStep + StepsToRun; ++step) {
222 if (simCtx->
np > 0) {
242 if (simCtx->
np > 0) {
255 if (removed_global_lost + removed_global_ob > 0) {
256 LOG_ALLOW(
GLOBAL,
LOG_INFO,
"Removed %d particles globally this step.\n", removed_global_lost + removed_global_ob);
274 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
279 if (OutputFreq > 0 && (step + 1) % OutputFreq == 0) {
281 for (PetscInt bi = 0; bi < simCtx->
block_number; bi++) {
284 if (simCtx->
np > 0) {
295 PetscFunctionReturn(0);
PetscErrorCode CheckAndRemoveOutOfBoundsParticles(UserCtx *user, PetscInt *removedCountLocal, PetscInt *removedCountGlobal, const BoundingBox *bboxlist)
Checks for particles outside the physical domain boundaries and removes them using DMSwarmRemovePoint...
PetscErrorCode LocateAllParticlesInGrid_TEST(UserCtx *user, BoundingBox *bboxlist)
Orchestrates the complete particle location and migration process for one timestep.
PetscErrorCode UpdateAllParticlePositions(UserCtx *user)
Loops over all local particles in the DMSwarm, updating their positions based on velocity and the glo...
PetscErrorCode ResetAllParticleStatuses(UserCtx *user)
This function is designed to be called at the end of a full timestep, after all particle-based calcul...
PetscErrorCode ReinitializeParticlesOnInletSurface(UserCtx *user, PetscReal currentTime, PetscInt step)
Re-initializes the positions of particles currently on this rank if this rank owns part of the design...
PetscErrorCode CheckAndRemoveLostParticles(UserCtx *user, PetscInt *removedCountLocal, PetscInt *removedCountGlobal)
Removes particles that have been definitively flagged as LOST by the location algorithm.
PetscErrorCode CalculateParticleCountPerCell(UserCtx *user)
Counts particles in each cell of the DMDA 'da' and stores the result in user->ParticleCount.
PetscErrorCode ScatterAllParticleFieldsToEulerFields(UserCtx *user)
Scatters a predefined set of particle fields to their corresponding Eulerian fields.
PetscErrorCode InterpolateAllFieldsToSwarm(UserCtx *user)
Interpolates all relevant fields from the DMDA to the DMSwarm.
PetscErrorCode WriteAllSwarmFields(UserCtx *user)
Writes a predefined set of PETSc Swarm fields to files.
PetscErrorCode WriteSimulationFields(UserCtx *user)
Writes simulation fields to files.
#define LOCAL
Logging scope definitions for controlling message output.
#define GLOBAL
Scope for global logging across all processes.
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
#define PROFILE_FUNCTION_END
Marks the end of a profiled code block.
LogLevel get_log_level()
Retrieves the current logging level from the environment variable LOG_LEVEL.
PetscErrorCode LOG_PARTICLE_FIELDS(UserCtx *user, PetscInt printInterval)
Prints particle fields in a table that automatically adjusts its column widths.
@ LOG_INFO
Informational messages about program execution.
@ LOG_DEBUG
Detailed debugging information.
#define PROFILE_FUNCTION_BEGIN
Marks the beginning of a profiled code block (typically a function).
PetscErrorCode PerformInitialSetup(SimCtx *simCtx)
Finalizes the simulation setup at t=0, ensuring a consistent state before time marching.
PetscErrorCode AdvanceSimulation(SimCtx *simCtx)
Executes the main time-marching loop for the coupled Euler-Lagrange simulation.
PetscErrorCode UpdateSolverHistoryVectors(UserCtx *user)
Copies the current time step's solution fields into history vectors (e.g., U(t_n) -> U_o,...
PetscErrorCode Flow_Solver(SimCtx *simCtx)
Orchestrates a single time step of the Eulerian fluid solver.
PetscBool inletFaceDefined
SimCtx * simCtx
Back-pointer to the master simulation context.
PetscInt ParticleInitialization
PetscInt LoggingFrequency
Defines a 3D axis-aligned bounding box.
The master context for the entire simulation.
User-defined context containing data specific to a single computational grid level.