-
Notifications
You must be signed in to change notification settings - Fork 23
Artificial viscosity #213
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
Closed
Closed
Artificial viscosity #213
Changes from 104 commits
Commits
Show all changes
111 commits
Select commit
Hold shift + click to select a range
8e7ddda
Initial implementation of artificial viscosity for the euler equations
w-hagen 59f80c3
Initial implementation of smoothness indicator
w-hagen 122966e
Updated modal smoothness indicator to mode_ids to select highest mode
w-hagen 598e4b6
Fixed updated artificial viscosity implementation to use desired equa…
w-hagen 822d863
Add boundary condition function to return projected boundary solution
w-hagen e0f0ce4
Added double mach reflection example problem
w-hagen d35771a
Added double mach reflection example problem
w-hagen a71ac3b
Remove reference to unnecessary heat operator
w-hagen 0f132eb
Fixed error in calculating face fluxes across ranks
w-hagen 40656f3
Removed unessecary reference to heat operator
w-hagen d49de59
Fixed error in not distributing grid
w-hagen 80e1a62
Added shock indicator and integrated with artificial viscosity
w-hagen 0c25238
Added output field for shock indicator
w-hagen 96fc18c
Modified stepping parameters for scaling tests
w-hagen 446cace
Fixed artifical viscosity boundary conditions
w-hagen 7a9a81d
Merge branch 'master' into av-mrg-master
MTCam bf67fc0
Bring back functions inadvertently removed in hand merge
MTCam f52b8b6
Minimum changes to bring boundary conditions up to date with mainline…
w-hagen 37abb66
Merges the upstream master
MTCam 703869a
Silence flake8.
MTCam f20059f
Silence pydocstyle
MTCam 125ff51
Merge pull request #3 from w-hagen/silence-pydocstyle
w-hagen 5c99ac1
Merge pull request #2 from w-hagen/silence-flake8
w-hagen d978414
merge updated master into artificial viscosity branch
w-hagen 8d30def
Merge pull request #4 from w-hagen/av-mrg-master
w-hagen 1340ea6
Remove un-needed make_obj_array calls
w-hagen 067ad2b
Merge pull request #5 from w-hagen/remove-mkobjarray
w-hagen 9d32a7a
Rework boundary conditions to avoid duplicating code
w-hagen 3a13a05
Fix docstyle, remove unused import
w-hagen 1b2b30e
Expose smoothness indicator parameters
w-hagen 0dff5e5
Fixed boundary calls to self
w-hagen 1b57517
Fixed flake8 line to long
w-hagen 20221dd
Merge pull request #6 from w-hagen/av-boundary-rework
w-hagen f39deb2
Clean up AdiabaticSlipBoundary for artificial viscosity condition.
w-hagen 6b9a29d
Added inital documentation to artificial viscosity routines (#8)
w-hagen d17ea87
fixed flake8 error
w-hagen 5018f52
Merge branch 'artificial_viscosity' of github.com:w-hagen/mirgecom in…
w-hagen 100b1c3
Fixed too long line
w-hagen 9d0f8ed
Added tests to artificial viscosity routines. (#9)
w-hagen 105fd83
Bring branch up to main
w-hagen 5d22727
Merge branch 'artificial_viscosity' of github.com:w-hagen/mirgecom in…
w-hagen bf309fe
Fixed missed merge conflict.
w-hagen 34b96bf
Fixed errors in dobule mach initialization.
w-hagen f52a165
Fixed error in initialization.
w-hagen c8858e4
Cleaned up artificial viscosity routines.
w-hagen 1afa3d7
Fixed errors in calling gmsh
w-hagen a404a62
Add gmsh as requirement
w-hagen c1cd479
Fix some style issues and add temporary fix for Issue #280
w-hagen 8b580e5
Fix documentation grammer.
w-hagen 40364ac
Renamed shock parameters to be more descriptive.
w-hagen af24249
Added normal shock relations calculator to DoubleMahcReflection case.
w-hagen 8a50f22
Remove linter changes for not my file
w-hagen 77b0263
use viz_fields to visualize tagged cells.
w-hagen 218cb52
Added interface parameter documentation.
w-hagen cb8be6a
Remove linting modification to simutil.py
w-hagen 0f2d680
Fixed tests to reflect change in smoothness indicator parameters.
w-hagen 834a98c
Update mirgecom/initializers.py
w-hagen f2654ab
Merge branch 'main' into artificial_viscosity
MTCam d72df2a
Refactor AV (#12)
MTCam afd9233
Merge branch 'main' into artificial_viscosity
MTCam 8fc9771
Add some comments for docs, try to address @thomasgibson comments (#13)
MTCam 0495f3b
Update examples/doublemach-mpi.py to get rank properly
w-hagen b93411b
Update logic to check if file exists
w-hagen 3f336fd
Update documenatation
w-hagen 8fa696e
Update documentation
w-hagen de305d9
Update documentation
w-hagen 376ba33
Update documentation
w-hagen 184e2cc
Update documentation
w-hagen 1fea6b6
Update documentation
w-hagen f17e450
Update documentation
w-hagen 9cd58d3
Update documentation
w-hagen cc2752a
Update documentation
w-hagen d78cdab
Update documentation
w-hagen d55666c
Update documentation
w-hagen 06d171c
Fix flake8/docstyle issue
w-hagen 974bcd4
Clean up doublemach case documentation and remove dim as parameter.
w-hagen f3e6a61
Tweak the doublemach docs and implementation just a bit (#15)
MTCam fbe4de3
Remove superfluous isinstance check
w-hagen 7dfa814
Use added grudge functionality to get modal solution
w-hagen fa4ace9
Updated AV documentation to reflect new use of cv-specific fluid func…
w-hagen 34e5ae4
Merge branch 'main' into artificial_viscosity
MTCam 88f3530
remove commented out import
w-hagen bde0028
Fix sign error in doublemach case
w-hagen d58d27d
Merge branch 'main' into artificial_viscosity
MTCam 13d2619
Replace join_conserved_vectors with np.stack per @majosm suggestion. …
MTCam 1cb7979
Merge branch 'main' into artificial_viscosity
MTCam b3556c9
Rename vars more precisely in AV boundary routine. (#17)
MTCam ef9c67e
Make artificial viscosity documentation more general (#18)
thomasgibson 961a5bb
Fixed spelling
w-hagen ea3dc35
Remove join_conserved_vectors
w-hagen 326caf8
Merge branch 'main' into artificial_viscosity
MTCam 56e5efd
Merge branch 'main' into artificial_viscosity
MTCam 70a4696
Rewrite shock indicator, cache program and mode computations (#20)
thomasgibson 7090d32
Update double mach example (#22)
thomasgibson 445c5c8
Clean up object array handling in flux routines (#19)
majosm d185c95
Merge branch 'main' into artificial_viscosity
MTCam e2d7ddd
Sooth the bugbear.
MTCam 3a61993
Unpoke the bugbear.
MTCam 59df6df
AV misc fixes (#23)
majosm c0578f2
Rename modes_active_flag
w-hagen bfe3658
Merge branch 'main' into artificial_viscosity
MTCam fb44717
Merge branch 'main' into artificial_viscosity
MTCam 557df33
Merge branch 'main' into artificial_viscosity
MTCam f9e7884
Merge branch 'main' into artificial_viscosity
MTCam d602975
Update mirgecom/artificial_viscosity.py for lazy eval
w-hagen 07b4ebe
Merge branch 'main' into artificial_viscosity
MTCam 90b924e
Fix up calls to be like main - CV array container stuff
MTCam a259e51
Update to make_conserved - CV array container stuff
MTCam 2d42add
Update per CV array container
MTCam a06062c
Placate flake8
MTCam bbe0281
Update to latest APIs
MTCam 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
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,4 @@ | ||
| Artificial Viscosity | ||
| ==================== | ||
|
|
||
| .. automodule:: mirgecom.artificial_viscosity |
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 |
|---|---|---|
|
|
@@ -6,4 +6,5 @@ Operators | |
|
|
||
| wave-eq | ||
| diffusion | ||
| artificial_viscosity | ||
| gas-dynamics | ||
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,260 @@ | ||
| """Demonstrate double mach reflection.""" | ||
|
|
||
| __copyright__ = """ | ||
| Copyright (C) 2020 University of Illinois Board of Trustees | ||
| """ | ||
|
|
||
| __license__ = """ | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
| """ | ||
| import logging | ||
| import pyopencl as cl | ||
| import pyopencl.tools as cl_tools | ||
| from functools import partial | ||
|
|
||
| from meshmode.array_context import PyOpenCLArrayContext | ||
| from meshmode.dof_array import thaw | ||
| from meshmode.mesh import BTAG_ALL, BTAG_NONE # noqa | ||
| from grudge.dof_desc import DTAG_BOUNDARY | ||
| from grudge.eager import EagerDGDiscretization | ||
| from grudge.shortcuts import make_visualizer | ||
|
|
||
|
|
||
| from mirgecom.euler import inviscid_operator, split_conserved | ||
| from mirgecom.artificial_viscosity import ( | ||
| av_operator, | ||
| smoothness_indicator | ||
| ) | ||
| from mirgecom.simutil import ( | ||
| inviscid_sim_timestep, | ||
| sim_checkpoint, | ||
| generate_and_distribute_mesh, | ||
| ExactSolutionMismatch, | ||
| ) | ||
| from mirgecom.io import make_init_message | ||
| from mirgecom.mpi import mpi_entry_point | ||
|
|
||
| from mirgecom.integrators import rk4_step | ||
| from mirgecom.steppers import advance_state | ||
| from mirgecom.boundary import AdiabaticSlipBoundary, PrescribedBoundary | ||
| from mirgecom.initializers import DoubleMachReflection | ||
| from mirgecom.eos import IdealSingleGas | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def get_doublemach_mesh(): | ||
| """Generate or import a grid using `gmsh`. | ||
|
|
||
| Input required: | ||
| doubleMach.msh (read existing mesh) | ||
|
|
||
| This routine will generate a new grid if it does | ||
| not find the grid file (doubleMach.msh). | ||
| """ | ||
| from meshmode.mesh.io import ( | ||
| read_gmsh, | ||
| generate_gmsh, | ||
| ScriptSource, | ||
| ) | ||
| import os | ||
| meshfile = "doubleMach.msh" | ||
| if not os.path.exists(meshfile): | ||
| mesh = generate_gmsh( | ||
| ScriptSource(""" | ||
| x0=1.0/6.0; | ||
| setsize=0.025; | ||
| Point(1) = {0, 0, 0, setsize}; | ||
| Point(2) = {x0,0, 0, setsize}; | ||
| Point(3) = {4, 0, 0, setsize}; | ||
| Point(4) = {4, 1, 0, setsize}; | ||
| Point(5) = {0, 1, 0, setsize}; | ||
| Line(1) = {1, 2}; | ||
| Line(2) = {2, 3}; | ||
| Line(5) = {3, 4}; | ||
| Line(6) = {4, 5}; | ||
| Line(7) = {5, 1}; | ||
| Line Loop(8) = {-5, -6, -7, -1, -2}; | ||
| Plane Surface(8) = {8}; | ||
| Physical Surface('domain') = {8}; | ||
| Physical Curve('ic1') = {6}; | ||
| Physical Curve('ic2') = {7}; | ||
| Physical Curve('ic3') = {1}; | ||
| Physical Curve('wall') = {2}; | ||
| Physical Curve('out') = {5}; | ||
| """, "geo"), force_ambient_dim=2, dimensions=2, target_unit="M") | ||
| else: | ||
| mesh = read_gmsh(meshfile, force_ambient_dim=2) | ||
|
|
||
| return mesh | ||
|
|
||
|
|
||
| @mpi_entry_point | ||
| def main(ctx_factory=cl.create_some_context): | ||
| """Drive the example.""" | ||
| cl_ctx = ctx_factory() | ||
| queue = cl.CommandQueue(cl_ctx) | ||
| actx = PyOpenCLArrayContext( | ||
| queue, allocator=cl_tools.MemoryPool(cl_tools.ImmediateAllocator(queue)) | ||
| ) | ||
|
|
||
| dim = 2 | ||
| order = 3 | ||
| # Too many steps for CI | ||
| # t_final = 1.0e-2 | ||
| t_final = 1.0e-3 | ||
| current_cfl = 0.1 | ||
| current_dt = 1.0e-4 | ||
| current_t = 0 | ||
| eos = IdealSingleGas() | ||
| initializer = DoubleMachReflection() | ||
| casename = "doubleMach" | ||
|
|
||
| boundaries = { | ||
| DTAG_BOUNDARY("ic1"): PrescribedBoundary(initializer), | ||
| DTAG_BOUNDARY("ic2"): PrescribedBoundary(initializer), | ||
| DTAG_BOUNDARY("ic3"): PrescribedBoundary(initializer), | ||
| DTAG_BOUNDARY("wall"): AdiabaticSlipBoundary(), | ||
| DTAG_BOUNDARY("out"): AdiabaticSlipBoundary(), | ||
| } | ||
| constant_cfl = False | ||
| nstatus = 10 | ||
| nviz = 100 | ||
| rank = 0 | ||
| checkpoint_t = current_t | ||
| current_step = 0 | ||
| timestepper = rk4_step | ||
|
|
||
| s0 = -6.0 | ||
| kappa = 1.0 | ||
| alpha = 2.0e-2 | ||
| from mpi4py import MPI | ||
|
|
||
| comm = MPI.COMM_WORLD | ||
| rank = comm.Get_rank() | ||
|
|
||
| gen_grid = partial(get_doublemach_mesh) | ||
|
|
||
| local_mesh, global_nelements = generate_and_distribute_mesh(comm, gen_grid) | ||
|
|
||
| local_nelements = local_mesh.nelements | ||
|
|
||
| discr = EagerDGDiscretization(actx, local_mesh, order=order, | ||
| mpi_communicator=comm) | ||
|
|
||
| nodes = thaw(actx, discr.nodes()) | ||
| current_state = initializer(nodes) | ||
|
|
||
| visualizer = make_visualizer(discr, | ||
| discr.order if discr.dim == 2 else discr.order) | ||
| initname = initializer.__class__.__name__ | ||
| eosname = eos.__class__.__name__ | ||
| init_message = make_init_message( | ||
| dim=dim, | ||
| order=order, | ||
| nelements=local_nelements, | ||
| global_nelements=global_nelements, | ||
| dt=current_dt, | ||
| t_final=t_final, | ||
| nstatus=nstatus, | ||
| nviz=nviz, | ||
| cfl=current_cfl, | ||
| constant_cfl=constant_cfl, | ||
| initname=initname, | ||
| eosname=eosname, | ||
| casename=casename, | ||
| ) | ||
| if rank == 0: | ||
| logger.info(init_message) | ||
|
|
||
| get_timestep = partial( | ||
| inviscid_sim_timestep, | ||
| discr=discr, | ||
| t=current_t, | ||
| dt=current_dt, | ||
| cfl=current_cfl, | ||
| eos=eos, | ||
| t_final=t_final, | ||
| constant_cfl=constant_cfl, | ||
| ) | ||
|
|
||
| def my_rhs(t, state): | ||
| return inviscid_operator( | ||
| discr, q=state, t=t, boundaries=boundaries, eos=eos | ||
| ) + av_operator( | ||
| discr, q=state, boundaries=boundaries, | ||
| boundary_kwargs={"t": t, "eos": eos}, alpha=alpha, | ||
| s0=s0, kappa=kappa | ||
| ) | ||
|
|
||
| def my_checkpoint(step, t, dt, state): | ||
| cv = split_conserved(dim, state) | ||
| tagged_cells = smoothness_indicator(discr, cv.mass, s0=s0, kappa=kappa) | ||
| viz_fields = [("tagged cells", tagged_cells)] | ||
| return sim_checkpoint( | ||
| discr, | ||
| visualizer, | ||
| eos, | ||
| q=state, | ||
| vizname=casename, | ||
| step=step, | ||
| t=t, | ||
| dt=dt, | ||
| nstatus=nstatus, | ||
| nviz=nviz, | ||
| constant_cfl=constant_cfl, | ||
| comm=comm, | ||
| viz_fields=viz_fields, | ||
| overwrite=True, | ||
| ) | ||
|
|
||
| try: | ||
| (current_step, current_t, current_state) = advance_state( | ||
| rhs=my_rhs, | ||
| timestepper=timestepper, | ||
| checkpoint=my_checkpoint, | ||
| get_timestep=get_timestep, | ||
| state=current_state, | ||
| t=current_t, | ||
| t_final=t_final, | ||
| ) | ||
| except ExactSolutionMismatch as ex: | ||
| current_step = ex.step | ||
| current_t = ex.t | ||
| current_state = ex.state | ||
|
|
||
| # if current_t != checkpoint_t: | ||
| if rank == 0: | ||
| logger.info("Checkpointing final state ...") | ||
| my_checkpoint( | ||
| current_step, | ||
| t=current_t, | ||
| dt=(current_t - checkpoint_t), | ||
| state=current_state, | ||
| ) | ||
|
|
||
| if current_t - t_final < 0: | ||
| raise ValueError("Simulation exited abnormally") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| logging.basicConfig(format="%(message)s", level=logging.INFO) | ||
| main() | ||
|
|
||
| # vim: foldmethod=marker | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.