From 5b57e5c0988ac64bdbc2bf7e48b88190221b7ddb Mon Sep 17 00:00:00 2001 From: Mike Campbell Date: Tue, 28 Mar 2023 10:35:47 -0500 Subject: [PATCH 1/2] Add option to turn off inviscid terms in CNS operator. --- mirgecom/navierstokes.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/mirgecom/navierstokes.py b/mirgecom/navierstokes.py index 8a4257350..23b62e778 100644 --- a/mirgecom/navierstokes.py +++ b/mirgecom/navierstokes.py @@ -328,7 +328,7 @@ def ns_operator(dcoll, gas_model, state, boundaries, *, time=0.0, # Added to avoid repeated computation # FIXME: See if there's a better way to do this operator_states_quad=None, - grad_cv=None, grad_t=None): + grad_cv=None, grad_t=None, inviscid_terms_on=True): r"""Compute RHS of the Navier-Stokes equations. Parameters @@ -397,6 +397,10 @@ def ns_operator(dcoll, gas_model, state, boundaries, *, time=0.0, provided, the operator will calculate it with :func:`~mirgecom.navierstokes.grad_t_operator`. + inviscid_terms_on + Optional boolean to turn OFF invsicid contributions to this operator. + Defaults to True. + Returns ------- :class:`mirgecom.fluid.ConservedVars` @@ -486,41 +490,30 @@ def ns_operator(dcoll, gas_model, state, boundaries, *, time=0.0, # {{{ === Navier-Stokes RHS === - # Compute the volume term for the divergence operator - vol_term = ( - - # Compute the volume contribution of the viscous flux terms - # using field values on the quadrature grid - viscous_flux(state=vol_state_quad, + # Compute the viscous volume and boundary terms for the divergence operator + vol_term = viscous_flux(state=vol_state_quad, # Interpolate gradients to the quadrature grid grad_cv=op.project(dcoll, dd_vol, dd_vol_quad, grad_cv), grad_t=op.project(dcoll, dd_vol, dd_vol_quad, grad_t)) - # Compute the volume contribution of the inviscid flux terms - # using field values on the quadrature grid - - inviscid_flux(state=vol_state_quad) - ) - - # Compute the boundary terms for the divergence operator - bnd_term = ( - - # All surface contributions from the viscous fluxes - viscous_flux_on_element_boundary( + bnd_term = viscous_flux_on_element_boundary( dcoll, gas_model, boundaries, inter_elem_bnd_states_quad, domain_bnd_states_quad, grad_cv, grad_cv_interior_pairs, grad_t, grad_t_interior_pairs, quadrature_tag=quadrature_tag, numerical_flux_func=viscous_numerical_flux_func, time=time, dd=dd_vol) - # All surface contributions from the inviscid fluxes - - inviscid_flux_on_element_boundary( + # Add in the invsicd parts if enabled + if inviscid_terms_on: + vol_term = vol_term - inviscid_flux(state=vol_state_quad) + bnd_term = bnd_term - inviscid_flux_on_element_boundary( dcoll, gas_model, boundaries, inter_elem_bnd_states_quad, domain_bnd_states_quad, quadrature_tag=quadrature_tag, numerical_flux_func=inviscid_numerical_flux_func, time=time, dd=dd_vol) - ) ns_rhs = div_operator(dcoll, dd_vol_quad, dd_allfaces_quad, vol_term, bnd_term) + if return_gradients: return ns_rhs, grad_cv, grad_t return ns_rhs From 0f8f2447a8975f77d51a495fdda1de0db74548ad Mon Sep 17 00:00:00 2001 From: Michael Campbell Date: Tue, 28 Mar 2023 18:56:18 -0500 Subject: [PATCH 2/2] Deflake8 --- mirgecom/navierstokes.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/mirgecom/navierstokes.py b/mirgecom/navierstokes.py index 23b62e778..f4c40af57 100644 --- a/mirgecom/navierstokes.py +++ b/mirgecom/navierstokes.py @@ -490,20 +490,21 @@ def ns_operator(dcoll, gas_model, state, boundaries, *, time=0.0, # {{{ === Navier-Stokes RHS === - # Compute the viscous volume and boundary terms for the divergence operator + # Physical viscous flux in the element volume vol_term = viscous_flux(state=vol_state_quad, # Interpolate gradients to the quadrature grid grad_cv=op.project(dcoll, dd_vol, dd_vol_quad, grad_cv), grad_t=op.project(dcoll, dd_vol, dd_vol_quad, grad_t)) + # Physical viscous flux (f .dot. n) is the boundary term for the div op bnd_term = viscous_flux_on_element_boundary( - dcoll, gas_model, boundaries, inter_elem_bnd_states_quad, - domain_bnd_states_quad, grad_cv, grad_cv_interior_pairs, - grad_t, grad_t_interior_pairs, quadrature_tag=quadrature_tag, - numerical_flux_func=viscous_numerical_flux_func, time=time, - dd=dd_vol) + dcoll, gas_model, boundaries, inter_elem_bnd_states_quad, + domain_bnd_states_quad, grad_cv, grad_cv_interior_pairs, + grad_t, grad_t_interior_pairs, quadrature_tag=quadrature_tag, + numerical_flux_func=viscous_numerical_flux_func, time=time, + dd=dd_vol) - # Add in the invsicd parts if enabled + # Add corresponding inviscid parts if enabled if inviscid_terms_on: vol_term = vol_term - inviscid_flux(state=vol_state_quad) bnd_term = bnd_term - inviscid_flux_on_element_boundary(