[pyfr] 18/32: Cleanups.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Apr 21 08:21:51 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 10f88c1e214d1f56c2b03db77f34efccca035416
Author: Freddie Witherden <freddie at witherden.org>
Date:   Sun Mar 20 11:37:15 2016 -0700

    Cleanups.
---
 pyfr/plugins/dtstats.py          |  6 +++---
 pyfr/solvers/base/inters.py      |  6 ------
 pyfr/solvers/baseadvec/inters.py | 12 ++++--------
 pyfr/solvers/navstokes/inters.py | 10 +++++-----
 4 files changed, 12 insertions(+), 22 deletions(-)

diff --git a/pyfr/plugins/dtstats.py b/pyfr/plugins/dtstats.py
index 19e5bd1..04a85e2 100644
--- a/pyfr/plugins/dtstats.py
+++ b/pyfr/plugins/dtstats.py
@@ -23,6 +23,8 @@ class DtStatsPlugin(BasePlugin):
         # The root rank needs to open the output file
         if rank == root:
             self.outf = init_csv(self.cfg, cfgsect, 'n,t,dt,action,error')
+        else:
+            self.outf = None
 
     def __call__(self, intg):
         # Process the sequence of rejected/accepted steps
@@ -33,10 +35,8 @@ class DtStatsPlugin(BasePlugin):
         self.count += len(intg.stepinfo)
         self.tprev = intg.tcurr
 
-        comm, rank, root = get_comm_rank_root()
-
         # If we're the root rank then output
-        if rank == root:
+        if self.outf:
             for s in self.stats:
                 print(','.join(str(c) for c in s), file=self.outf)
 
diff --git a/pyfr/solvers/base/inters.py b/pyfr/solvers/base/inters.py
index bcb1fe5..7b77d2c 100644
--- a/pyfr/solvers/base/inters.py
+++ b/pyfr/solvers/base/inters.py
@@ -66,9 +66,6 @@ class BaseInters(object):
     def _vect_view(self, inter, meth):
         return self._view(inter, meth, (self.ndims, self.nvars))
 
-    def _avis_view(self, inter, meth):
-        return self._view(inter, meth)
-
     def _xchg_view(self, inter, meth, vshape=tuple()):
         vm = _get_inter_objs(inter, meth, self._elemap)
         vm = [np.concatenate(m)[self._perm] for m in zip(*vm)]
@@ -79,6 +76,3 @@ class BaseInters(object):
 
     def _vect_xchg_view(self, inter, meth):
         return self._xchg_view(inter, meth, (self.ndims, self.nvars))
-
-    def _avis_xchg_view(self, inter, meth):
-        return self._xchg_view(inter, meth)
diff --git a/pyfr/solvers/baseadvec/inters.py b/pyfr/solvers/baseadvec/inters.py
index 6b6dcde..7425605 100644
--- a/pyfr/solvers/baseadvec/inters.py
+++ b/pyfr/solvers/baseadvec/inters.py
@@ -97,7 +97,7 @@ class BaseAdvectionBCInters(BaseInters):
         else:
             return [npeval(cfg.getexpr(sect, k), cc) for k in opts]
 
-    def _exp_opts(self, opts, lhs, default=None):
+    def _exp_opts(self, opts, lhs, default={}):
         cfg, sect = self.cfg, self.cfgsect
 
         subs = cfg.items('constants')
@@ -106,14 +106,10 @@ class BaseAdvectionBCInters(BaseInters):
 
         exprs = {}
         for k in opts:
-            if default is None:
-                ex = cfg.getexpr(sect, k, subs=subs)
-            elif isinstance(default, dict):
-                ex = cfg.getexpr(sect, k, default.get(k, None), subs=subs)
+            if k in default:
+                exprs[k] = cfg.getexpr(sect, k, default[k], subs=subs)
             else:
-                ex = cfg.getexpr(sect, k, default, subs=subs)
-
-            exprs[k] = ex
+                exprs[k] = cfg.getexpr(sect, k, subs=subs)
 
         if any('ploc' in ex for ex in exprs.values()):
             plocpts = self._const_mat(lhs, 'get_ploc_for_inter')
diff --git a/pyfr/solvers/navstokes/inters.py b/pyfr/solvers/navstokes/inters.py
index e16e0e5..7cad8ee 100644
--- a/pyfr/solvers/navstokes/inters.py
+++ b/pyfr/solvers/navstokes/inters.py
@@ -21,8 +21,8 @@ class NavierStokesIntInters(BaseAdvectionDiffusionIntInters):
         # Generate the additional view matrices for artificial viscosity
         shock_capturing = self.cfg.get('solver', 'shock-capturing', 'none')
         if shock_capturing == 'artificial-viscosity':
-            avis0_lhs = self._avis_view(lhs, 'get_avis_fpts_for_inter')
-            avis0_rhs = self._avis_view(rhs, 'get_avis_fpts_for_inter')
+            avis0_lhs = self._view(lhs, 'get_avis_fpts_for_inter')
+            avis0_rhs = self._view(rhs, 'get_avis_fpts_for_inter')
             tplargs['art_vis'] = 'mu'
         else:
             avis0_lhs = avis0_rhs = None
@@ -58,7 +58,7 @@ class NavierStokesMPIInters(BaseAdvectionDiffusionMPIInters):
         # Generate the additional kernels/views for artificial viscosity
         shock_capturing = self.cfg.get('solver', 'shock-capturing', 'none')
         if shock_capturing == 'artificial-viscosity':
-            avis0_lhs = self._avis_xchg_view(lhs, 'get_avis_fpts_for_inter')
+            avis0_lhs = self._xchg_view(lhs, 'get_avis_fpts_for_inter')
             avis0_rhs = be.xchg_matrix_for_view(avis0_lhs)
 
             # If we need to send our artificial viscosity to the RHS
@@ -122,7 +122,7 @@ class NavierStokesBaseBCInters(BaseAdvectionDiffusionBCInters):
         # Generate the additional view matrices for artificial viscosity
         shock_capturing = self.cfg.get('solver', 'shock-capturing', 'none')
         if shock_capturing == 'artificial-viscosity':
-            avis0_lhs = self._avis_view(lhs, 'get_avis_fpts_for_inter')
+            avis0_lhs = self._view(lhs, 'get_avis_fpts_for_inter')
             tplargs['art_vis'] = 'mu'
         else:
             avis0_lhs = None
@@ -207,7 +207,7 @@ class NavierStokesSubInflowFrvBCInters(NavierStokesBaseBCInters):
 
         tplc, self._ploc = self._exp_opts(
             ['rho', 'u', 'v', 'w'][:self.ndims + 1], lhs,
-            default={'u':0, 'v': 0, 'w':0}
+            default={'u': 0, 'v': 0, 'w': 0}
         )
 
         self._tpl_c.update(tplc)

-- 
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