r""":mod:`mirgecom.operators` provides helper functions for composing DG operators... autofunction:: grad_operator.. autofunction:: div_operator"""__copyright__="""Copyright (C) 2021 University of Illinois Board of Trustees"""__license__="""Permission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHERLIABILITY, 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 INTHE SOFTWARE."""importgrudge.opasopfromgrudge.dof_descimportDISCR_TAG_BASE
[docs]defgrad_operator(dcoll,dd_vol,dd_allfaces,u,flux):r"""Compute a DG gradient for the input *u* with flux given by *flux*. Parameters ---------- dcoll: grudge.discretization.DiscretizationCollection the discretization collection to use dd_vol: grudge.dof_desc.DOFDesc the degree-of-freedom tag associated with the volume discretization. This determines the type of quadrature to be used. dd_allfaces: grudge.dof_desc.DOFDesc the degree-of-freedom tag associated with the surface discretization. This determines the type of quadrature to be used. u: meshmode.dof_array.DOFArray or numpy.ndarray the function (or container of functions) for which gradient is to be calculated flux: numpy.ndarray the boundary flux across the faces of the element for each component of *u* Returns ------- meshmode.dof_array.DOFArray or numpy.ndarray the dg gradient operator applied to *u* """# pylint: disable=invalid-unary-operand-typereturn-op.inverse_mass(dcoll,dd_vol.with_discr_tag(DISCR_TAG_BASE),op.weak_local_grad(dcoll,dd_vol,u)-op.face_mass(dcoll,dd_allfaces,flux))
[docs]defdiv_operator(dcoll,dd_vol,dd_allfaces,v,flux):r"""Compute DG divergence of vector-valued func *v* with flux given by *flux*. Parameters ---------- dcoll: grudge.discretization.DiscretizationCollection the discretization collection to use dd_vol: grudge.dof_desc.DOFDesc the degree-of-freedom tag associated with the volume discretization. This determines the type of quadrature to be used. dd_allfaces: grudge.dof_desc.DOFDesc the degree-of-freedom tag associated with the surface discretization. This determines the type of quadrature to be used. v: numpy.ndarray obj array of :class:`~meshmode.dof_array.DOFArray` (or container of such) representing the vector-valued functions for which divergence is to be calculated flux: numpy.ndarray the boundary flux for each function in v Returns ------- meshmode.dof_array.DOFArray or numpy.ndarray the dg divergence operator applied to vector-valued function(s) *v*. """# pylint: disable=invalid-unary-operand-typereturn-op.inverse_mass(dcoll,dd_vol.with_discr_tag(DISCR_TAG_BASE),op.weak_local_div(dcoll,dd_vol,v)-op.face_mass(dcoll,dd_allfaces,flux))