Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rotation and MPI for multiple IBs #788

Merged
merged 1 commit into from
Jan 10, 2025

Conversation

haochey
Copy link
Contributor

@haochey haochey commented Jan 9, 2025

Description

Fixes issue #787

This PR fixes two bugs:

  1. The rotation of STL patches and STL immersed boundaries.
  • Why not working?
    (a) The normal vector of the triangular facets are not rotated with the vertices. The ray-tracing become erroneous when
    the unrotated normal vectors are used.
    (b) The rotation did not consider the original center of the geometry is not at the origin of the coordinate.

  • What's the fix?
    (a) Include the normal vector in the process of the model transformation, but skip the scale and translation parts.
    (b) Shift the geometry to the origin before rotation and shift it back to its original position after the rotation.

  1. MPI communication for >1 number of IBs. (a two-line fix that's left over from the IBM+STL PR).

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Scope

  • This PR comprises a set of related changes with a common goal

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.
Provide instructions so we can reproduce.
Please also list any relevant details for your test configuration

Test Configuration:

import json
import math
gam_a = 1.4
D = 2
Ma = 4
vel = Ma * math.sqrt(gam_a) 
tStop = 20/vel
print(
    json.dumps(
        {
            "run_time_info": "T",
            "x_domain%beg": -4,
            "x_domain%end": 8,
            "stretch_x" : 'T',
            'a_x': 20,
            'x_a': -10,
            'x_b': 6,
            "y_domain%beg": -3,
            "y_domain%end": 3,
            "stretch_y" : 'T',
            'a_y': 15,
            'y_a': -1.75,
            'y_b': 1.75,
            'loops_y': 2,
            "z_domain%beg": -3,
            "z_domain%end": 3,
            "stretch_z" : 'T',
            'a_z': 15,
            'z_a': -1.75,
            'z_b': 1.75,
            'loops_z': 2,
            "cyl_coord": "F",
            "m": 99,
            "n": 49,
            "p": 49,
            'cfl_adap_dt' : 'F', #'T',
            'n_start'     : 0,
            'cfl_target'  : 0.8,
            't_step_start': 0,
            't_step_stop' : 1, #tStop,
            't_step_save' : 1, #tStop/100,
            'dt' : 1e-9,
            't_stop'      : 1, #tStop,
            't_save'      : 1, #tStop/100,
            "num_patches": 1,
            "model_eqns": 2,
            "alt_soundspeed": "F",
            "num_fluids": 1,
            "mpp_lim": "F",
            "mixture_err": "F",
            "time_stepper": 3,
            "weno_order": 5,
            "weno_eps": 1.0e-16,
            "weno_Re_flux": "F",
            "weno_avg": "T",
            "avg_state": 2,
            "mapped_weno": "F",
            "null_weights": "F",
            "mp_weno": "F",
            "riemann_solver": 2,
            "wave_speeds": 1,
            "viscous": "F",
            "bc_x%beg": -3,
            "bc_x%end": -3,
            "bc_y%beg": -3,
            "bc_y%end": -3,
            "bc_z%beg": -3,
            "bc_z%end": -3,
            "ib": "T",
            "num_ibs": 1,
            "format": 1,
            "precision": 2,
            "prim_vars_wrt":'T',
            "parallel_io": "T",
            "patch_icpp(1)%geometry": 9,
            "patch_icpp(1)%x_centroid": 0.0,
            "patch_icpp(1)%y_centroid": 0.0,
            "patch_icpp(1)%z_centroid": 0.0,
            "patch_icpp(1)%length_x": 100,
            "patch_icpp(1)%length_y": 50,
            "patch_icpp(1)%length_z": 50,
            "patch_icpp(1)%vel(1)": vel,
            "patch_icpp(1)%vel(2)": 0,
            "patch_icpp(1)%vel(3)": 0,
            "patch_icpp(1)%pres": 1,
            "patch_icpp(1)%alpha_rho(1)": 1,
            "patch_icpp(1)%alpha(1)": 1,
            "patch_ib(1)%geometry": 12,
            "patch_ib(1)%model_filepath": "vehicle.stl",
            "patch_ib(1)%model_translate(1)": 3,
            "patch_ib(1)%model_translate(2)": 0,
            "patch_ib(1)%model_translate(3)": 0,
            "patch_ib(1)%model_rotate(3)": -0.5*math.pi,
            "patch_ib(1)%model_spc": 20,
            "patch_ib(1)%model_threshold": 0.01,
            "patch_ib(1)%slip": "F",
            "fluid_pp(1)%gamma": 1.0e00 / (gam_a - 1.0e00),
            "fluid_pp(1)%pi_inf": 0,
        }
    )
)

Without rotation and translation:
Screen Shot 2025-01-08 at 10 37 42 PM

With rotation and translation:
Screen Shot 2025-01-08 at 10 30 01 PM

  • What computers and compilers did you use to test this: MacOS with GCC

Checklist

  • I have added comments for the new code
  • I ran ./mfc.sh format before committing my code
  • New and existing tests pass locally with my changes, including with GPU capability enabled (both NVIDIA hardware with NVHPC compilers and AMD hardware with CRAY compilers) and disabled
  • This PR does not introduce any repeated code (it follows the DRY principle)
  • I cannot think of a way to condense this code and reduce any introduced additional line count

If your code changes any code source files (anything in src/simulation)

To make sure the code is performing as expected on GPU devices, I have:

  • Checked that the code compiles using NVHPC compilers

@haochey haochey requested a review from a team as a code owner January 9, 2025 03:39
@haochey haochey added the bug Something isn't working or doesn't seem right label Jan 9, 2025
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 44.44444% with 10 lines in your changes missing coverage. Please review.

Project coverage is 43.76%. Comparing base (bae121f) to head (ad01abf).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/common/m_helper.fpp 23.07% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #788      +/-   ##
==========================================
- Coverage   43.79%   43.76%   -0.04%     
==========================================
  Files          65       65              
  Lines       19055    19047       -8     
  Branches     2326     2324       -2     
==========================================
- Hits         8345     8335      -10     
- Misses       9302     9305       +3     
+ Partials     1408     1407       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sbryngelson sbryngelson merged commit 6c69026 into MFlowCode:master Jan 10, 2025
28 checks passed
@sbryngelson sbryngelson linked an issue Jan 10, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working or doesn't seem right
Development

Successfully merging this pull request may close these issues.

STL immersed boundaries don't work with an applied rotation
2 participants