Browse Source

simplified a module, and adjusted tests for imports

Stephen McQuay 7 years ago
parent
commit
b54272bb85
6 changed files with 32 additions and 32 deletions
  1. 1
    1
      gmsh/gmsh.3D.geo
  2. 22
    2
      interp/grid/__init__.py
  3. 0
    20
      interp/grid/simplex.py
  4. 3
    3
      test/baker2dorder.py
  5. 3
    3
      test/cubic2d.py
  6. 3
    3
      test/quadratic2d.py

+ 1
- 1
gmsh/gmsh.3D.geo View File

@@ -1,4 +1,4 @@
1
-a = 0.0885;
1
+a = 0.885;
2 2
 Point(0) = {0, 0, 0, a};
3 3
 Point(1) = {1, 0, 0, a};
4 4
 Point(2) = {1, 1, 0, a};

+ 22
- 2
interp/grid/__init__.py View File

@@ -8,7 +8,7 @@ import numpy as np
8 8
 from scipy.spatial import KDTree
9 9
 
10 10
 from interp.baker import run_baker
11
-import interp.grid.simplex
11
+from interp.baker import get_phis
12 12
 
13 13
 import logging
14 14
 log = logging.getLogger("interp")
@@ -233,7 +233,7 @@ class cell(object):
233 233
 
234 234
       this simply calls grid.simplex.contains
235 235
     """
236
-    return interp.grid.simplex.contains(X, [G.verts[i] for i in self.verts])
236
+    return contains(X, [G.verts[i] for i in self.verts])
237 237
 
238 238
   def __str__(self):
239 239
     # neighbors = [str(i.name) for i in self.neighbors]
@@ -246,3 +246,23 @@ class cell(object):
246 246
            )
247 247
 
248 248
   __repr__ = __str__
249
+
250
+
251
+TOL = 1e-8
252
+
253
+def contains(X, R):
254
+  """
255
+    tests if X (point) is in R
256
+
257
+    R is a simplex, represented by a list of n-degree coordinates
258
+
259
+    it now correctly checks for 2/3-D verts
260
+
261
+    TODO: write unit test ...
262
+  """
263
+  phis = get_phis(X, R)
264
+
265
+  r = True
266
+  if [i for i in phis if i < 0.0 - TOL]:
267
+    r = False
268
+  return r

+ 0
- 20
interp/grid/simplex.py View File

@@ -1,20 +0,0 @@
1
-from interp.baker import get_phis
2
-
3
-TOL = 1e-8
4
-
5
-def contains(X, R):
6
-  """
7
-    tests if X (point) is in R
8
-
9
-    R is a simplex, represented by a list of n-degree coordinates
10
-
11
-    it now correctly checks for 2/3-D verts
12
-
13
-    TODO: write unit test ...
14
-  """
15
-  phis = get_phis(X, R)
16
-
17
-  r = True
18
-  if [i for i in phis if i < 0.0 - TOL]:
19
-    r = False
20
-  return r

+ 3
- 3
test/baker2dorder.py View File

@@ -6,7 +6,7 @@ from interp import baker
6 6
 from interp.grid import grid
7 7
 import numpy as np
8 8
 
9
-from interp.grid.simplex import contains
9
+from interp.grid import contains
10 10
 
11 11
 def exact_func(point):
12 12
   x = point[0]
@@ -78,8 +78,8 @@ class Test(unittest.TestCase):
78 78
     self.answer = baker.run_baker(self.X,self.R,self.S)
79 79
 
80 80
 
81
-  # def test_R_contains_X(self):
82
-  #   self.assertTrue(contains(self.X, self.R.verts))
81
+  def test_R_contains_X(self):
82
+    self.assertTrue(contains(self.X, self.R.verts))
83 83
 
84 84
   def test_1(self):
85 85
     a,b,c,d,e,f = (0,1,   1,2,   2,0)

+ 3
- 3
test/cubic2d.py View File

@@ -2,10 +2,10 @@
2 2
 
3 3
 import unittest
4 4
 
5
-from interp.baker        import run_baker
5
+from interp.baker import run_baker
6 6
 
7
-from interp.grid         import grid
8
-from interp.grid.simplex import contains
7
+from interp.grid  import grid
8
+from interp.grid  import contains
9 9
 
10 10
 def exact_func(X):
11 11
   x = X[0]

+ 3
- 3
test/quadratic2d.py View File

@@ -2,10 +2,10 @@
2 2
 
3 3
 import unittest
4 4
 
5
-from interp.baker        import run_baker
5
+from interp.baker import run_baker
6 6
 
7
-from interp.grid         import grid
8
-from interp.grid.simplex import contains
7
+from interp.grid  import grid
8
+from interp.grid  import contains
9 9
 
10 10
 def exact_func(X):
11 11
   x = X[0]

Loading…
Cancel
Save