|
MFC
Exascale flow solver
|
Ghost-node immersed boundary method: locates ghost/image points, computes interpolation coefficients, and corrects the flow state. More...
Data Types | |
| type | wall_fill |
| Quadratic wall-normal fill of one ghost point (ib_wall_order = 2): TSC stencils of two probes along the surface normal and the Lagrange weights that carry the profile through them back to the ghost (see s_wall_fill). More... | |
Functions/Subroutines | |
| impure subroutine, public | s_initialize_ibm_module () |
| Allocates memory for the variables in the IBM module. | |
| impure subroutine, public | s_ibm_setup () |
| Initializes the values of various IBM variables, such as ghost points and image points. | |
| real(wp) function, dimension(3) | f_wall_velocity (gp_patch_id, r) |
| Velocity of the body's material point at r from its centroid: translation plus rotation about the centroid. Zero for a fixed body. | |
| real(wp) function | f_curvature_u2 (gp_patch_id, n, u_t) |
| sum_i kappa_i u_i^2 over the principal directions of the wall, for a velocity u_t tangent to it: the centripetal acceleration of fluid sliding along a curved wall with outward normal n. Known for a circle and a sphere (1/R in every direction) and the curved side of a cylinder (none along its axis, the first column of its rotation matrix); zero for any other shape, which keeps the zero-curvature condition there. | |
| subroutine, private | s_compute_ghost_point_pressure (gp, gp_patch_id, radial_vector, vel_ip, rho, pres_ip, pres_gp) |
| Ghost pressure from the wall-normal momentum balance, dp/dn = -rho (a_w . n) + rho sum_i kappa_i u_i^2 with n out of the body. a_w is the acceleration of the wall point: the body's translation (force/mass for a two-way coupled body, else the stage-differenced one), alpha x r_w from its angular acceleration, and the centripetal acceleration omega x (omega x r_w) of its rotation about its centroid. A fluid held at an accelerating wall's velocity needs this pressure gradient to stay with it; mirroring the image-point pressure instead leaves the wall layer unbalanced. The second term is the centripetal acceleration of fluid sliding along a curved slip wall, from the image point's velocity relative to the wall; a no-slip wall holds its fluid at the wall velocity, so it has none. Clamped both ways: the linearization holds only while the correction is order one, and an unbounded one drives the ghost state to vacuum. | |
| subroutine, private | s_compute_ghost_point_velocity (gp, gp_patch_id, radial_vector, vel_ip, pres_ip, vel_gp, q_prim_vf, wf) |
| subroutine, public | s_ibm_correct_state (q_cons_vf, q_prim_vf, pb_in, mv_in) |
| Update the conservative variables at the ghost points. | |
| impure subroutine, public | s_report_ibm_surface |
| One line at the end of a run if the reacting surface ever failed to solve. Silence means every ghost point on every step reached the surface-balance tolerance, i.e. the surface chemistry was actually applied everywhere it was asked for. | |
| subroutine | s_record_gp_surface (i, gp, t_s, mdot_s, reacting) |
| Store ghost point i's surface record in gp_surf. The weight is the surface area the point stands for. Ghost points within two cell sizes h = dV^(1/d) of the surface fill a band of volume ~2hA, so dV/(2h) each sums to the area A (a length in 2D) whatever the surface's orientation to the grid. The band lies inside the solid, where a layer at depth s has area A (1 - s/R)^(d-1) on a curved surface; for circles, spheres and cylinders the weight is scaled back by (R/(R - s))^(d-1), which removes that bias (sampled on random lattice offsets: < 0.1% mean, 0.3% spread for a sphere at R = 12h). The factor is limited to R/(R - s) <= 2, so a body of only a few cells cannot give an infinite or negative weight. | |
| impure subroutine, public | s_write_ib_surface (save_count) |
| Write this rank's surface records to D/ib_surface_<rank>_<save>.dat, one line per weighted ghost point. | |
| pure logical function | f_holds_twall (thermal_bc) |
| The surface temperature is held at Twall: prescribed (thermal_bc = 1) or evolved by the heat balance (thermal_bc = 3). | |
| pure real(wp) function | f_ib_volume (ib_patch) |
| Solid volume of a circle (per unit depth), sphere or cylinder IB. | |
| impure subroutine, public | s_update_ib_temperatures (dt_step) |
| Advance the temperature of each thermal_bc = 3 IB over one step, treating it as one lumped body (small Biot number). With E_solid = m c_s (T - T_ref), the step's face energy in from s_accumulate_ib_face_fluxes and the gasification rate from the surface solve, m c_s dT/dt = Q_in + c_s (T - T_ref) Mdot_out + heat_power - emissivity sigma A (T^4 - T_rad^4). Mdot_out is the solid's mass loss: the face mass sum also carries the ghost cells' non-conservation (a net inflow on a reacting cylinder). T_ref = 298.15 K is the reference of the formation enthalpies, so the gas energy the solid's lost carbon carries is consistent. The step is explicit: the body's thermal time m c_s/(h A) is many orders of magnitude longer than a flow step. For D/ib_heat.dat every body also keeps its gasification rate, face mass out and fluid heat in, Q_in (+ the c_s term for thermal_bc = 3), in patch_ibmdot, mdot_face and qdot. | |
| impure subroutine, public | s_conserve_ib_mass (q_cons_vf) |
| ib_mass_relax: take this step's release of each body's bank (s_update_ib_temperatures) out of the gas within ib_shell_width cells of the body, scaling the partial densities, momentum, energy and species of those cells by one factor (velocity, temperature and composition kept). The ghost-cell treatment does not conserve mass at a moving or gasifying wall (face fluxes into overwritten ghost cells against cells changing side); this returns the gas to exactly the gasified mass, lagged by about ib_mass_relax steps. A cell within reach of two bodies is assigned to the first one found. | |
| impure subroutine, public | s_add_swept_cells (q_cons_vf, q_start_vf, a_w, dt_step) |
| Moving bodies, ib_mass_relax: book the mass of each cell a body covered (-) or uncovered (+) at this stage's placement into ib_heat(3) (mass out of the body, as a rate). The grid faces do not move with the wall, so the face fluxes alone miss the gas swept between face and wall. Called at every placement, after the stage update and before the ghost correction overwrites the covered cells: a cell's content enters the step's result with weight a_w (the product of the later stages' rk_coef(:,1)/ rk_coef(:,4)) and the step-start state with 1 - a_w, so it is booked as a_w q + (1 - a_w) q_start. Mass only: the energy a swept cell carries is not booked. A cell passing directly from one body to another is not counted. | |
| pure subroutine | s_sort_gps_by_location (order) |
| Ghost-point indices ordered by grid location, so per-point output does not inherit the discovery order. s_find_ghost_points assigns slots from a GPU atomic, so that order is the thread schedule's and differs between CPU and GPU builds (MFlowCode/MFC#2039). Heapsort, since a GPU run's input is unordered and a particle array carries O(10^5) ghost points. | |
| pure subroutine | s_sift_gp (order, key, root, last) |
| Restore the max-heap rooted at root over order(1:last), comparing by key. | |
| impure subroutine, private | s_compute_image_points () |
| Compute the image points for each ghost point. | |
| subroutine, private | s_find_num_ghost_points (num_gps_out) |
| Count the number of ghost points for memory allocation. | |
| subroutine, private | s_find_ghost_points () |
| Locate all ghost points in the domain. | |
| subroutine | s_find_ghost_points_ordered () |
| Gather the ghost points in lexicographic (i,j,k) order: count them per i-slab, scan the counts into slab offsets, then fill each slab serially in (j,k) order. The serial-sweep order, reached in parallel over slabs and linear in the cell count. | |
| subroutine, private | s_compute_interpolation_coeffs () |
| Compute the interpolation coefficients for image points. | |
| subroutine | s_tsc_weights (markers, loc, ic, wd, fluid_frac) |
| Triangular-shaped-cloud (quadratic B-spline) weights of a point on the 3x3(x3) stencil centred on the cell nearest to it (Ezra, Peles & Kozak 2025, Int. J. Heat Mass Transf. 252:127314), and the fraction of that weight carried by fluid cells. The kernel is a partition of unity and smooth across cell boundaries, so an interpolated wall quantity converges one order faster than from inverse-distance or bilinear weights, which are only continuous. The weights use the fractional position in the bracketing cell at integer offsets, which keeps the partition of unity exactly on a stretched grid. The stencil is kept inside the halo. Solid cells in it carry the ghost values of the last correction (see ib_keep_ghost); a point buried in a body has no fluid weight. | |
| real(wp) function, private | f_tsc_apply (sf, ic, wd) |
| Apply TSC weights from s_tsc_weights to one field. | |
| real(wp) function, private | f_quad_fill (phi_w, phi_1, phi_2, lw, llin) |
| Ghost value from the quadratic wall-normal profile, bounded by the linear mirror (minmod). The two extrapolations agree exactly for a linear profile, so this limits only the curvature correction, and to the size the linear mirror already produces. Unlimited, the quadratic amplifies that correction with ghost depth and can leave unphysical near-wall states. | |
| subroutine, private | s_wall_fill (gp, wf) |
| Probes and Lagrange weights of the quadratic wall-normal fill of a ghost point. The wall is at s = 0, the probes at s1 and s2 = 2 s1 along the surface normal from the wall foot, the ghost at s = -d (d = |levelset|): | |
| real(wp) function, dimension(3, 3, 3) | f_tsc_stencil (wd) |
| Tensor product of the 1D TSC weights: the coefficient on each cell of the 3x3x3 stencil. | |
| subroutine, private | s_interpolation_weights (gp, i, j, k, dist, fluid_mask, interp_coeffs) |
| Fluid-masked image-point weights: bilinear for second-order IBM, else inverse distance squared. | |
| subroutine, private | s_interpolate_image_point (q_prim_vf, gp, alpha_rho_ip, alpha_ip, pres_ip, vel_ip, c_ip, r_ip, v_ip, pb_ip, mv_ip, nmom_ip, pb_in, mv_in, presb_ip, massv_ip, ys_ip) |
| Interpolate primitive variables to a ghost point's image point using bilinear or trilinear interpolation. | |
| subroutine | s_update_ib_rotation_matrices (num_ibs) |
| Resets the current indexes of immersed boundaries and replaces them after updating the position of each moving immersed boundary Recalculate the moving bodies' rotation matrices from their current angles (device). | |
| impure subroutine | s_update_mib (num_ibs) |
| pure real(wp) function | f_log_cosh (x) |
| log(cosh(x)) without overflow for large |x| | |
| subroutine | s_prescribed_kinematics (i, t) |
| Prescribed kinematics for patch i at time t: hinged flapping (kin_model = 1) or the Eldredge pitch ramp (kin_model = 2). Flapping rolls phi about the lab x axis through the hinge and pitches theta about the body spanwise (y) axis through it; the ramp holds phi at zero and drives theta alone. Both compose as R = Rx(phi) Ry(theta) (MFC's angle convention) and set the angles, centroid, velocity and lab-frame angular velocity; nothing is integrated, so restarts are exact. | |
| real(wp) function | f_ib_face_flux (hatr, j, k, l, c) |
| Face flux of component c. The dual-pass HLLD RHS takes the hat_R set at the left face of a cell (hatR) and hat_L at its right. | |
| subroutine | s_accumulate_ib_face_fluxes (idir, stage, q_cons_vf, markers) |
| Add direction idir's fluid-body face fluxes to each IB. These are the fluxes the RHS differences, Riemann (flux_rsx_vf) plus viscous, capillary, conductive and diffusive (flux_src_rsx_vf), so each body receives exactly what the fluid loses. A face counts on the rank owning its fluid cell. With IB forces: force (1:3) and torque about the centroid (4:6) of each local IB into ib_face_ft, from the last RHS evaluation (idir = 1 starts afresh); a moving body's momentum flux is taken through a face moving with its wall (face momentum times the wall's normal velocity is removed). With ib_exchange: energy in and mass out of each lumped body (every body with ib_heat_wrt) into ib_heat(2:3), weighted so a step's stages sum to its exchange (SSP-RK: 1; 1/2, 1/2; 1/6, 1/6, 2/3). | |
| subroutine | s_compute_ib_forces () |
| Set each IB's force and torque: the fluid's share from the face fluxes of the last RHS evaluation (s_accumulate_ib_face_fluxes), plus collisions and body forces. | |
| subroutine | s_compute_centroid_offset (gid, ib_marker) |
| Computes the center of mass for IB patch types where we are unable to determine their center of mass analytically. These patches include things like NACA airfoils and STL models Move a moving airfoil/STL patch's centroid to its centre of mass, keeping the difference in centroid_offset. Collective: every rank calls it for every global id, contributing zeros for patches it does not hold. | |
| pure logical function | f_needs_centroid_offset (patch) |
| A moving airfoil or STL (geometries 4, 5, 11, 12) moves its centroid to the centre of mass and keeps a centroid_offset. | |
| impure subroutine | s_restore_centroid_offsets (t_init) |
| On restart, replace the re-measured centroid offsets with the ones the run was using (restart_data/ib_offset_<step>.dat, written with each checkpoint), and re-place kinematics-driven bodies about them. No file: the measured offsets stand. | |
| subroutine | s_compute_moment_of_inertia (patch, axis, moment) |
| Computes the moment of inertia for an immersed boundary. | |
| subroutine | s_wrap_periodic_ibs () |
| Wrap immersed boundary positions across periodic domain boundaries. | |
| impure subroutine | s_setup_ib_force_comm () |
| Builds the ascending list of distinct neighborhood ranks used by s_communicate_ib_forces and allocates its buffers once. The ascending order is the fixed order in which an owner adds its neighbors' contributions. | |
| integer function | f_ib_nbr_slot (rank) |
| Position of rank in ib_nbrs. | |
| subroutine | s_communicate_ib_forces (forces, torques) |
| Reduces forces and torques so every rank holding an IB ends with bit-identical values. Each IB has one owner, the rank whose subdomain holds its centroid (patch_ibowner_rank, stamped at handoff). Phase 1: each rank sends its nonzero partials to the owner, which adds them to its own partial in ascending source-rank order once all have arrived. Phase 2: each owner sends its totals to every neighborhood rank, which overwrite their partials. One nonblocking message per neighbor per phase. | |
| subroutine | s_handoff_ib_ownership () |
| Swaps ownership of IBs and passes ownership of IBs to neighbor processors. | |
| impure subroutine | s_check_every_patch_marked () |
| Abort if any namelist immersed boundary marks no cell anywhere. The owning rank is chosen by the patch centroid, so an STL placed with model_translate while its centroid is left elsewhere is handed to ranks that do not hold it, and it vanishes silently. Cloud particles are skipped: a particle's centroid is its body, so it cannot vanish this way. | |
| impure subroutine | s_ibm_marker_bounds () |
| Compute the deepest-level marker-field bounds into mkr_lo/mkr_hi: the coarse block (m/n/p with ghosts) or the deepest fine block a rank can own, whichever is larger (a level-l block has amr_ref_ratio**l * base_ext - 1 interior cells per active dim, base_ext = the user footprint in coarse cells). Called from s_initialize_ibm_module and s_ibm_alloc_fine. | |
| impure subroutine, public | s_ibm_alloc_fine (nslots, f1_lo, f1_hi, f2_lo, f2_hi, f3_lo, f3_hi) |
| Allocate the per-slot fine-IB marker fields, sized to the max buffered fine extents; ghost-point lists start empty. No-op unless amr .and. ib. | |
| impure subroutine, public | s_ibm_note_fine_memory () |
| Note the fine IB state's memory for the end-of-run AMR table. | |
| impure subroutine, public | s_ibm_reset_fine_park () |
| Forget every slot's parked fine list (before the fine lists are rebuilt for the current block set). | |
| impure integer function, public | f_ibm_fine_gps (islot) |
| Ghost points stored for fine slot islot: zero for a block that holds no immersed body. | |
| impure subroutine, public | s_ibm_tally_gps_by_body (cnt) |
| Add to cnt(1:num_gbl_ibs) the ghost points each body has in the active list (the fine slot's when swapped in); counted on the device, since ghost_points never crosses to the host. | |
| impure subroutine, public | s_ibm_check_bodies_on_one_rank (cnt) |
| Abort if any one body has ghost points on more than one rank: the fine image-point stencil is exact only when a body's whole fine state lives on one rank. Counts are per global body, so bodies on different ranks are fine. | |
| impure subroutine, public | s_ibm_load_fine_markers (nb, slots, mext, sd, w) |
| Load ib_markers_fine for the next fine RHS pass: member ibm's fine markers (interior 0:mext(:, ibm)) land at offset (ibm - 1)*w along dimension sd; the rest of the installed frame reads 0, so padding and gaps zero nothing. Per-block callers pass nb = 1, w = 0. Grid globals must already be swapped. | |
| impure subroutine, public | s_ibm_swap_to_fine (islot, gps_on_device) |
| Swap the module IB globals (ib_markers/ghost_points/num_gps) to fine slot islot's state; the coarse state parks in the save slot. Pair with s_ibm_restore_from_fine; grid globals must already be swapped to the fine block. | |
| impure subroutine, public | s_ibm_restore_from_fine (islot) |
| Restore the coarse IB globals saved by s_ibm_swap_to_fine, parking the (possibly updated) fine state back in slot islot. | |
| impure subroutine | s_ibm_reserve_park (islot, n_f) |
| Give slot islot a gp_park segment for n_f ghost points at the pool top: exact for fixed bodies (the list keeps its length until s_ibm_reset_fine_park), full-length for moving bodies (so a slot never needs a second one, and a vacated one is reused). | |
| impure subroutine | s_ibm_rebuild_corrected_gps (n_g) |
| Rebuild corrected_gps from the ghost-point list now in ghost_points: s_compute_interpolation_coeffs only sets entries, so clear the whole field and re-mark the valid ghost points on-device (same defaultmap treatment as the swap kernels). | |
| impure subroutine, public | s_ibm_setup_fine () |
| Compute the fine-grid IB state (markers, ghost points, levelset, image points, interpolation coeffs) for the current block, mirroring the static-body portion of s_ibm_setup. Grid globals must be swapped to the fine block and IB globals to this slot (s_ibm_swap_to_fine) first. | |
| impure subroutine, public | s_finalize_ibm_module () |
| Finalize the IBM module. | |
| impure subroutine | s_ib_flux_wall_setup () |
| ib_flux_wall: allocate the wall fields, give each body's ghost points with a fluid face neighbor their wall area per face area, and report the wall area the faces carry. A planar wall of area A has sum|n_i| A of staircase faces, so each face carries 1/sum|n_i| of its own area. | |
| impure subroutine, public | s_ib_flux_wall_prepare (q_prim_vf) |
| ib_flux_wall, before each Riemann solve (primitive buffers filled): fill ib_wall_src's buffer cells and set the positivity factor of every fluid cell in the domain and its first buffer layer (a wall face on a rank seam is solved on both sides), the largest theta <= 1 for which its wall faces take at most ib_wall_safety of any species in one forward-Euler step of size dt (each SSP-RK stage is a convex combination of such steps). Conservative: the body books the scaled flux. | |
| real(wp) function | f_wall_face_sum (src, j, k, l, q) |
| ib_flux_wall: sum over the wall faces of fluid cell (j, k, l) of the wall area per cell volume, times species q's consumption rate max(-mdot_q, 0) (q > 0) or 1 (q = 0) | |
| real(wp) function | f_wall_face_term (src, j, k, l, q) |
| ib_flux_wall: wall area per face area times species q's consumption rate (q > 0) or 1 (q = 0) of the body cell (j, k, l) | |
| real(wp) function | f_flux_wall_record_area (src, theta, marks, loc) |
| ib_flux_wall: the surface area a reacting body's ghost point (j, k, l) stands for in its surface record, the wall area its fluid faces carry (a theta times their area, as the Riemann solver takes them); 0 off the faces | |
| impure subroutine | s_ib_wall_src_buffers () |
| ib_flux_wall: fill ib_wall_src's buffer cells from the neighbouring ranks or the periodic image; they stay zero (no wall) at other domain boundaries | |
| subroutine | s_surface_species_residual (pres, t_s, d, ys_ip, ys_s, w_species, r_species, omega_s, mdot_s) |
| Species flux residual at a heterogeneous reacting surface. | |
| subroutine | s_surface_energy_residual (pres, t_ip, t_s, d, ys_s, r_energy) |
| Surface energy residual: gas-side conduction balances heterogeneous reaction heat. Radiation and solid-side conduction are omitted. | |
| subroutine | s_surface_residual (pres, t_ip, t_s, d, ys_ip, ys_s, w_species, k_bath, solve_temperature, flux_scale, energy_scale, r, r_species, omega_s, mdot_s) |
| Assemble the Newton residual for Ns species, with temperature appended only when it is solved. k_bath selects which species balance the sum constraint displaces; see s_solve_surface for why it must be the most abundant one. | |
| subroutine | s_blend_ghost_temperature (t_ip, t_s, t_lo, t_hi, t_g) |
| Ghost state for an immersed surface, from the image-point state and the surface state. | |
| subroutine | s_blend_ghost_species (ys_ip, ys_s, ys_g) |
| Species half of the ghost-state blend: one theta shared by every species (see s_blend_ghost_temperature). | |
| subroutine | s_pick_bath_species (ys_s, k_bath) |
| Index of the most abundant species, i.e. the balance the sum constraint displaces. | |
| subroutine | s_solve_surface (pres, t_ip, t_wall, d, ys_ip, w_species, thermal_bc, ys_s, t_s, mdot_s, converged) |
| Newton solve for a reacting surface. thermal_bc=0: zero-normal-gradient T; 1: prescribed T; 2: energy balance. | |
| subroutine | s_solve_surface_linear_system (a, b, x, nsolve, success) |
| Small dense linear solve with partial pivoting for the local surface Newton system. | |
Variables | |
| integer | n_surface_not_converged = 0 |
| Ghost points at which the reacting-surface Newton solve did not reach its tolerance, so the point fell back to a chemically inert wall (keeping a prescribed Twall). Counted because that fallback is otherwise indistinguishable from a surface mechanism that simply does nothing, and a run can look converged while the surface chemistry never engaged. | |
| integer | n_surface_ill_posed = 0 |
| Ghost points whose levelset distance was not positive, leaving the surface gradient (X_IP - X_s)/d undefined. Separate from the counter above because this is a grid/geometry degeneracy, not a kinetics failure. | |
| integer, dimension(3) | n_fill_tier = 0 |
| Ghost-point updates per fill tier, summed over the run and reported at its end, because a tight packing can sit mostly in tier 2 and a second-order claim is then not true of that surface. | |
| type(integer_field), public | ib_markers |
| type(integer_field), public | ib_markers_fine |
| Body markers in the fine-advance frame, read by s_compute_rhs's body-cell RHS zeroing while amr_in_fine_advance: the advanced block's fine markers (for a batch, every member's at its slab offset), loaded by s_ibm_load_fine_markers before each fine RHS pass. ib_markers holds the coarse markers during a fine RHS. Interior-only, sized to the allocation extents. | |
| type(integer_field) | corrected_gps |
| 1 at ghost points whose image point reaches the fluid, 0 elsewhere. Ghost points with a buried image point average over these neighbors, and never over each other. | |
| type(ghost_point), dimension(:), allocatable | ghost_points |
| real(wp), dimension(:,:), allocatable | gp_prim_new |
| New primitive state per ghost point, staged so it is published only after every image-point stencil has been read (MFlowCode/MFC#1901). Writing q_prim inside the same loop that reads it at neighboring image-point stencils makes a ghost's result depend on whether its neighbors were updated first. Inverse-distance weights mask solid cells, so the race is latent there; a stencil that reads ghost cells (ib_ip_interp = 2) needs it. | |
| integer, dimension(:), allocatable | gp_slab |
| per-i-slab ghost-point counts/offsets for the ordered gather (AMR) | |
| integer, parameter | ib_surf_nvars = 3 |
| Surface record per ghost point from the latest s_ibm_correct_state, kept when ib_surface_wrt: (1) area weight, (2) wall temperature, (3) gasified mass flux. Only ghost points within two cells of the surface carry a weight, so summing weight*flux over them integrates over the surface; see s_record_gp_surface. | |
| real(wp), dimension(:,:), allocatable | gp_surf |
| integer, parameter, public | ibw_e = num_species + 1 |
| ib_flux_wall: per ghost point with a fluid face neighbor of a body, from its surface solve (zero for an inert body), the species mass fluxes into the gas (1:num_species), the energy flux (ibw_e), the blowing velocity (ibw_u:ibw_u + 2) and the wall area per face area, 1/sum|n_i| (ibw_a, 0 off a wall); ib_wall_theta: each fluid cell's positivity factor on its wall faces' rates | |
| integer, parameter, public | ibw_u = num_species + 2 |
| integer, parameter, public | ibw_a = num_species + 5 |
| type(scalar_field), dimension(ibw_a), public | ib_wall_src |
| type(scalar_field), public | ib_wall_theta |
| logical | record_surface |
| gp_surf is filled when it is written (ib_surface_wrt) or integrated (ib_exchange). | |
| logical, public | ib_exchange = .false. |
| ib_heat is accumulated: some IB has thermal_bc = 3, ib_heat_wrt or ib_mass_relax | |
| real(wp), dimension(:,:), allocatable | ib_heat |
| Per global IB, for the thermal_bc = 3 update and ib_heat_wrt: (1) surface area and (4) gasification rate, from gp_surf; (2) energy into the solid and (3) mass out of it, both summed over the faces between the body's cells and fluid cells with the RK stage weights, so over a step they are exactly the energy and mass the fluid exchanged with the body. | |
| real(wp), dimension(:,:), allocatable | ib_mass_res |
| ib_mass_relax, per global IB: (1) gas mass gained from the body beyond its gasification and not yet returned, (2) the share released this step; ib_shell_mass: gas mass of the body's shell. ib_shell: global IB id of each fluid cell within ib_shell_width cells of a body, else 0. ib_markers_prev: markers at the last placement of a moving body (s_add_swept_cells). | |
| real(wp), dimension(:,:), allocatable | ib_shell_mass |
| type(integer_field) | ib_shell |
| type(integer_field) | ib_markers_prev |
| integer, parameter | ib_shell_width = 2 |
| integer, public | num_gps |
| Number of ghost points. | |
| logical | moving_immersed_boundary_flag |
| integer | ib_ip_width |
| Cells per direction in the image-point interpolation stencil: 2 (inverse distance, bilinear) or 3 (TSC). | |
| logical | ib_keep_ghost |
| The interpolation or the wall probes read solid cells, so ghost cells keep the last correction. | |
| logical | ib_wall_quad |
| ib_wall_order = 2: quadratic wall-normal ghost velocity at no-slip walls | |
| logical | centroid_offsets_active = .false. |
| some patch is a moving airfoil or STL, which carries a centroid_offset | |
| integer, parameter, private | ib_rec_len = 7 |
| gbl_patch_id, force(1:3), torque(1:3) | |
| integer, private | n_ib_nbrs = 0 |
| integer, dimension(:), allocatable, private | ib_nbrs |
| integer, dimension(:), allocatable, private | ib_send_counts |
| integer, dimension(:), allocatable, private | ib_reqs |
| integer, dimension(:,:), allocatable, private | ib_stats |
| real(wp), dimension(:,:), allocatable, private | ib_send_bufs |
| real(wp), dimension(:,:), allocatable, private | ib_recv_bufs |
| real(wp), dimension(:,:), allocatable | ib_face_ft |
| Force (1:3) and torque (4:6) on each local IB from the fluid-body face fluxes of the last RHS evaluation. | |
Ghost-node immersed boundary method: locates ghost/image points, computes interpolation coefficients, and corrects the flow state.
| real(wp) function m_ibm::f_curvature_u2 | ( | integer, intent(in) | gp_patch_id, |
| real(wp), dimension(3), intent(in) | n, | ||
| real(wp), dimension(3), intent(in) | u_t ) |
sum_i kappa_i u_i^2 over the principal directions of the wall, for a velocity u_t tangent to it: the centripetal acceleration of fluid sliding along a curved wall with outward normal n. Known for a circle and a sphere (1/R in every direction) and the curved side of a cylinder (none along its axis, the first column of its rotation matrix); zero for any other shape, which keeps the zero-curvature condition there.
Definition at line 2013 of file m_ibm.fpp.f90.
| real(wp) function m_ibm::f_flux_wall_record_area | ( | type(scalar_field), dimension(ibw_a), intent(in) | src, |
| type(scalar_field), intent(in) | theta, | ||
| type(integer_field), intent(in) | marks, | ||
| integer, dimension(3), intent(in) | loc ) |
ib_flux_wall: the surface area a reacting body's ghost point (j, k, l) stands for in its surface record, the wall area its fluid faces carry (a theta times their area, as the Riemann solver takes them); 0 off the faces
| [in] | marks | ib_markers, passed like src |
Definition at line 8566 of file m_ibm.fpp.f90.
| pure logical function m_ibm::f_holds_twall | ( | integer, intent(in) | thermal_bc | ) |
The surface temperature is held at Twall: prescribed (thermal_bc = 1) or evolved by the heat balance (thermal_bc = 3).
Definition at line 3220 of file m_ibm.fpp.f90.
| real(wp) function m_ibm::f_ib_face_flux | ( | logical, intent(in) | hatr, |
| integer, intent(in) | j, | ||
| integer, intent(in) | k, | ||
| integer, intent(in) | l, | ||
| integer, intent(in) | c ) |
Face flux of component c. The dual-pass HLLD RHS takes the hat_R set at the left face of a cell (hatR) and hat_L at its right.
Definition at line 5601 of file m_ibm.fpp.f90.
| integer function m_ibm::f_ib_nbr_slot | ( | integer, intent(in) | rank | ) |
Position of rank in ib_nbrs.
Definition at line 6423 of file m_ibm.fpp.f90.
| pure real(wp) function m_ibm::f_ib_volume | ( | type(ib_patch_parameters), intent(in) | ib_patch | ) |
Solid volume of a circle (per unit depth), sphere or cylinder IB.
Definition at line 3246 of file m_ibm.fpp.f90.
| impure integer function, public m_ibm::f_ibm_fine_gps | ( | integer, intent(in) | islot | ) |
Ghost points stored for fine slot islot: zero for a block that holds no immersed body.
Definition at line 6867 of file m_ibm.fpp.f90.
log(cosh(x)) without overflow for large |x|
Definition at line 5487 of file m_ibm.fpp.f90.
| pure logical function m_ibm::f_needs_centroid_offset | ( | type(ib_patch_parameters), intent(in) | patch | ) |
A moving airfoil or STL (geometries 4, 5, 11, 12) moves its centroid to the centre of mass and keeps a centroid_offset.
Definition at line 6133 of file m_ibm.fpp.f90.
|
private |
Ghost value from the quadratic wall-normal profile, bounded by the linear mirror (minmod). The two extrapolations agree exactly for a linear profile, so this limits only the curvature correction, and to the size the linear mirror already produces. Unlimited, the quadratic amplifies that correction with ghost depth and can leave unphysical near-wall states.
Definition at line 4899 of file m_ibm.fpp.f90.
|
private |
Apply TSC weights from s_tsc_weights to one field.
Definition at line 4841 of file m_ibm.fpp.f90.
| real(wp) function, dimension(3, 3, 3) m_ibm::f_tsc_stencil | ( | real(wp), dimension(3, 3), intent(in) | wd | ) |
Tensor product of the 1D TSC weights: the coefficient on each cell of the 3x3x3 stencil.
Definition at line 5013 of file m_ibm.fpp.f90.
| real(wp) function m_ibm::f_wall_face_sum | ( | type(scalar_field), dimension(ibw_a), intent(in) | src, |
| integer, intent(in) | j, | ||
| integer, intent(in) | k, | ||
| integer, intent(in) | l, | ||
| integer, intent(in) | q ) |
ib_flux_wall: sum over the wall faces of fluid cell (j, k, l) of the wall area per cell volume, times species q's consumption rate max(-mdot_q, 0) (q > 0) or 1 (q = 0)
| [in] | src | ib_wall_src, passed so the device routine reads the present copy |
Definition at line 8506 of file m_ibm.fpp.f90.
| real(wp) function m_ibm::f_wall_face_term | ( | type(scalar_field), dimension(ibw_a), intent(in) | src, |
| integer, intent(in) | j, | ||
| integer, intent(in) | k, | ||
| integer, intent(in) | l, | ||
| integer, intent(in) | q ) |
ib_flux_wall: wall area per face area times species q's consumption rate (q > 0) or 1 (q = 0) of the body cell (j, k, l)
Definition at line 8536 of file m_ibm.fpp.f90.
| real(wp) function, dimension(3) m_ibm::f_wall_velocity | ( | integer, intent(in) | gp_patch_id, |
| real(wp), dimension(3), intent(in) | r ) |
Velocity of the body's material point at r from its centroid: translation plus rotation about the centroid. Zero for a fixed body.
Definition at line 1959 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_accumulate_ib_face_fluxes | ( | integer, intent(in) | idir, |
| integer, intent(in) | stage, | ||
| type(scalar_field), dimension(sys_size), intent(in) | q_cons_vf, | ||
| type(integer_field), intent(in) | markers ) |
Add direction idir's fluid-body face fluxes to each IB. These are the fluxes the RHS differences, Riemann (flux_rsx_vf) plus viscous, capillary, conductive and diffusive (flux_src_rsx_vf), so each body receives exactly what the fluid loses. A face counts on the rank owning its fluid cell. With IB forces: force (1:3) and torque about the centroid (4:6) of each local IB into ib_face_ft, from the last RHS evaluation (idir = 1 starts afresh); a moving body's momentum flux is taken through a face moving with its wall (face momentum times the wall's normal velocity is removed). With ib_exchange: energy in and mass out of each lumped body (every body with ib_heat_wrt) into ib_heat(2:3), weighted so a step's stages sum to its exchange (SSP-RK: 1; 1/2, 1/2; 1/6, 1/6, 2/3).
| [in] | markers | ib_markers, or ib_markers_fine on an AMR fine frame |
Definition at line 5658 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_add_swept_cells | ( | type(scalar_field), dimension(sys_size), intent(in) | q_cons_vf, |
| type(scalar_field), dimension(sys_size), intent(in) | q_start_vf, | ||
| real(wp), intent(in) | a_w, | ||
| real(wp), intent(in) | dt_step ) |
Moving bodies, ib_mass_relax: book the mass of each cell a body covered (-) or uncovered (+) at this stage's placement into ib_heat(3) (mass out of the body, as a rate). The grid faces do not move with the wall, so the face fluxes alone miss the gas swept between face and wall. Called at every placement, after the stage update and before the ghost correction overwrites the covered cells: a cell's content enters the step's result with weight a_w (the product of the later stages' rk_coef(:,1)/ rk_coef(:,4)) and the step-start state with 1 - a_w, so it is booked as a_w q + (1 - a_w) q_start. Mass only: the energy a swept cell carries is not booked. A cell passing directly from one body to another is not counted.
Definition at line 3786 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_blend_ghost_species | ( | real(wp), dimension(num_species), intent(in) | ys_ip, |
| real(wp), dimension(num_species), intent(in) | ys_s, | ||
| real(wp), dimension(num_species), intent(out) | ys_g ) |
Species half of the ghost-state blend: one theta shared by every species (see s_blend_ghost_temperature).
Definition at line 8906 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_blend_ghost_temperature | ( | real(wp), intent(in) | t_ip, |
| real(wp), intent(in) | t_s, | ||
| real(wp), intent(in) | t_lo, | ||
| real(wp), intent(in) | t_hi, | ||
| real(wp), intent(out) | t_g ) |
Ghost state for an immersed surface, from the image-point state and the surface state.
The natural closure is the linear mirror phi_g = 2*phi_s - phi_IP, which is what makes the midpoint of the ghost/image pair reproduce the surface value. Its -1 coefficient on phi_IP is unconditional, though, so it drives strictly positive quantities negative whenever the surface value sits far below the image-point value: a cold wall in hot gas gives a negative ghost temperature and hence a negative ghost density, and a species the surface consumes faster than half the free-stream value gives a negative mass fraction. Rather than clamp the result – which would break sum(Y) = 1 and hide the excursion – the ghost state is the largest convex blend of the mirror back toward the surface value that stays physical:
phi_g(theta) = phi_s + theta*(phi_s - phi_IP), theta in [0, 1]
theta = 1 is the full second-order mirror; theta = 0 is the first-order Dirichlet ghost phi_g = phi_s, which is Gibou et al. (JCP 176:205, 2002) Eq. 17 and is what they likewise fall back to where the linear form is ill-behaved. One theta is shared by every species, so since both endpoints satisfy sum(Y) = 1, so does every blend between them – exactly, with no renormalization. Temperature gets its own theta: nothing couples it to the composition, and sharing would let a trace radical the surface consumes to ~1e-9 (O and OH at a burning carbon wall) drag the thermal mirror down with it, turning a 2100 K ghost into 1205 K over a species whose own excursion was 1e-9. The cost of limiting is small: the mirror already delivers only first-order wall flux (Ezra et al., Int. J. Heat Mass Transfer, 2025), and a boundary closure one order below the interior scheme retains the interior convergence rate (Gustafsson, Math. Comp. 29:396, 1975).
This bounds the ghost state; it does not make the boundary strictly conservative. Baskaya et al. (Computers & Fluids 270:106134, 2024) trace the same cold-wall, large-gradient regime in ablation to ghost-cell mass conservation error that surfaces as spurious blowing, and resolve it only by moving to a flux-based cut-cell boundary – a different discretization from this one, not a tuning of it.
Definition at line 8866 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_check_every_patch_marked |
Abort if any namelist immersed boundary marks no cell anywhere. The owning rank is chosen by the patch centroid, so an STL placed with model_translate while its centroid is left elsewhere is handed to ranks that do not hold it, and it vanishes silently. Cloud particles are skipped: a particle's centroid is its body, so it cannot vanish this way.
Definition at line 6758 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_communicate_ib_forces | ( | real(wp), dimension(num_ibs, 3), intent(inout) | forces, |
| real(wp), dimension(num_ibs, 3), intent(inout) | torques ) |
Reduces forces and torques so every rank holding an IB ends with bit-identical values. Each IB has one owner, the rank whose subdomain holds its centroid (patch_ibowner_rank, stamped at handoff). Phase 1: each rank sends its nonzero partials to the owner, which adds them to its own partial in ascending source-rank order once all have arrived. Phase 2: each owner sends its totals to every neighborhood rank, which overwrite their partials. One nonblocking message per neighbor per phase.
Definition at line 6439 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_compute_centroid_offset | ( | integer, intent(in) | gid, |
| integer, intent(in) | ib_marker ) |
Computes the center of mass for IB patch types where we are unable to determine their center of mass analytically. These patches include things like NACA airfoils and STL models Move a moving airfoil/STL patch's centroid to its centre of mass, keeping the difference in centroid_offset. Collective: every rank calls it for every global id, contributing zeros for patches it does not hold.
| [in] | gid | global patch id |
| [in] | ib_marker | local index on this rank; <= 0 if not held |
Definition at line 6068 of file m_ibm.fpp.f90.
|
private |
Ghost pressure from the wall-normal momentum balance, dp/dn = -rho (a_w . n) + rho sum_i kappa_i u_i^2 with n out of the body. a_w is the acceleration of the wall point: the body's translation (force/mass for a two-way coupled body, else the stage-differenced one), alpha x r_w from its angular acceleration, and the centripetal acceleration omega x (omega x r_w) of its rotation about its centroid. A fluid held at an accelerating wall's velocity needs this pressure gradient to stay with it; mirroring the image-point pressure instead leaves the wall layer unbalanced. The second term is the centripetal acceleration of fluid sliding along a curved slip wall, from the image point's velocity relative to the wall; a no-slip wall holds its fluid at the wall velocity, so it has none. Clamped both ways: the linearization holds only while the correction is order one, and an unbounded one drives the ghost state to vacuum.
| [in] | radial_vector | Centroid to ghost point |
Definition at line 2075 of file m_ibm.fpp.f90.
|
private |
| [in] | q_prim_vf | Probed by the quadratic fill |
Definition at line 2122 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_compute_ib_forces |
Set each IB's force and torque: the fluid's share from the face fluxes of the last RHS evaluation (s_accumulate_ib_face_fluxes), plus collisions and body forces.
Definition at line 5939 of file m_ibm.fpp.f90.
|
private |
Compute the image points for each ghost point.
Definition at line 3961 of file m_ibm.fpp.f90.
|
private |
Compute the interpolation coefficients for image points.
Definition at line 4633 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_compute_moment_of_inertia | ( | type(ib_patch_parameters), intent(in) | patch, |
| real(wp), dimension(3), intent(in) | axis, | ||
| real(wp), intent(out) | moment ) |
Computes the moment of inertia for an immersed boundary.
Definition at line 6173 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_conserve_ib_mass | ( | type(scalar_field), dimension(sys_size), intent(inout) | q_cons_vf | ) |
ib_mass_relax: take this step's release of each body's bank (s_update_ib_temperatures) out of the gas within ib_shell_width cells of the body, scaling the partial densities, momentum, energy and species of those cells by one factor (velocity, temperature and composition kept). The ghost-cell treatment does not conserve mass at a moving or gasifying wall (face fluxes into overwritten ghost cells against cells changing side); this returns the gas to exactly the gasified mass, lagged by about ib_mass_relax steps. A cell within reach of two bodies is assigned to the first one found.
Definition at line 3568 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_finalize_ibm_module |
Finalize the IBM module.
Definition at line 7476 of file m_ibm.fpp.f90.
|
private |
Locate all ghost points in the domain.
Definition at line 4197 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_find_ghost_points_ordered |
Gather the ghost points in lexicographic (i,j,k) order: count them per i-slab, scan the counts into slab offsets, then fill each slab serially in (j,k) order. The serial-sweep order, reached in parallel over slabs and linear in the cell count.
Definition at line 4382 of file m_ibm.fpp.f90.
|
private |
Count the number of ghost points for memory allocation.
Definition at line 4109 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_handoff_ib_ownership |
Swaps ownership of IBs and passes ownership of IBs to neighbor processors.
Definition at line 6542 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ib_flux_wall_prepare | ( | type(scalar_field), dimension(sys_size), intent(in) | q_prim_vf | ) |
ib_flux_wall, before each Riemann solve (primitive buffers filled): fill ib_wall_src's buffer cells and set the positivity factor of every fluid cell in the domain and its first buffer layer (a wall face on a rank seam is solved on both sides), the largest theta <= 1 for which its wall faces take at most ib_wall_safety of any species in one forward-Euler step of size dt (each SSP-RK stage is a convex combination of such steps). Conservative: the body books the scaled flux.
Definition at line 8395 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_ib_flux_wall_setup |
ib_flux_wall: allocate the wall fields, give each body's ghost points with a fluid face neighbor their wall area per face area, and report the wall area the faces carry. A planar wall of area A has sum|n_i| A of staircase faces, so each face carries 1/sum|n_i| of its own area.
Definition at line 8037 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_ib_wall_src_buffers |
ib_flux_wall: fill ib_wall_src's buffer cells from the neighbouring ranks or the periodic image; they stay zero (no wall) at other domain boundaries
Definition at line 8610 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_alloc_fine | ( | integer, intent(in) | nslots, |
| integer, intent(in) | f1_lo, | ||
| integer, intent(in) | f1_hi, | ||
| integer, intent(in) | f2_lo, | ||
| integer, intent(in) | f2_hi, | ||
| integer, intent(in) | f3_lo, | ||
| integer, intent(in) | f3_hi ) |
Allocate the per-slot fine-IB marker fields, sized to the max buffered fine extents; ghost-point lists start empty. No-op unless amr .and. ib.
Definition at line 6812 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_check_bodies_on_one_rank | ( | integer(kind=8), dimension(:), intent(in) | cnt | ) |
Abort if any one body has ghost points on more than one rank: the fine image-point stencil is exact only when a body's whole fine state lives on one rank. Counts are per global body, so bodies on different ranks are fine.
Definition at line 6944 of file m_ibm.fpp.f90.
| subroutine, public m_ibm::s_ibm_correct_state | ( | type(scalar_field), dimension(sys_size), intent(inout) | q_cons_vf, |
| type(scalar_field), dimension(sys_size), intent(inout) | q_prim_vf, | ||
| real(stp), dimension(idwbuff(1)%beg:,idwbuff(2)%beg:,idwbuff(3)%beg:,1:,1:), intent(inout) | pb_in, | ||
| real(stp), dimension(idwbuff(1)%beg:,idwbuff(2)%beg:,idwbuff(3)%beg:,1:,1:), intent(inout) | mv_in ) |
Update the conservative variables at the ghost points.
| [in,out] | q_cons_vf | Primitive Variables |
| [in,out] | q_prim_vf | Primitive Variables |
Host copies; amdflang reads Re_size stale cross-TU
Definition at line 2195 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_load_fine_markers | ( | integer, intent(in) | nb, |
| integer, dimension(nb), intent(in) | slots, | ||
| integer, dimension(3, nb), intent(in) | mext, | ||
| integer, intent(in) | sd, | ||
| integer, intent(in) | w ) |
Load ib_markers_fine for the next fine RHS pass: member ibm's fine markers (interior 0:mext(:, ibm)) land at offset (ibm - 1)*w along dimension sd; the rest of the installed frame reads 0, so padding and gaps zero nothing. Per-block callers pass nb = 1, w = 0. Grid globals must already be swapped.
Definition at line 6970 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_ibm_marker_bounds |
Compute the deepest-level marker-field bounds into mkr_lo/mkr_hi: the coarse block (m/n/p with ghosts) or the deepest fine block a rank can own, whichever is larger (a level-l block has amr_ref_ratio**l * base_ext - 1 interior cells per active dim, base_ext = the user footprint in coarse cells). Called from s_initialize_ibm_module and s_ibm_alloc_fine.
Definition at line 6791 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_note_fine_memory |
Note the fine IB state's memory for the end-of-run AMR table.
Definition at line 6843 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_ibm_rebuild_corrected_gps | ( | integer, intent(in) | n_g | ) |
Rebuild corrected_gps from the ghost-point list now in ghost_points: s_compute_interpolation_coeffs only sets entries, so clear the whole field and re-mark the valid ghost points on-device (same defaultmap treatment as the swap kernels).
Definition at line 7318 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_ibm_reserve_park | ( | integer, intent(in) | islot, |
| integer, intent(in) | n_f ) |
Give slot islot a gp_park segment for n_f ghost points at the pool top: exact for fixed bodies (the list keeps its length until s_ibm_reset_fine_park), full-length for moving bodies (so a slot never needs a second one, and a vacated one is reused).
Definition at line 7289 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_reset_fine_park |
Forget every slot's parked fine list (before the fine lists are rebuilt for the current block set).
Definition at line 6856 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_restore_from_fine | ( | integer, intent(in) | islot | ) |
Restore the coarse IB globals saved by s_ibm_swap_to_fine, parking the (possibly updated) fine state back in slot islot.
Definition at line 7154 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_setup |
Initializes the values of various IBM variables, such as ghost points and image points.
Definition at line 1180 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_setup_fine |
Compute the fine-grid IB state (markers, ghost points, levelset, image points, interpolation coeffs) for the current block, mirroring the static-body portion of s_ibm_setup. Grid globals must be swapped to the fine block and IB globals to this slot (s_ibm_swap_to_fine) first.
Definition at line 7411 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_swap_to_fine | ( | integer, intent(in) | islot, |
| logical, intent(in) | gps_on_device ) |
Swap the module IB globals (ib_markers/ghost_points/num_gps) to fine slot islot's state; the coarse state parks in the save slot. Pair with s_ibm_restore_from_fine; grid globals must already be swapped to the fine block.
| [in] | gps_on_device | fine ghost points already present on device (per-stage correct path) |
Definition at line 6999 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_ibm_tally_gps_by_body | ( | integer(kind=8), dimension(:), intent(inout) | cnt | ) |
Add to cnt(1:num_gbl_ibs) the ghost points each body has in the active list (the fine slot's when swapped in); counted on the device, since ghost_points never crosses to the host.
Definition at line 6877 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_initialize_ibm_module |
Allocates memory for the variables in the IBM module.
Definition at line 716 of file m_ibm.fpp.f90.
|
private |
Interpolate primitive variables to a ghost point's image point using bilinear or trilinear interpolation.
| [in] | q_prim_vf | Primitive Variables |
| [in,out] | ys_ip | Interpolated species mass fractions (chemistry) |
Definition at line 5128 of file m_ibm.fpp.f90.
|
private |
Fluid-masked image-point weights: bilinear for second-order IBM, else inverse distance squared.
| [in] | k | lower corner of the stencil |
Definition at line 5066 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_pick_bath_species | ( | real(wp), dimension(num_species), intent(in) | ys_s, |
| integer, intent(out) | k_bath ) |
Index of the most abundant species, i.e. the balance the sum constraint displaces.
Closing sum(Y) = 1 by dropping one species' flux balance is standard (Surface CHEMKIN), but the dropped species absorbs the roundoff of every other balance, so it must be the bath gas. Dropping a fixed index instead – the last species in the mechanism – lands that error on whatever the mechanism happens to list last, which for the reduced GRI mechanism shipped with the reacting-surface example is H2O2, a trace radical whose own surface balance then goes unenforced. Cantera's solveSP re-scans for the largest species each iteration (evalSurfLarge) for this reason.
Definition at line 8949 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_prescribed_kinematics | ( | integer, intent(in) | i, |
| real(wp), intent(in) | t ) |
Prescribed kinematics for patch i at time t: hinged flapping (kin_model = 1) or the Eldredge pitch ramp (kin_model = 2). Flapping rolls phi about the lab x axis through the hinge and pitches theta about the body spanwise (y) axis through it; the ramp holds phi at zero and drives theta alone. Both compose as R = Rx(phi) Ry(theta) (MFC's angle convention) and set the angles, centroid, velocity and lab-frame angular velocity; nothing is integrated, so restarts are exact.
Definition at line 5515 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_record_gp_surface | ( | integer, intent(in) | i, |
| type(ghost_point), intent(in) | gp, | ||
| real(wp), intent(in) | t_s, | ||
| real(wp), intent(in) | mdot_s, | ||
| logical, intent(in) | reacting ) |
Store ghost point i's surface record in gp_surf. The weight is the surface area the point stands for. Ghost points within two cell sizes h = dV^(1/d) of the surface fill a band of volume ~2hA, so dV/(2h) each sums to the area A (a length in 2D) whatever the surface's orientation to the grid. The band lies inside the solid, where a layer at depth s has area A (1 - s/R)^(d-1) on a curved surface; for circles, spheres and cylinders the weight is scaled back by (R/(R - s))^(d-1), which removes that bias (sampled on random lattice offsets: < 0.1% mean, 0.3% spread for a sphere at R = 12h). The factor is limited to R/(R - s) <= 2, so a body of only a few cells cannot give an infinite or negative weight.
Definition at line 3116 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_report_ibm_surface |
One line at the end of a run if the reacting surface ever failed to solve. Silence means every ghost point on every step reached the surface-balance tolerance, i.e. the surface chemistry was actually applied everywhere it was asked for.
Definition at line 3076 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_restore_centroid_offsets | ( | real(wp), intent(in) | t_init | ) |
On restart, replace the re-measured centroid offsets with the ones the run was using (restart_data/ib_offset_<step>.dat, written with each checkpoint), and re-place kinematics-driven bodies about them. No file: the measured offsets stand.
Definition at line 6143 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_setup_ib_force_comm |
Builds the ascending list of distinct neighborhood ranks used by s_communicate_ib_forces and allocates its buffers once. The ascending order is the fixed order in which an owner adds its neighbors' contributions.
Definition at line 6381 of file m_ibm.fpp.f90.
| pure subroutine m_ibm::s_sift_gp | ( | integer, dimension(:), intent(inout) | order, |
| integer(8), dimension(:), intent(in) | key, | ||
| integer, intent(in) | root, | ||
| integer, intent(in) | last ) |
Restore the max-heap rooted at root over order(1:last), comparing by key.
Definition at line 3939 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_solve_surface | ( | real(wp), intent(in) | pres, |
| real(wp), intent(in) | t_ip, | ||
| real(wp), intent(in) | t_wall, | ||
| real(wp), intent(in) | d, | ||
| real(wp), dimension(num_species), intent(in) | ys_ip, | ||
| real(wp), dimension(num_species), intent(in) | w_species, | ||
| integer, intent(in) | thermal_bc, | ||
| real(wp), dimension(num_species), intent(out) | ys_s, | ||
| real(wp), intent(out) | t_s, | ||
| real(wp), intent(out) | mdot_s, | ||
| logical, intent(out) | converged ) |
Newton solve for a reacting surface. thermal_bc=0: zero-normal-gradient T; 1: prescribed T; 2: energy balance.
Definition at line 8980 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_solve_surface_linear_system | ( | real(wp), dimension(num_species + 1, num_species + 1), intent(inout) | a, |
| real(wp), dimension(num_species + 1), intent(inout) | b, | ||
| real(wp), dimension(num_species + 1), intent(out) | x, | ||
| integer, intent(in) | nsolve, | ||
| logical, intent(out) | success ) |
Small dense linear solve with partial pivoting for the local surface Newton system.
Definition at line 9148 of file m_ibm.fpp.f90.
| pure subroutine m_ibm::s_sort_gps_by_location | ( | integer, dimension(:), intent(out), allocatable | order | ) |
Ghost-point indices ordered by grid location, so per-point output does not inherit the discovery order. s_find_ghost_points assigns slots from a GPU atomic, so that order is the thread schedule's and differs between CPU and GPU builds (MFlowCode/MFC#2039). Heapsort, since a GPU run's input is unordered and a particle array carries O(10^5) ghost points.
Definition at line 3912 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_surface_energy_residual | ( | real(wp), intent(in) | pres, |
| real(wp), intent(in) | t_ip, | ||
| real(wp), intent(in) | t_s, | ||
| real(wp), intent(in) | d, | ||
| real(wp), dimension(num_species), intent(in) | ys_s, | ||
| real(wp), intent(out) | r_energy ) |
Surface energy residual: gas-side conduction balances heterogeneous reaction heat. Radiation and solid-side conduction are omitted.
Definition at line 8761 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_surface_residual | ( | real(wp), intent(in) | pres, |
| real(wp), intent(in) | t_ip, | ||
| real(wp), intent(in) | t_s, | ||
| real(wp), intent(in) | d, | ||
| real(wp), dimension(num_species), intent(in) | ys_ip, | ||
| real(wp), dimension(num_species), intent(in) | ys_s, | ||
| real(wp), dimension(num_species), intent(in) | w_species, | ||
| integer, intent(in) | k_bath, | ||
| logical, intent(in) | solve_temperature, | ||
| real(wp), intent(in) | flux_scale, | ||
| real(wp), intent(in) | energy_scale, | ||
| real(wp), dimension(num_species + 1), intent(out) | r, | ||
| real(wp), dimension(num_species), intent(out) | r_species, | ||
| real(wp), dimension(num_species), intent(out) | omega_s, | ||
| real(wp), intent(out) | mdot_s ) |
Assemble the Newton residual for Ns species, with temperature appended only when it is solved. k_bath selects which species balance the sum constraint displaces; see s_solve_surface for why it must be the most abundant one.
Definition at line 8797 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_surface_species_residual | ( | real(wp), intent(in) | pres, |
| real(wp), intent(in) | t_s, | ||
| real(wp), intent(in) | d, | ||
| real(wp), dimension(num_species), intent(in) | ys_ip, | ||
| real(wp), dimension(num_species), intent(in) | ys_s, | ||
| real(wp), dimension(num_species), intent(in) | w_species, | ||
| real(wp), dimension(num_species), intent(out) | r_species, | ||
| real(wp), dimension(num_species), intent(out) | omega_s, | ||
| real(wp), intent(out) | mdot_s ) |
Species flux residual at a heterogeneous reacting surface.
Definition at line 8702 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_tsc_weights | ( | type(integer_field), intent(in) | markers, |
| real(wp), dimension(3), intent(in) | loc, | ||
| integer, dimension(3), intent(out) | ic, | ||
| real(wp), dimension(3, 3), intent(out) | wd, | ||
| real(wp), intent(out) | fluid_frac ) |
Triangular-shaped-cloud (quadratic B-spline) weights of a point on the 3x3(x3) stencil centred on the cell nearest to it (Ezra, Peles & Kozak 2025, Int. J. Heat Mass Transf. 252:127314), and the fraction of that weight carried by fluid cells. The kernel is a partition of unity and smooth across cell boundaries, so an interpolated wall quantity converges one order faster than from inverse-distance or bilinear weights, which are only continuous. The weights use the fractional position in the bracketing cell at integer offsets, which keeps the partition of unity exactly on a stretched grid. The stencil is kept inside the halo. Solid cells in it carry the ghost values of the last correction (see ib_keep_ghost); a point buried in a body has no fluid weight.
| [in] | markers | ib_markers, passed so the device routine reads the caller's present copy |
| [out] | ic | Cell centring the stencil |
| [out] | wd | 1D weights on ic - 1, ic, ic + 1, per direction |
Definition at line 4770 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_update_ib_rotation_matrices | ( | integer, intent(in) | num_ibs | ) |
Resets the current indexes of immersed boundaries and replaces them after updating the position of each moving immersed boundary Recalculate the moving bodies' rotation matrices from their current angles (device).
Definition at line 5347 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_update_ib_temperatures | ( | real(wp), intent(in) | dt_step | ) |
Advance the temperature of each thermal_bc = 3 IB over one step, treating it as one lumped body (small Biot number). With E_solid = m c_s (T - T_ref), the step's face energy in from s_accumulate_ib_face_fluxes and the gasification rate from the surface solve, m c_s dT/dt = Q_in + c_s (T - T_ref) Mdot_out + heat_power - emissivity sigma A (T^4 - T_rad^4). Mdot_out is the solid's mass loss: the face mass sum also carries the ghost cells' non-conservation (a net inflow on a reacting cylinder). T_ref = 298.15 K is the reference of the formation enthalpies, so the gas energy the solid's lost carbon carries is consistent. The step is explicit: the body's thermal time m c_s/(h A) is many orders of magnitude longer than a flow step. For D/ib_heat.dat every body also keeps its gasification rate, face mass out and fluid heat in, Q_in (+ the c_s term for thermal_bc = 3), in patch_ibmdot, mdot_face and qdot.
Definition at line 3285 of file m_ibm.fpp.f90.
| impure subroutine m_ibm::s_update_mib | ( | integer, intent(in) | num_ibs | ) |
Definition at line 5394 of file m_ibm.fpp.f90.
|
private |
Probes and Lagrange weights of the quadratic wall-normal fill of a ghost point. The wall is at s = 0, the probes at s1 and s2 = 2 s1 along the surface normal from the wall foot, the ghost at s = -d (d = |levelset|):
phi_g = L0 phi_w + L1 phi_1 + L2 phi_2 L0 = (d + s1)(d + s2)/(s1 s2), L1 = -d (d + s2)/(s1 (s2 - s1)), L2 = d (d + s1)/(s2 (s2 - s1))
L0 + L1 + L2 = 1 and at d = 0 they reduce to (1, 0, 0), so the wall value is exact on the wall. s1 = max(h, d) bounds the weights by (3, -3, 1) at any ghost depth. Tier 1 uses both probes; tier 2 is the linear mirror where the outer probe has too little fluid around it (a narrow gap, a rim, a neighbouring body); tier 3 leaves the default treatment.
Definition at line 4963 of file m_ibm.fpp.f90.
| subroutine m_ibm::s_wrap_periodic_ibs |
Wrap immersed boundary positions across periodic domain boundaries.
Definition at line 6262 of file m_ibm.fpp.f90.
| impure subroutine, public m_ibm::s_write_ib_surface | ( | integer, intent(in) | save_count | ) |
Write this rank's surface records to D/ib_surface_<rank>_<save>.dat, one line per weighted ghost point.
Definition at line 3176 of file m_ibm.fpp.f90.
| logical m_ibm::centroid_offsets_active = .false. |
some patch is a moving airfoil or STL, which carries a centroid_offset
Definition at line 689 of file m_ibm.fpp.f90.
| type(integer_field) m_ibm::corrected_gps |
1 at ghost points whose image point reaches the fluid, 0 elsewhere. Ghost points with a buried image point average over these neighbors, and never over each other.
Definition at line 502 of file m_ibm.fpp.f90.
| type(ghost_point), dimension(:), allocatable m_ibm::ghost_points |
Definition at line 516 of file m_ibm.fpp.f90.
| real(wp), dimension(:,:), allocatable m_ibm::gp_prim_new |
New primitive state per ghost point, staged so it is published only after every image-point stencil has been read (MFlowCode/MFC#1901). Writing q_prim inside the same loop that reads it at neighboring image-point stencils makes a ghost's result depend on whether its neighbors were updated first. Inverse-distance weights mask solid cells, so the race is latent there; a stencil that reads ghost cells (ib_ip_interp = 2) needs it.
Definition at line 522 of file m_ibm.fpp.f90.
| integer, dimension(:), allocatable m_ibm::gp_slab |
per-i-slab ghost-point counts/offsets for the ordered gather (AMR)
Definition at line 536 of file m_ibm.fpp.f90.
| real(wp), dimension(:,:), allocatable m_ibm::gp_surf |
Definition at line 554 of file m_ibm.fpp.f90.
| logical, public m_ibm::ib_exchange = .false. |
ib_heat is accumulated: some IB has thermal_bc = 3, ib_heat_wrt or ib_mass_relax
Definition at line 593 of file m_ibm.fpp.f90.
| real(wp), dimension(:,:), allocatable m_ibm::ib_face_ft |
Force (1:3) and torque (4:6) on each local IB from the fluid-body face fluxes of the last RHS evaluation.
Definition at line 699 of file m_ibm.fpp.f90.
| real(wp), dimension(:,:), allocatable m_ibm::ib_heat |
Per global IB, for the thermal_bc = 3 update and ib_heat_wrt: (1) surface area and (4) gasification rate, from gp_surf; (2) energy into the solid and (3) mass out of it, both summed over the faces between the body's cells and fluid cells with the RK stage weights, so over a step they are exactly the energy and mass the fluid exchanged with the body.
Definition at line 610 of file m_ibm.fpp.f90.
| integer m_ibm::ib_ip_width |
Cells per direction in the image-point interpolation stencil: 2 (inverse distance, bilinear) or 3 (TSC).
Definition at line 674 of file m_ibm.fpp.f90.
| logical m_ibm::ib_keep_ghost |
The interpolation or the wall probes read solid cells, so ghost cells keep the last correction.
Definition at line 675 of file m_ibm.fpp.f90.
| type(integer_field), public m_ibm::ib_markers |
Definition at line 469 of file m_ibm.fpp.f90.
| type(integer_field), public m_ibm::ib_markers_fine |
Body markers in the fine-advance frame, read by s_compute_rhs's body-cell RHS zeroing while amr_in_fine_advance: the advanced block's fine markers (for a batch, every member's at its slab offset), loaded by s_ibm_load_fine_markers before each fine RHS pass. ib_markers holds the coarse markers during a fine RHS. Interior-only, sized to the allocation extents.
Definition at line 486 of file m_ibm.fpp.f90.
| type(integer_field) m_ibm::ib_markers_prev |
Definition at line 629 of file m_ibm.fpp.f90.
| real(wp), dimension(:,:), allocatable m_ibm::ib_mass_res |
ib_mass_relax, per global IB: (1) gas mass gained from the body beyond its gasification and not yet returned, (2) the share released this step; ib_shell_mass: gas mass of the body's shell. ib_shell: global IB id of each fluid cell within ib_shell_width cells of a body, else 0. ib_markers_prev: markers at the last placement of a moving body (s_add_swept_cells).
Definition at line 627 of file m_ibm.fpp.f90.
|
private |
Definition at line 694 of file m_ibm.fpp.f90.
|
private |
gbl_patch_id, force(1:3), torque(1:3)
Definition at line 692 of file m_ibm.fpp.f90.
|
private |
Definition at line 695 of file m_ibm.fpp.f90.
|
private |
Definition at line 694 of file m_ibm.fpp.f90.
|
private |
Definition at line 695 of file m_ibm.fpp.f90.
|
private |
Definition at line 694 of file m_ibm.fpp.f90.
| type(integer_field) m_ibm::ib_shell |
Definition at line 629 of file m_ibm.fpp.f90.
| real(wp), dimension(:,:), allocatable m_ibm::ib_shell_mass |
Definition at line 628 of file m_ibm.fpp.f90.
| integer, parameter m_ibm::ib_shell_width = 2 |
Definition at line 630 of file m_ibm.fpp.f90.
|
private |
Definition at line 694 of file m_ibm.fpp.f90.
| integer, parameter m_ibm::ib_surf_nvars = 3 |
Surface record per ghost point from the latest s_ibm_correct_state, kept when ib_surface_wrt: (1) area weight, (2) wall temperature, (3) gasified mass flux. Only ghost points within two cells of the surface carry a weight, so summing weight*flux over them integrates over the surface; see s_record_gp_surface.
Definition at line 553 of file m_ibm.fpp.f90.
| logical m_ibm::ib_wall_quad |
ib_wall_order = 2: quadratic wall-normal ghost velocity at no-slip walls
Definition at line 676 of file m_ibm.fpp.f90.
| type(scalar_field), dimension(ibw_a), public m_ibm::ib_wall_src |
Definition at line 576 of file m_ibm.fpp.f90.
| type(scalar_field), public m_ibm::ib_wall_theta |
Definition at line 577 of file m_ibm.fpp.f90.
| integer, parameter, public m_ibm::ibw_a = num_species + 5 |
Definition at line 573 of file m_ibm.fpp.f90.
| integer, parameter, public m_ibm::ibw_e = num_species + 1 |
ib_flux_wall: per ghost point with a fluid face neighbor of a body, from its surface solve (zero for an inert body), the species mass fluxes into the gas (1:num_species), the energy flux (ibw_e), the blowing velocity (ibw_u:ibw_u + 2) and the wall area per face area, 1/sum|n_i| (ibw_a, 0 off a wall); ib_wall_theta: each fluid cell's positivity factor on its wall faces' rates
Definition at line 572 of file m_ibm.fpp.f90.
| integer, parameter, public m_ibm::ibw_u = num_species + 2 |
Definition at line 572 of file m_ibm.fpp.f90.
| logical m_ibm::moving_immersed_boundary_flag |
Definition at line 672 of file m_ibm.fpp.f90.
| integer, dimension(3) m_ibm::n_fill_tier = 0 |
Ghost-point updates per fill tier, summed over the run and reported at its end, because a tight packing can sit mostly in tier 2 and a second-order claim is then not true of that surface.
Definition at line 468 of file m_ibm.fpp.f90.
|
private |
Definition at line 693 of file m_ibm.fpp.f90.
| integer m_ibm::n_surface_ill_posed = 0 |
Ghost points whose levelset distance was not positive, leaving the surface gradient (X_IP - X_s)/d undefined. Separate from the counter above because this is a grid/geometry degeneracy, not a kinetics failure.
Definition at line 454 of file m_ibm.fpp.f90.
| integer m_ibm::n_surface_not_converged = 0 |
Ghost points at which the reacting-surface Newton solve did not reach its tolerance, so the point fell back to a chemically inert wall (keeping a prescribed Twall). Counted because that fallback is otherwise indistinguishable from a surface mechanism that simply does nothing, and a run can look converged while the surface chemistry never engaged.
Definition at line 450 of file m_ibm.fpp.f90.
| integer, public m_ibm::num_gps |
Number of ghost points.
Definition at line 644 of file m_ibm.fpp.f90.
| logical m_ibm::record_surface |
gp_surf is filled when it is written (ib_surface_wrt) or integrated (ib_exchange).
Definition at line 592 of file m_ibm.fpp.f90.