Conversation
inducer
left a comment
There was a problem hiding this comment.
Some initial thoughts below.
| Tests that the cells tagging properly tags cells | ||
| given prescribed solutions. |
There was a problem hiding this comment.
Expand to describe precisely what is being tested.
There was a problem hiding this comment.
Took a stab at this. Want to have a look and sharpen it up @w-hagen ?
| @@ -0,0 +1,265 @@ | |||
| """Test the artificial viscosity functions.""" | |||
There was a problem hiding this comment.
IMO, this is missing a test for proper handing of boundary conditions, particularly in view of the fact that we had trouble with that.
There was a problem hiding this comment.
A test has been added to make sure the AV fluxes returned from the fluid BC constructs match those which we intended for them to be. We collectively share a lack of knowledge about what the BCs should actually be for this operator (i.e., when computing the 2nd part; div(alpha*indicator*grad(Q))). For the first (grad(Q)) part, this operator now mercifully uses grad(Q) from the fluid computation, and is thus using the appropriate fluid BCs directly there - whatever those may be for the given boundary. The added tests check the AV-specific interface fluxes for the 2nd part.
| """Test artificial_viscosity. | ||
|
|
||
| Tests the application on a few simple functions | ||
| to confirm artificial viscosity returns the analytical result. | ||
| """ |
There was a problem hiding this comment.
Improve the description here.
| """Test artificial_viscosity. | ||
|
|
||
| Tests the application on a few simple functions | ||
| to confirm artificial viscosity returns the analytical result. | ||
| """ |
There was a problem hiding this comment.
I think this should be replaced by a manufactured-solution test, instead of these two simplistic known-solution tests.
There was a problem hiding this comment.
I tried quickly re-use the diffusion operator MMS tests, but turns out not to be as easy of a drop-in as I had imagined.
We'll need some infrastructure backing to make this happen. It looks like the amount of effort to get an MMS infrastructure for AV is about the same as replacing the guts of AV with the diffusion operator. I think we'd prefer using the diffusion operator. Another option would be just beefing up the tests a bit with more analytic functions, perhaps leveraging the symbolic infrastructure.
There was a problem hiding this comment.
@lukeolson added a trig test that helps with this a little.
I tried to add a discontinuous coeff test (which I do not expect this operator to pass) - but it turned out to be too much effort for this fluid-specific operator. If this operator was just a (multi)scalar laplacian operator, then it'd be a no-brainer. Alas, now it re-uses the gradient operator and boundary projection routines designed specifically for fluid solutions - and thus requires physically-consistent fluid solutions.
| """Test artificial_viscosity. | ||
|
|
||
| Tests the application on a few simple functions | ||
| to confirm artificial viscosity returns the analytical result. | ||
| """ |
There was a problem hiding this comment.
This does not test the numerical fluxes, since there are no jumps. As a result, numerical stability of AV is not being tested.
There was a problem hiding this comment.
It appears that the diffusion operator has only one test where jumps are tested. We could potentially port that over to AV testing, if that is of interest.
| pass | ||
|
|
||
|
|
||
| def av_laplacian_operator(discr, boundaries, fluid_state, alpha, gas_model=None, |
There was a problem hiding this comment.
Let me ask the elephant-in-the-room question here: Given that we have variable-coefficient diffusion, why do we want this? As @majosm can possibly attest, getting diffusion with elementwise-discontinuous coefficients right is not entirely trivial. And the already-implemented diffusion operator literally implements the same operator. It doesn't help that this operator is not well-tested.
I'd be OK with this becoming a deprecated wrapper of the diffusion operator.
| return -div_operator(discr, dd_vol, dd_faces, interp_to_vol_quad(r), r_bnd) | ||
|
|
||
|
|
||
| def smoothness_indicator(discr, u, kappa=1.0, s0=-6.0): |
There was a problem hiding this comment.
I think this can be built simply out of the modal discretization facility in meshmode. There's definitely no need for this to make use of a loopy kernel. @kaushikcfd had also worked on a more lazy-compatible version of this. I am surprised to see that that is not part of this.
There was a problem hiding this comment.
I believe the version you are thinking of is added by @kaushikcfd in #666. It requires the fusion array context and does not work without it afaik.
There was a problem hiding this comment.
The tagging bit won't work, but the einsum bit should be fine. I don't have a preference for which PR the einsum is introduced in.
There was a problem hiding this comment.
What part of the tagging is the issue? I'm looking over the code in #666, and it mostly seems like it ought to go even with arraycontext/meshmode main?
There was a problem hiding this comment.
Tag types like DiscretizationDOFAxisTag haven't made it to meshmode main.
There was a problem hiding this comment.
Do we have a path forward for this item?
There was a problem hiding this comment.
fwiw, here's the error i get when trying to run with @kaushikcfd indicator:
indicator = smoothness_indicator(discr, fluid_state.mass_density,
File "/Users/mtcampbe/CEESD/devel/tau/main/emirge/mirgecom/mirgecom/artificial_viscosity.py", line 318, in smoothness_indicator
from meshmode.transform_metadata import DiscretizationDOFAxisTag
ImportError: cannot import name 'DiscretizationDOFAxisTag' from 'meshmode.transform_metadata' (/Users/mtcampbe/CEESD/devel/tau/
There was a problem hiding this comment.
The actx.tag_axis part would be illegal, but without that the call to actx.einsum should be legal on meshmode main. I'm ok with the rewrite to einsum either here or in #666.
There was a problem hiding this comment.
I just added @kaushikcfd version of this in (732f005). The tests passed locally with main (:tada:).
|
It might make sense to squash this so that the Github UI does not bog down. |
| health_error = True | ||
| logger.info(f"{rank=}: NANs/Infs in pressure data.") | ||
|
|
||
| from mirgecom.simutil import allsync |
There was a problem hiding this comment.
I believe these should be global_reduce now
| default_simplex_group_factory, QuadratureSimplexGroupFactory | ||
|
|
||
| order = 3 | ||
| discr = EagerDGDiscretization( |
There was a problem hiding this comment.
These should be updated to the new collection. But this is done in #360
There was a problem hiding this comment.
Let's make a dedicated issue about updating mirgecom to use discretization collections. This cannot be done example-by-example. It requires a large collection of supporting updates throughout mirgecom.
There was a problem hiding this comment.
Working to centralize and then replace the discretization collection in a dedicated effort was precisely the reason we added this code:
https://github.com/illinois-ceesd/mirgecom/blob/main/mirgecom/discretization.py
7b9ee93 uses the wrapper, and gets rid of the deprecation warning.
| from mirgecom.logging_quantities import ( | ||
| initialize_logmgr, | ||
| logmgr_add_many_discretization_quantities, | ||
| logmgr_add_device_name, |
There was a problem hiding this comment.
use logmgr_cl_device_name
| current_state = make_fluid_state(cv=current_cv, gas_model=gas_model) | ||
|
|
||
| visualizer = make_visualizer(discr, | ||
| discr.order if discr.dim == 2 else discr.order) |
There was a problem hiding this comment.
.order is deprecated (it appears)
There was a problem hiding this comment.
Also, what is the point of this line.
There was a problem hiding this comment.
I think that was used for a bit to plot at a higher discretization order but looks like I changed that and never got rid of the if statement. That part can be removed.
There was a problem hiding this comment.
Oh sure - but this particular line says something like "if sthing then discr.order else discr.order"
Co-authored-by: Andreas Klöckner <inform@tiker.net>
| 0.5 * (1.0 + actx.np.sin(np.pi * (indicator - s0) / (2.0 * kappa))), | ||
| 0.0 * indicator, | ||
| ) | ||
| indicator = actx.np.where(yesnou, 1.0 + 0.0 * indicator, sin_indicator) |
There was a problem hiding this comment.
np.where() works with a scalar field... this would avoid an extra dof array by just using 1.0
There was a problem hiding this comment.
I'm not sure if that's extended in the array context though worth checking
There was a problem hiding this comment.
I do not know if it has changed (i doubt it), but I definitely needed each "rhs" args to be arrays of equal size when using this function in the past.
This change set adds artificial viscosity (mostly) as developed by @w-hagen, with the tweaks and improvements we've made along the way including @thomasgibson changes to bring in over-integration capabilities.
Checklist for @lukeolson
av_laplacian_operatoris limited. Consider adding a more complete MMS. In the very least note limitations of this Laplace operator in the notes (lack of testing for discontinuous coefficients?)global_reduceshould be used instead ofallsyncinartificial_viscocity.py. Update to finalize this check. https://github.com/illinois-ceesd/mirgecom/pull/582/files#r890463448logmgr_add_cl_name(https://github.com/illinois-ceesd/mirgecom/pull/582/files#r890474470)DiscretizationCollection(https://github.com/illinois-ceesd/mirgecom/pull/582/files#r890468427). Make this update (consistent with Modernize Mirgecom #360) to finish the checklist item..order(https://github.com/illinois-ceesd/mirgecom/pull/582/files#r890477095) to finish this.