def __init__(self, be, lhs, rhs, elemap, cfg): super().__init__(be, lhs, rhs, elemap, cfg) # Pointwise template arguments rsolver = self.cfg.get('solver-interfaces', 'riemann-solver') tplargs = dict(ndims=self.ndims, nvars=self.nvars, rsolver=rsolver, c=self._tpl_c) self._be.pointwise.register('pyfr.solvers.acnavstokes.kernels.intconu') self._be.pointwise.register( 'pyfr.solvers.acnavstokes.kernels.intcflux') if abs(self._tpl_c['ldg-beta']) == 0.5: self.kernels['copy_fpts'] = lambda: ComputeMetaKernel( [ele.kernels['_copy_fpts']() for ele in elemap.values()]) self.kernels['con_u'] = lambda: self._be.kernel('intconu', tplargs=tplargs, dims=[self.ninterfpts], ulin=self._scal_lhs, urin=self._scal_rhs, ulout=self._vect_lhs, urout=self._vect_rhs) self.kernels['comm_flux'] = lambda: self._be.kernel( 'intcflux', tplargs=tplargs, dims=[self.ninterfpts], ul=self._scal_lhs, ur=self._scal_rhs, gradul=self._vect_lhs, gradur=self._vect_rhs, magnl=self._mag_pnorm_lhs, nl=self._norm_pnorm_lhs)
def __init__(self, be, lhs, rhs, elemap, cfg): super().__init__(be, lhs, rhs, elemap, cfg) be.pointwise.register('pyfr.solvers.navstokes.kernels.intconu') be.pointwise.register('pyfr.solvers.navstokes.kernels.intcflux') if abs(self.c['ldg-beta']) == 0.5: self.kernels['copy_fpts'] = lambda: ComputeMetaKernel( [ele.kernels['_copy_fpts']() for ele in elemap.values()]) self.kernels['con_u'] = lambda: be.kernel('intconu', tplargs=self._tplargs, dims=[self.ninterfpts], ulin=self._scal_lhs, urin=self._scal_rhs, ulout=self._vect_lhs, urout=self._vect_rhs) self.kernels['comm_flux'] = lambda: be.kernel( 'intcflux', tplargs=self._tplargs, dims=[self.ninterfpts], ul=self._scal_lhs, ur=self._scal_rhs, gradul=self._vect_lhs, gradur=self._vect_rhs, artviscl=self._artvisc_lhs, artviscr=self._artvisc_rhs, magnl=self._mag_pnorm_lhs, nl=self._norm_pnorm_lhs)
def filter_soln(): mul = backend.kernel('mul', self.opmat('M11'), self.scal_upts_inb, out=self._scal_upts_temp) copy = backend.kernel('copy', self.scal_upts_inb, self._scal_upts_temp) return ComputeMetaKernel([mul, copy])
def gradcoru_qpts(): nupts, nqpts = self.nupts, self.nqpts vupts, vqpts = self._vect_upts, self._vect_qpts # Exploit the block-diagonal form of the operator muls = [backend.kernel('mul', self.opmat('M7'), vupts.rslice(i*nupts, (i + 1)*nupts), vqpts.rslice(i*nqpts, (i + 1)*nqpts)) for i in range(self.ndims)] return ComputeMetaKernel(muls)
def artf_vis(): # Compute entropy and save to avis_upts ent = backend.kernel('entropy', tplargs=tplargs, dims=[nupts, neles], u=self.scal_upts_inb, s=avis_upts) # Compute modal coefficients of entropy rcpvdm = np.linalg.inv(self.basis.ubasis.vdm.T) rcpvdm = self._be.const_matrix(rcpvdm, tags={'align'}) mul = backend.kernel('mul', rcpvdm, avis_upts, out=avis_upts_temp) # Additional constants for element-wise artificial viscosity tplargs['c'].update( self.cfg.items_as('solver-artificial-viscosity', float)) tplargs.update( dict( nupts=nupts, nfpts=nfpts, order=self.basis.order, ubdegs=self.basis.ubasis.degrees, )) # Column view for avis_upts/fpts matrices col_view = lambda mat: backend.view( matmap=np.array([mat.mid] * mat.ncol), rcmap=np.array(list(ndrange(1, mat.ncol))), stridemap=np.array([[mat.leaddim]] * mat.ncol), vshape=(mat.nrow, )) avis_fpts_cv = col_view(self._avis_fpts) avis_upts_temp_cv = col_view(avis_upts_temp) if 'flux' in self.antialias: ame_e = col_view(avis_qpts) tplargs['nrow_amu'] = self.nqpts else: ame_e = col_view(avis_upts) tplargs['nrow_amu'] = nupts # Element-wise artificial viscosity kernel avis = backend.kernel('avis', tplargs, dims=[neles], s=avis_upts_temp_cv, amu_e=ame_e, amu_f=avis_fpts_cv) return ComputeMetaKernel([ent, mul, avis])
def gradcoru_fpts(): nupts, nfpts = self.nupts, self.nfpts vupts, vfpts = self._vect_upts, self._vect_fpts # Exploit the block-diagonal form of the operator muls = [ kernel('mul', self.opmat('M0'), vupts.slice(i * nupts, (i + 1) * nupts), vfpts.slice(i * nfpts, (i + 1) * nfpts)) for i in range(self.ndims) ] return ComputeMetaKernel(muls)