# Source code for pyfr.solvers.navstokes.elements

    # -*- coding: utf-8 -*-

    from pyfr.solvers.baseadvecdiff import BaseAdvectionDiffusionElements
    from pyfr.solvers.euler.elements import BaseFluidElements

    class NavierStokesElements(BaseFluidElements, BaseAdvectionDiffusionElements):
        # Use the density field for shock sensing
        shockvar = 'rho'

        def set_backend(self, backend, nscalupts, nonce):
            super().set_backend(backend, nscalupts, nonce)
            backend.pointwise.register('pyfr.solvers.navstokes.kernels.tflux')

            shock_capturing = self.cfg.get('solver', 'shock-capturing')
            visc_corr = self.cfg.get('solver', 'viscosity-correction', 'none')
            if visc_corr not in {'sutherland', 'none'}:
                raise ValueError('Invalid viscosity-correction option')

            tplargs = dict(ndims=self.ndims, nvars=self.nvars,
                           shock_capturing=shock_capturing, visc_corr=visc_corr,
                           c=self.cfg.items_as('constants', float))

            if 'flux' in self.antialias:
                self.kernels['tdisf'] = lambda: backend.kernel(
                    'tflux', tplargs=tplargs, dims=[self.nqpts, self.neles],
                    u=self._scal_qpts, smats=self.smat_at('qpts'),
                    f=self._vect_qpts, artvisc=self.artvisc
                )
            else:
                self.kernels['tdisf'] = lambda: backend.kernel(
                    'tflux', tplargs=tplargs, dims=[self.nupts, self.neles],
                    u=self.scal_upts_inb, smats=self.smat_at('upts'),
                    f=self._vect_upts, artvisc=self.artvisc
                )