-
Notifications
You must be signed in to change notification settings - Fork 130
Periodic Immersed Boundary Wrapping for Circular and Spherical Geometries #1117
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
Open
conraddelgado
wants to merge
8
commits into
MFlowCode:master
Choose a base branch
from
conraddelgado:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,076
−70
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8906810
periodic ib wrapping for spheres
conraddelgado 837b18b
periodic ib wrap for circle geometry + tests
conraddelgado 3441ef4
Merge branch 'MFlowCode:master' into master
conraddelgado 6338eea
formatting
conraddelgado 1aa4b08
Merge branch 'master' of github.com:conraddelgado/periodic_ibs
conraddelgado 8571caf
regenerate test data, gpu update
conraddelgado 85903b3
formatting
conraddelgado 067a337
r2 on GPU
conraddelgado File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| import json | ||
| import math | ||
| import numpy as np | ||
|
|
||
| gam_a = 1.4 | ||
|
|
||
| # sphere diameter | ||
| D = 0.1 | ||
|
|
||
| # circle density | ||
| rho_c = 200 | ||
|
|
||
| # domain length | ||
| L = 10 * D | ||
|
|
||
| # mach number | ||
| M = 1.2 | ||
|
|
||
| # reynolds number | ||
| Re = 400.0 | ||
|
|
||
| # pressure | ||
| P = 101325 | ||
|
|
||
| # density | ||
| rho = 1.0 | ||
|
|
||
| # fluid velocity | ||
| v1 = M * np.sqrt(gam_a * P / rho) | ||
|
|
||
| # dynamic viscosity | ||
| mu = rho * v1 * D / Re | ||
|
|
||
| dt = 1.0e-06 | ||
| Nt = 5000 | ||
| t_save = 20 | ||
|
|
||
| # to fully resolve requires 40-60 cells across sphere diameter | ||
| Nx = 511 | ||
| Ny = Nx | ||
| Nz = 0 | ||
|
|
||
| # immersed boundary dictionary | ||
| ib_dict = {} | ||
| ib_dict.update( | ||
| { | ||
| f"patch_ib({1})%geometry": 2, | ||
| f"patch_ib({1})%x_centroid": 0.5 * L, | ||
| f"patch_ib({1})%y_centroid": 0.5 * L, | ||
| f"patch_ib({1})%radius": D / 2, | ||
| f"patch_ib({1})%slip": "F", | ||
| f"patch_ib({1})%moving_ibm": 0, | ||
| f"patch_ib({1})%mass": rho_c * np.pi * (D / 2.0) ** 2, | ||
| } | ||
| ) | ||
|
|
||
| # Configuring case dictionary | ||
| case_dict = { | ||
| # Logistics | ||
| "run_time_info": "T", | ||
| # Computational Domain Parameters | ||
| # x direction | ||
| "x_domain%beg": -5.0 * D, | ||
| "x_domain%end": 5.0 * D, | ||
| # y direction | ||
| "y_domain%beg": -5.0 * D, | ||
| "y_domain%end": 5.0 * D, | ||
| "cyl_coord": "F", | ||
| "m": Nx, | ||
| "n": Ny, | ||
| "p": Nz, | ||
| "dt": dt, | ||
| "t_step_start": 0, | ||
| "t_step_stop": Nt, | ||
| "t_step_save": t_save, | ||
| # Simulation Algorithm Parameters | ||
| # Only one patch is necessary for one fluid | ||
| "num_patches": 1, | ||
| # Use the 5 equation model | ||
| "model_eqns": 2, | ||
| # 6 equations model does not need the K \div(u) term | ||
| "alt_soundspeed": "F", | ||
| # One fluids: air | ||
| "num_fluids": 1, | ||
| # time step | ||
| "mpp_lim": "F", | ||
| # Correct errors when computing speed of sound | ||
| "mixture_err": "T", | ||
| # Use TVD RK3 for time marching | ||
| "time_stepper": 3, | ||
| # Reconstruct the primitive variables to minimize spurious | ||
| # Use WENO5 | ||
| "weno_order": 5, | ||
| "weno_eps": 1.0e-14, | ||
| "weno_Re_flux": "T", | ||
| "weno_avg": "T", | ||
| "avg_state": 2, | ||
| "mapped_weno": "T", | ||
| "null_weights": "F", | ||
| "mp_weno": "T", | ||
| "riemann_solver": 2, | ||
| "wave_speeds": 1, | ||
| # periodic bc | ||
| "bc_x%beg": -1, | ||
| "bc_x%end": -1, | ||
| "bc_y%beg": -1, | ||
| "bc_y%end": -1, | ||
| # Set IB to True and add 1 patch for every sphere | ||
| "ib": "T", | ||
| "num_ibs": 1, | ||
| "viscous": "T", | ||
| # Formatted Database Files Structure Parameters | ||
| "format": 1, | ||
| "precision": 2, | ||
| "prim_vars_wrt": "T", | ||
| "E_wrt": "T", | ||
| "parallel_io": "T", | ||
| # Patch: square filled with air | ||
| "patch_icpp(1)%geometry": 3, | ||
| # Uniform properties, centroid is at the center of the domain | ||
| "patch_icpp(1)%x_centroid": 0.0, | ||
| "patch_icpp(1)%y_centroid": 0.0, | ||
| "patch_icpp(1)%length_x": 10 * D, | ||
| "patch_icpp(1)%length_y": 10 * D, | ||
| # Specify the patch primitive variables | ||
| "patch_icpp(1)%vel(1)": v1, | ||
| "patch_icpp(1)%vel(2)": 0.0, | ||
| "patch_icpp(1)%pres": P, | ||
| "patch_icpp(1)%alpha_rho(1)": rho, | ||
| "patch_icpp(1)%alpha(1)": 1.0e00, | ||
| # Fluids Physical Parameters | ||
| "fluid_pp(1)%gamma": 1.0e00 / (gam_a - 1.0e00), # 2.50(Not 1.40) | ||
| "fluid_pp(1)%pi_inf": 0, | ||
| "fluid_pp(1)%Re(1)": 1.0 / mu, | ||
| # ibs wrap around domain | ||
| "periodic_ibs": "T", | ||
| } | ||
|
|
||
| case_dict.update(ib_dict) | ||
|
|
||
| print(json.dumps(case_dict)) | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,150 @@ | ||
| import json | ||
| import math | ||
| import numpy as np | ||
|
|
||
| gam_a = 1.4 | ||
|
|
||
| # sphere diameter | ||
| D = 0.1 | ||
|
|
||
| # sphere density | ||
| rho_s = 200 | ||
|
|
||
| # domain length | ||
| L = 10 * D | ||
|
|
||
| # mach number | ||
| M = 1.2 | ||
|
|
||
| # reynolds number | ||
| Re = 400.0 | ||
|
|
||
| # pressure | ||
| P = 101325 | ||
|
|
||
| # density | ||
| rho = 1.0 | ||
|
|
||
| # fluid velocity | ||
| v1 = M * np.sqrt(gam_a * P / rho) | ||
|
|
||
| # dynamic viscosity | ||
| mu = rho * v1 * D / Re | ||
|
|
||
| dt = 2.0e-06 | ||
| Nt = 2000 | ||
| t_save = Nt // 250 | ||
|
|
||
| # to fully resolve requires 40-60 cells across sphere diameter | ||
| Nx = 127 | ||
| Ny = Nx | ||
| Nz = Ny | ||
|
Comment on lines
+38
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the resolution comment with the chosen grid. With L=1 and Nx=127, the sphere diameter spans ~13 cells, not 40–60. Consider updating the comment to avoid confusion. 💡 Suggested comment tweak-# to fully resolve requires 40-60 cells across sphere diameter
+# NOTE: fully resolving needs 40–60 cells across diameter; this example uses ~13 for faster runs🤖 Prompt for AI Agents |
||
|
|
||
| # immersed boundary dictionary | ||
| ib_dict = {} | ||
| ib_dict.update( | ||
| { | ||
| f"patch_ib({1})%geometry": 8, | ||
| f"patch_ib({1})%x_centroid": 0.5 * L, | ||
| f"patch_ib({1})%y_centroid": 0.5 * L, | ||
| f"patch_ib({1})%z_centroid": 0.5 * L, | ||
| f"patch_ib({1})%radius": D / 2, | ||
| f"patch_ib({1})%slip": "F", | ||
| f"patch_ib({1})%moving_ibm": 0, | ||
| f"patch_ib({1})%mass": rho_s * 4.0 / 3.0 * np.pi * (D / 2.0) ** 3, | ||
| } | ||
| ) | ||
|
|
||
| # Configuring case dictionary | ||
| case_dict = { | ||
| # Logistics | ||
| "run_time_info": "T", | ||
| # Computational Domain Parameters | ||
| # x direction | ||
| "x_domain%beg": -5.0 * D, | ||
| "x_domain%end": 5.0 * D, | ||
| # y direction | ||
| "y_domain%beg": -5.0 * D, | ||
| "y_domain%end": 5.0 * D, | ||
| # z direction | ||
| "z_domain%beg": -5.0 * D, | ||
| "z_domain%end": 5.0 * D, | ||
| "cyl_coord": "F", | ||
| "m": Nx, | ||
| "n": Ny, | ||
| "p": Nz, | ||
| "dt": dt, | ||
| "t_step_start": 0, | ||
| "t_step_stop": Nt, | ||
| "t_step_save": t_save, | ||
| # Simulation Algorithm Parameters | ||
| # Only one patch is necessary for one fluid | ||
| "num_patches": 1, | ||
| # Use the 5 equation model | ||
| "model_eqns": 2, | ||
| # 6 equations model does not need the K \div(u) term | ||
| "alt_soundspeed": "F", | ||
| # One fluids: air | ||
| "num_fluids": 1, | ||
| # time step | ||
| "mpp_lim": "F", | ||
| # Correct errors when computing speed of sound | ||
| "mixture_err": "T", | ||
| # Use TVD RK3 for time marching | ||
| "time_stepper": 3, | ||
| # Reconstruct the primitive variables to minimize spurious | ||
| # Use WENO5 | ||
| "weno_order": 5, | ||
| "weno_eps": 1.0e-14, | ||
| "weno_Re_flux": "T", | ||
| "weno_avg": "T", | ||
| "avg_state": 2, | ||
| "mapped_weno": "T", | ||
| "null_weights": "F", | ||
| "mp_weno": "T", | ||
| "riemann_solver": 2, | ||
| "wave_speeds": 1, | ||
| # periodic bc | ||
| "bc_x%beg": -1, | ||
| "bc_x%end": -1, | ||
| "bc_y%beg": -1, | ||
| "bc_y%end": -1, | ||
| "bc_z%beg": -1, | ||
| "bc_z%end": -1, | ||
| # Set IB to True and add 1 patch for every sphere | ||
| "ib": "T", | ||
| "num_ibs": 1, | ||
| "viscous": "T", | ||
| # Formatted Database Files Structure Parameters | ||
| "format": 1, | ||
| "precision": 2, | ||
| "prim_vars_wrt": "T", | ||
| "E_wrt": "T", | ||
| "parallel_io": "T", | ||
| # Patch: cube filled with air | ||
| "patch_icpp(1)%geometry": 9, | ||
| # Uniform properties, centroid is at the center of the domain | ||
| "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": 10 * D, | ||
| "patch_icpp(1)%length_y": 10 * D, | ||
| "patch_icpp(1)%length_z": 10 * D, | ||
| # Specify the patch primitive variables | ||
| "patch_icpp(1)%vel(1)": v1, | ||
| "patch_icpp(1)%vel(2)": 0.0e00, | ||
| "patch_icpp(1)%vel(3)": 0.0e00, | ||
| "patch_icpp(1)%pres": P, | ||
| "patch_icpp(1)%alpha_rho(1)": rho, | ||
| "patch_icpp(1)%alpha(1)": 1.0e00, | ||
| # Fluids Physical Parameters | ||
| "fluid_pp(1)%gamma": 1.0e00 / (gam_a - 1.0e00), # 2.50(Not 1.40) | ||
| "fluid_pp(1)%pi_inf": 0, | ||
| "fluid_pp(1)%Re(1)": 1.0 / mu, | ||
| # ibs wrap around domain | ||
| "periodic_ibs": "T", | ||
| } | ||
|
|
||
| case_dict.update(ib_dict) | ||
|
|
||
| print(json.dumps(case_dict)) | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor doc fix: “sphere” → “circle.”
This is a 2D circle case, so the resolution comment should reference a circle.
✏️ Suggested edit
📝 Committable suggestion
🤖 Prompt for AI Agents