Repository navigation
Conversation
decomposition_generic gave every rank global_vert_dims/nproc_dir vertices, which silently drops the remainder when the count does not divide. A non-periodic direction has one vertex more than cells, so its vertices and its cells can never both divide by the rank count: a non-periodic direction split over ranks (the CUDA backend, which never uses 2decomp) always lost vertices or held unequal cells. 129 z vertices on 2 ranks gave 64 cells on rank 0 and 63 on rank 1, 127 instead of 128. split_points now splits each direction the way decomp_2d_init does with the periodicity flags: the cells as evenly as possible, the remainder on the last ranks, and the extra vertex of a non-periodic direction on the last rank. A non-periodic direction of P*m cells gives every rank m cells, and both decompositions hand a rank the same range. A periodic direction whose count divides is split as before. test_mesh pinned the old generic split ([4, 4, 4, 4] vertices for 15 cells on 4 ranks); both decompositions now give [3, 4, 4, 5].
Non-periodic x, y and z now run on the OpenMP and CUDA backends, on one rank
and on several. As in Incompact3d's poisson_11x, 110 and 111 share one
solver type per backend (omp_poisson_11x_t, cuda_poisson_11x_t), with the
same (nz/2+1, nx, ny) spectral layout, plans, buffers and spectral kernels.
111 differs in three places:
- z is folded (odd entries ascending, even descending) so that the r2c
transform along z stands in for a cosine transform. The fold rides in the
copies that already move z into and out of the transform buffer: the z
transpose on one rank, the z-pencil (OpenMP) or the cuFFTMp Y-slab unpack
and pack (CUDA) on several. A 111 solve costs the same as a 110 one.
- az, bz take the half-angle form of a non-periodic direction, which
wave_numbers already gives.
- The imaginary part of waves takes the mirrored z mode N - k: the r2c of the
folded line, after the half-shift twiddle, holds C_k - i C_{N-k}.
waves_set builds waves from the 1D factors of each spectral dimension
instead of one 3D loop nest per layout: the expression is symmetric in the
directions, so one loop serves every case, and the mirrored mode is a
per-dimension detail. stretching_matrix shares the interpolation transfer
function. On the existing cases the analytic errors of test_poisson_bc are
unchanged and the other checks move by round-off only.
FFT_BC_111 and fft_bc_is_11x classify the case for the CUDA helpers and
x3d2-memcheck, which treat it as 110. The CUDA case on several ranks needs
the z cell count to divide by the rank count.
test_poisson_bc gains ddd and ddd_odd, on one rank for both backends, and
ddd on two ranks with a z split (both) and a y split (OpenMP). Its mode test
now removes the mean of its right-hand side, which is not zero with odd cell
counts in x and in a non-periodic z.
field_set_y_face located the top face at group b + (ny - 1)/SZ*nz with nz the z count of the field's own data_loc. The DIR_X group stride is the padded z count of the allocator. On a non-periodic z, a cell field holds one z station fewer than vertices on the last rank, so its top y face went to the wrong groups there. The launch still covers the field's own z stations, and only the stride changes. Vertex fields, and periodic z, were not affected. The OpenMP backend already used the padded stride. test_boundary_planes runs its cell-field Y_FACE check on a non-periodic z from the next commit, which is what exposed this.
Free-slip z walls need the impermeability stamp w = 0 on the z faces and an outlet flow-rate balance weighted along z, as #440 weighted it along y. field_set_face now sets Z_FACE on the OpenMP, CUDA and OpenMP-target backends. Unlike y, z is decomposed, so a face is set only by the rank that holds it, the first or the last along z (z_face_owned, shared by the three backends), and on a cell field the top face is its last local z station. A non-Dirichlet bc_start or bc_end leaves that face alone, as for Y_FACE. x_slice_weighted_sum takes optional z_weights, a weight per local z station on top of the y weights (z_weight_line gives 1 when absent), and outflow_flow_rate_correction passes them through. test_boundary_planes splits z over the ranks with free-slip walls and runs on one and on two ranks. It checks both Z_FACE planes, the Neumann bottom, a cell field, and the z-weighted sum.
Incompact3d's two_turbines example has free-slip walls in y and z (ncly1 = nclyn = nclz1 = nclzn = 1), which the 111 Poisson case now supports. BC_y and BC_z may each be 'periodic' or 'neumann' at both ends. apply_BC follows Incompact3d's pre_correc: Dirichlet inflow and convective outflow on the x faces, then v = 0 on the y walls and w = 0 on the z walls, stamped last so they win on the edges. The outlet mass correction balances the flow rates as the discrete divergence sees them, with trapezoid weights along a walled direction (outflow_flow_rate_correction), in place of the plain mean over the planes. For periodic y and z every weight is 1 and the correction is the plain mean as before. With walls the plain mean, which Incompact3d uses, leaves a uniform divergence that the Neumann-x projection cannot remove (about 6e-4 in the y-wall two_turbines run). The weighted one keeps div(u) at round-off. y walls need y not decomposed: field_set_face stamps the local y planes.
The two_turbines setup it reproduces has free-slip walls in y and z. With the 111 Poisson solver and wall support in wind_turbine, the example now uses the same boundaries and grid (641 x 129 x 321).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #449.
Adds the
111case, where x, y and z are all non-periodic, to the FFT Poisson solver on the OMP and CUDA backends. Thewind_turbinecase can now have free-slip walls in y and z.Poisson 111
Like Incompact3d's
poisson_11x,111reuses the whole110path. The z direction is folded before the transform and unfolded after it, in the copies that already hold z whole:z_dstmap in ther_trtransposes.fold_zflag intranspose_xyz_to_zxy/transpose_zxy_to_xyzandunpack_110_yslab/pack_110_yslab.The solver types are renamed
omp_poisson_11x_tandcuda_poisson_11x_t.fft_bc_is_11xreplaces the== '110'checks.The real-to-complex transform of a folded line gives C_k − i·C_{N−k}. So the imaginary part of the modified wavenumbers has to use the mirrored z mode N−k.
waves_setis rebuilt from 1D factors per spectral direction (spectral_line,interp_transfer), with one loop for all cases. The existing cases are unchanged: analytic errors are identical tomain, and other differences are at 1e-13 round-off.111costs the same as110. On a 256³ grid with the CUDA backend, a solve takes 14.3 ms vs 14.4 ms on 1 GPU and 77.6 ms vs 77.3 ms on 2 GPUs.Fixes found on the way (separate commits)
08e286e8). It usedglobal_vert_dims / nproc_dir, so a non-divisible count lost points, and a split non-periodicdirection could not have uniform cells. A 2-GPUdddrun failed with MPI "Message truncated". It now splits cells as 2decomp does, with the extra vertex on the last rank.test_meshnow expects the same split from both decompositions.Y_FACEused the unpadded z stride (f2f22feb). On cell fields withnon-periodic z, the top y face was written to the wrong groups. Vertex fields and periodic z were not affected.Walls in z (
aa37baf2,a2c7c80b)field_set_facenow supportsZ_FACEon OMP, CUDA and OMP_TGT. It stamps only on the first or last z rank, and only for Dirichlet.x_slice_weighted_sumtakes optional z weights. The outflow flux balance from#440 now uses trapezoid weights in both y and z.wind_turbineaccepts Neumann (free-slip) y and z boundaries. It sets v = 0 on the y walls and w = 0 on the z walls, and uses the weighted outlet balance. Y walls currently requirenproc_dir(2) = 1.examples/wind_turbine_almnow uses these walls on the 641×129×321 grid, matching thetwo_turbinessetup it reproduces (addde8e5). Before, it was periodicin y and z on 641×128×320.Tests
test_poisson_bchas two new111cases,ddd(65×65×129) andddd_odd(82×82×82). They run on 1 and 2 ranks, plus a y-split run on OMP.test_boundary_planesnow runs with z walls on 1 and 2 ranks. It covers the z-weighted sum andZ_FACEon vertex and cell fields.OMP_TGT has no FFT Poisson solver, so
111is not available there. The OMP_TGTZ_FACEand z-weight kernels were not compiled or run, because no OMP_TGT build was available.Validation: two turbines with y and z walls vs Incompact3d
The case is the
two_turbinesALM example on a 641×129×321 grid with free-slip y and z walls, run for 10,000 steps on 2 GPUs. The reference is unmodified Incompact3d with the same walls. Divergence stays at about 5e-12 throughout.Mean loads over t = 1–2 s, compared with Incompact3d. The noise column is how much Incompact3d's own loads change when the z walls are removed.
Turbine 2's torque is small (about −0.23 N·m), so −0.93% is a difference of 0.002 N·m.
Wake profiles of mean u and u′ within one rotor diameter of the axis:
Both differences are the size of the sampling noise of a 1 s average.
Notes for reviewers
X_FACEkernel has the same stride pattern as the oldY_FACEkernel. It is only called on vertex fields, where it is correct, so it is left unchanged.