From 8165646026ec85dfb6b7c63f3e9f86f3abb2ebb3 Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Sat, 9 Jan 2016 15:50:10 -0600
Subject: [PATCH] Advection: numpy -> np

---
 grudge/models/advection.py | 48 ++++++++++++++++----------------------
 1 file changed, 20 insertions(+), 28 deletions(-)

diff --git a/grudge/models/advection.py b/grudge/models/advection.py
index 4165724b..3f5da969 100644
--- a/grudge/models/advection.py
+++ b/grudge/models/advection.py
@@ -1,8 +1,7 @@
 # -*- coding: utf8 -*-
 """Operators modeling advective phenomena."""
 
-from __future__ import division
-from __future__ import absolute_import
+from __future__ import division, absolute_import
 
 __copyright__ = "Copyright (C) 2009 Andreas Kloeckner"
 
@@ -27,9 +26,7 @@ THE SOFTWARE.
 """
 
 
-
-
-import numpy
+import numpy as np
 import numpy.linalg as la
 
 import grudge.data
@@ -37,8 +34,6 @@ from grudge.models import HyperbolicOperator
 from grudge.second_order import CentralSecondDerivative
 
 
-
-
 # {{{ constant-coefficient advection ------------------------------------------
 class AdvectionOperatorBase(HyperbolicOperator):
     flux_types = [
@@ -47,7 +42,8 @@ class AdvectionOperatorBase(HyperbolicOperator):
             "lf"
             ]
 
-    def __init__(self, v,
+    def __init__(
+            self, v,
             inflow_tag="inflow",
             inflow_u=grudge.data.make_tdep_constant(0),
             outflow_tag="outflow",
@@ -68,13 +64,13 @@ class AdvectionOperatorBase(HyperbolicOperator):
         normal = make_normal(self.dimensions)
 
         if self.flux_type == "central":
-            return u.avg*numpy.dot(normal, self.v)
+            return u.avg*np.dot(normal, self.v)
         elif self.flux_type == "lf":
-            return u.avg*numpy.dot(normal, self.v) \
+            return u.avg*np.dot(normal, self.v) \
                     + 0.5*la.norm(self.v)*(u.int - u.ext)
         elif self.flux_type == "upwind":
-            return (numpy.dot(normal, self.v)*
-                    IfPositive(numpy.dot(normal, self.v),
+            return (np.dot(normal, self.v)*
+                    IfPositive(np.dot(normal, self.v),
                         u.int, # outflow
                         u.ext, # inflow
                         ))
@@ -129,7 +125,7 @@ class StrongAdvectionOperator(AdvectionOperatorBase):
         u = FluxScalarPlaceholder(0)
         normal = make_normal(self.dimensions)
 
-        return u.int * numpy.dot(normal, self.v) - self.weak_flux()
+        return u.int * np.dot(normal, self.v) - self.weak_flux()
 
     def sym_operator(self):
         from grudge.symbolic import Field, BoundaryPair, \
@@ -144,7 +140,7 @@ class StrongAdvectionOperator(AdvectionOperatorBase):
         flux_op = get_flux_operator(self.flux())
 
         return (
-                -numpy.dot(self.v, nabla*u)
+                -np.dot(self.v, nabla*u)
                 + m_inv(
                 flux_op(u)
                 + flux_op(BoundaryPair(u, bc_in, self.inflow_tag))))
@@ -181,7 +177,7 @@ class WeakAdvectionOperator(AdvectionOperatorBase):
 
         flux_op = get_flux_operator(self.flux())
 
-        return m_inv(numpy.dot(self.v, stiff_t*u) - (
+        return m_inv(np.dot(self.v, stiff_t*u) - (
                     flux_op(u)
                     + flux_op(BoundaryPair(u, bc_in, self.inflow_tag))
                     + flux_op(BoundaryPair(u, bc_out, self.outflow_tag))
@@ -190,8 +186,6 @@ class WeakAdvectionOperator(AdvectionOperatorBase):
 # }}}
 
 
-
-
 # {{{ variable-coefficient advection ------------------------------------------
 class VariableCoefficientAdvectionOperator(HyperbolicOperator):
     """A class for space- and time-dependent DG advection operators.
@@ -243,20 +237,20 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator):
         normal = make_normal(self.dimensions)
 
         if self.flux_type == "central":
-            return (u.int*numpy.dot(v.int, normal )
-                    + u.ext*numpy.dot(v.ext, normal)) * 0.5
+            return (u.int*np.dot(v.int, normal )
+                    + u.ext*np.dot(v.ext, normal)) * 0.5
         elif self.flux_type == "lf":
-            n_vint = numpy.dot(normal, v.int)
-            n_vext = numpy.dot(normal, v.ext)
+            n_vint = np.dot(normal, v.int)
+            n_vext = np.dot(normal, v.ext)
             return 0.5 * (n_vint * u.int + n_vext * u.ext) \
                    - 0.5 * (u.ext - u.int) \
                    * flux_max(c.int, c.ext)
 
         elif self.flux_type == "upwind":
             return (
-                    IfPositive(numpy.dot(normal, v.avg),
-                        numpy.dot(normal, v.int) * u.int, # outflow
-                        numpy.dot(normal, v.ext) * u.ext, # inflow
+                    IfPositive(np.dot(normal, v.avg),
+                        np.dot(normal, v.int) * u.int, # outflow
+                        np.dot(normal, v.ext) * u.ext, # inflow
                         ))
         else:
             raise ValueError("invalid flux type")
@@ -268,7 +262,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator):
         from grudge.symbolic import make_sym_vector
         velocity_vec = make_sym_vector("v", self.dimensions)
         velocity = ElementwiseMaxOperator()(
-                numpy.dot(velocity_vec, velocity_vec)**0.5)
+                np.dot(velocity_vec, velocity_vec)**0.5)
 
         compiled = discr.compile(velocity)
 
@@ -363,7 +357,7 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator):
         quad_u = cse(to_quad(u))
         quad_v = cse(to_quad(v))
 
-        return m_inv(numpy.dot(minv_st, cse(quad_v*quad_u))
+        return m_inv(np.dot(minv_st, cse(quad_v*quad_u))
                 - (flux_op(quad_face_w)
                     + flux_op(BoundaryPair(quad_face_w, bc_w, BTAG_ALL)))) \
                             + diffusion_part
@@ -405,6 +399,4 @@ class VariableCoefficientAdvectionOperator(HyperbolicOperator):
 # }}}
 
 
-
-
 # vim: foldmethod=marker
-- 
GitLab