Skip to content

Move Particle Cloud Generation to Pre-Process - #1839

Draft
danieljvickers wants to merge 2 commits into
MFlowCode:masterfrom
danieljvickers:move-particle-cloud-to-pre-process
Draft

Move Particle Cloud Generation to Pre-Process#1839
danieljvickers wants to merge 2 commits into
MFlowCode:masterfrom
danieljvickers:move-particle-cloud-to-pre-process

Conversation

@danieljvickers

Copy link
Copy Markdown
Member

Simulation should always read the initial state of particles upon start/restart. The particle cloud code was added haphazardly in an attempt to test scaling, but was poorly designed because it performs CPU-only particle placement that is invarient under restart simultaneously on each processor. This compute would be more efficiently done once on CPUs in pre_process and then read in by simulation each time. It saves some placement time in simulation, allows users to not utilize GPU node time to place particles (or worse, to get an allocation just for the job to fail), and muddies the waters for development on particle clouds.

This PR moves that code to preprocessing, and has preprocessing produce IB state files for the first time step, matching the implementation of all other initial values of the code.

@github-actions

Copy link
Copy Markdown

Claude Code Review

Head SHA: 40af4f1

Files changed:

  • 7
  • src/pre_process/m_data_output.fpp
  • src/pre_process/m_global_parameters.fpp
  • src/pre_process/m_particle_cloud.fpp
  • src/pre_process/m_start_up.fpp
  • src/simulation/m_start_up.fpp
  • toolchain/mfc/params/definitions.py
  • toolchain/mfc/test/cases.py

Findings:

  • Namelist patch_ib initial vel/angular_vel/angles are silently zeroed on every run, not just restarts. s_write_ib_state_0 (src/pre_process/m_data_output.fpp) zero-initializes ib_buf once and, for each of the num_ibs namelist patches, only ever populates fields 17–20 (centroid + radius); fields 8–16 (vel/angular_vel/angles) are written as 0 for every namelist patch. In src/simulation/m_start_up.fpp, the new call call s_read_ib_restart_data(0, particle_cloud_ibs, num_particle_cloud_ibs) is now unconditional — it runs on every start, including a fresh (non-restart) run — and applies s_apply_ib_buf to patch_ib(gbl_id) for every namelist IB, overwriting vel, angular_vel, and angles with the zeros read from ib_state_0.dat. Previously, a fresh start (t_step_start == 0, no cfl_dt restart) never called s_read_ib_restart_data at all, so namelist-set initial kinematics for a moving_ibm patch survived untouched. Now any case that sets a nonzero initial patch_ib(i)%vel, %angular_vel, or %angles in the case file will have that initial condition silently discarded at startup (it only self-corrects on an actual restart, where the second s_read_ib_restart_data(n_start/t_step_start, ...) call re-overwrites with the real saved state). This is a silent-wrong-answer regression, not a crash.
    • failure_scenario: A case defines ib = T with a namelist patch_ib(1) moving immersed boundary given a nonzero initial patch_ib(1)%vel(1) (e.g. a projectile launched with initial velocity). On a fresh run, s_write_ib_state_0 writes zeros for vel into restart_data/ib_state_0.dat, and the new unconditional s_read_ib_restart_data(0, ...) call in simulation overwrites patch_ib(1)%vel back to zero before the first timestep, so the IB starts at rest instead of at the specified initial velocity — no error or warning is produced.

@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/pre_process/m_particle_cloud.fpp 415 +415
src/simulation/m_particle_cloud.fpp 0 -411
src/pre_process/m_data_output.fpp 762 +138
src/simulation/m_start_up.fpp 1317 +68
src/common/m_helper.fpp 490 +28
src/simulation/m_collisions.fpp 303 -25
src/pre_process/m_global_parameters.fpp 470 +20
src/pre_process/m_start_up.fpp 493 +12
src/pre_process/p_main.f90 19 +1
Directory Lines Diff
common 10336 +28
pre_process 5099 +586
simulation 27567 -368
total 46390 +246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant