[pyfr] 34/88: Improve element weighting factors.

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Wed Nov 16 12:05:27 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 e8665a2182c16f16f5270093c82d259a57a302d5
Author: Freddie Witherden <freddie at witherden.org>
Date:   Mon May 9 20:02:08 2016 -0700

    Improve element weighting factors.
    
    Note that these factors do not account for any sparsity in the
    operator matrices.  However, they do now consider the target
    polynomial order of the simulation.
---
 pyfr/partitioners/base.py | 24 +++++++++++++++++++-----
 pyfr/scripts/main.py      | 30 ++++++++++++++++--------------
 2 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/pyfr/partitioners/base.py b/pyfr/partitioners/base.py
index bb581bf..ff622f1 100644
--- a/pyfr/partitioners/base.py
+++ b/pyfr/partitioners/base.py
@@ -11,12 +11,26 @@ Graph = namedtuple('Graph', ['vtab', 'etab', 'vwts', 'ewts'])
 
 
 class BasePartitioner(object):
-    # Approximate element weighting table
-    _ele_wts = {'quad': 3, 'tri': 2, 'tet': 2, 'hex': 6, 'pri': 4, 'pyr': 3}
-
-    def __init__(self, partwts, opts={}):
+    # Approximate element weightings at each polynomial order
+    elewtsmap = {
+        1: {'quad': 5, 'tri': 3, 'tet': 3, 'hex': 9, 'pri': 6, 'pyr': 4},
+        2: {'quad': 6, 'tri': 3, 'tet': 3, 'hex': 16, 'pri': 8, 'pyr': 5},
+        3: {'quad': 6, 'tri': 3, 'tet': 3, 'hex': 24, 'pri': 10, 'pyr': 6},
+        4: {'quad': 7, 'tri': 3, 'tet': 3, 'hex': 30, 'pri': 12, 'pyr': 7},
+        5: {'quad': 7, 'tri': 3, 'tet': 3, 'hex': 34, 'pri': 13, 'pyr': 7},
+        6: {'quad': 8, 'tri': 3, 'tet': 3, 'hex': 38, 'pri': 14, 'pyr': 8}
+    }
+
+    def __init__(self, partwts, elewts=None, order=None, opts={}):
         self.partwts = partwts
 
+        if elewts is not None:
+            self.elewts = elewts
+        elif order is not None:
+            self.elewts = self.elewtsmap[min(order, max(self.elewtsmap))]
+        else:
+            raise ValueError('Must provide either elewts or order')
+
         # Parse the options list
         self.opts = {}
         for k, v in dict(self.dflt_opts, **opts).items():
@@ -123,7 +137,7 @@ class BasePartitioner(object):
         etab = np.array([etivmap[tuple(r)] for r in rhs])
 
         # Prepare the list of vertex and edge weights
-        vwts = np.array([self._ele_wts[t] for t, i in vetimap])
+        vwts = np.array([self.elewts[t] for t, i in vetimap])
         ewts = np.ones_like(etab)
 
         return Graph(vtab, etab, vwts, ewts), vetimap
diff --git a/pyfr/scripts/main.py b/pyfr/scripts/main.py
index 0afdd64..79ede1f 100755
--- a/pyfr/scripts/main.py
+++ b/pyfr/scripts/main.py
@@ -44,38 +44,39 @@ def main():
     # Partition command
     ap_partition = sp.add_parser('partition', help='partition --help')
     ap_partition.add_argument('np', help='number of partitions or a colon '
-                              'delimited list of weighs')
+                              'delimited list of weights')
     ap_partition.add_argument('mesh', help='input mesh file')
-    ap_partition.add_argument('solns', nargs='*',
+    ap_partition.add_argument('solns', metavar='soln', nargs='*',
                               help='input solution files')
-    ap_partition.add_argument(dest='outd', help='output directory')
+    ap_partition.add_argument('outd', help='output directory')
     partitioners = sorted(cls.name for cls in subclasses(BasePartitioner))
     ap_partition.add_argument('-p', dest='partitioner', choices=partitioners,
                               help='partitioner to use')
     ap_partition.add_argument('--popt', dest='popts', action='append',
                               default=[], metavar='key:value',
                               help='partitioner-specific option')
+    ap_partition.add_argument('-t', dest='order', type=int, default=3,
+                              help='target polynomial order; aids in '
+                              'load-balancing mixed meshes')
     ap_partition.set_defaults(process=process_partition)
 
     # Export command
-    ap_export = sp.add_parser('export', help='export --help',
-                              description='Converts .pyfr[ms] files for '
-                              'visualisation in external software.')
+    ap_export = sp.add_parser('export', help='export --help')
     ap_export.add_argument('meshf', help='PyFR mesh file to be converted')
     ap_export.add_argument('solnf', help='PyFR solution file to be converted')
-    ap_export.add_argument('outf', type=str, help='Output filename')
+    ap_export.add_argument('outf', type=str, help='output file')
     types = [cls.name for cls in subclasses(BaseWriter)]
     ap_export.add_argument('-t', dest='type', choices=types, required=False,
-                           help='Output file type; this is usually inferred '
+                           help='output file type; this is usually inferred '
                            'from the extension of outf')
     ap_export.add_argument('-d', '--divisor', type=int, default=0,
-                           help='Sets the level to which high order elements '
+                           help='sets the level to which high order elements '
                            'are divided; output is linear between nodes, so '
                            'increased resolution may be required')
     ap_export.add_argument('-g', '--gradients', action='store_true',
-                           help='Compute gradients')
+                           help='compute gradients')
     ap_export.add_argument('-p', '--precision', choices=['single', 'double'],
-                           default='single', help='Output number precision, '
+                           default='single', help='output number precision; '
                            'defaults to single')
     ap_export.set_defaults(process=process_export)
 
@@ -97,7 +98,7 @@ def main():
     backends = sorted(cls.name for cls in subclasses(BaseBackend))
     for p in [ap_run, ap_restart]:
         p.add_argument('--backend', '-b', choices=backends, required=True,
-                       help='Backend to use')
+                       help='backend to use')
         p.add_argument('--progress', '-p', action='store_true',
                        help='show a progress bar')
 
@@ -144,11 +145,12 @@ def process_partition(args):
 
     # Create the partitioner
     if args.partitioner:
-        part = get_partitioner(args.partitioner, pwts, opts)
+        part = get_partitioner(args.partitioner, pwts, order=args.order,
+                               opts=opts)
     else:
         for name in sorted(cls.name for cls in subclasses(BasePartitioner)):
             try:
-                part = get_partitioner(name, pwts)
+                part = get_partitioner(name, pwts, order=args.order)
                 break
             except OSError:
                 pass

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