[pyfr] 08/88: Avoid the use of views when computing artifical viscosity.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Nov 16 12:05:24 UTC 2016


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to branch master
in repository pyfr.

commit 3fa0bc443a15e34d02cae1abb64568e292846c75
Author: Freddie Witherden <freddie at witherden.org>
Date:   Fri Apr 15 11:12:37 2016 -0700

    Avoid the use of views when computing artifical viscosity.
    
    This should reduce memory consumption slightly and also improve
    the performance of the avis kernel.
---
 pyfr/solvers/navstokes/elements.py       | 21 ++++++---------------
 pyfr/solvers/navstokes/kernels/avis.mako | 17 +++++++----------
 2 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/pyfr/solvers/navstokes/elements.py b/pyfr/solvers/navstokes/elements.py
index 638185f..b880a3a 100644
--- a/pyfr/solvers/navstokes/elements.py
+++ b/pyfr/solvers/navstokes/elements.py
@@ -16,6 +16,7 @@ class NavierStokesElements(BaseFluidElements, BaseAdvectionDiffusionElements):
         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,
                        visc_corr=visc_corr,
                        c=self.cfg.items_as('constants', float))
@@ -76,33 +77,23 @@ class NavierStokesElements(BaseFluidElements, BaseAdvectionDiffusionElements):
                     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)
+                    ame_e = avis_qpts
                     tplargs['nrow_amu'] = self.nqpts
                 else:
-                    ame_e = col_view(avis_upts)
+                    ame_e = 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
+                    'avis', tplargs, dims=[neles], s=avis_upts_temp,
+                    amu_e=ame_e, amu_f=self._avis_fpts
                 )
 
                 return ComputeMetaKernel([ent, mul, avis])
 
             self.kernels['avis'] = artf_vis
+
             tplargs['art_vis'] = 'mu'
         elif shock_capturing == 'none':
             avis_upts = avis_qpts = None
diff --git a/pyfr/solvers/navstokes/kernels/avis.mako b/pyfr/solvers/navstokes/kernels/avis.mako
index cd7fabe..b9bc178 100644
--- a/pyfr/solvers/navstokes/kernels/avis.mako
+++ b/pyfr/solvers/navstokes/kernels/avis.mako
@@ -9,20 +9,17 @@
 
 
 <%pyfr:kernel name='avis' ndim='1'
-              s='in view fpdtype_t[${str(nupts)}]'
-              amu_e='out view fpdtype_t[${str(nrow_amu)}]'
-              amu_f='out view fpdtype_t[${str(nfpts)}]'>
-
+              s='in fpdtype_t[${str(nupts)}]'
+              amu_e='out fpdtype_t[${str(nrow_amu)}]'
+              amu_f='out fpdtype_t[${str(nfpts)}]'>
     // Smoothness indicator
-    fpdtype_t totEn = 0.0, pnEn = 1e-15, s2;
-    fpdtype_t se0= ${math.log10(c['s0'])};
+    fpdtype_t totEn = 0.0, pnEn = 1e-15;
+    fpdtype_t se0 = ${math.log10(c['s0'])};
 
 % for i, deg in enumerate(ubdegs):
-    s2 = s[${i}]*s[${i}];
-    totEn += s2;
-
+    totEn += s[${i}]*s[${i}];
 % if deg >= order:
-    pnEn += s2;
+    pnEn += s[${i}]*s[${i}];
 % endif
 % endfor
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/pyfr.git



More information about the debian-science-commits mailing list