Browse Source

simplified a module, and adjusted tests for imports

master
Stephen McQuay 9 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 @@
a = 0.0885;
a = 0.885;
Point(0) = {0, 0, 0, a};
Point(1) = {1, 0, 0, a};
Point(2) = {1, 1, 0, a};


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

@@ -8,7 +8,7 @@ import numpy as np
from scipy.spatial import KDTree

from interp.baker import run_baker
import interp.grid.simplex
from interp.baker import get_phis

import logging
log = logging.getLogger("interp")
@@ -233,7 +233,7 @@ class cell(object):

this simply calls grid.simplex.contains
"""
return interp.grid.simplex.contains(X, [G.verts[i] for i in self.verts])
return contains(X, [G.verts[i] for i in self.verts])

def __str__(self):
# neighbors = [str(i.name) for i in self.neighbors]
@@ -246,3 +246,23 @@ class cell(object):
)

__repr__ = __str__


TOL = 1e-8

def contains(X, R):
"""
tests if X (point) is in R

R is a simplex, represented by a list of n-degree coordinates

it now correctly checks for 2/3-D verts

TODO: write unit test ...
"""
phis = get_phis(X, R)

r = True
if [i for i in phis if i < 0.0 - TOL]:
r = False
return r

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

@@ -1,20 +0,0 @@
from interp.baker import get_phis

TOL = 1e-8

def contains(X, R):
"""
tests if X (point) is in R

R is a simplex, represented by a list of n-degree coordinates

it now correctly checks for 2/3-D verts

TODO: write unit test ...
"""
phis = get_phis(X, R)

r = True
if [i for i in phis if i < 0.0 - TOL]:
r = False
return r

+ 3
- 3
test/baker2dorder.py View File

@@ -6,7 +6,7 @@ from interp import baker
from interp.grid import grid
import numpy as np

from interp.grid.simplex import contains
from interp.grid import contains

def exact_func(point):
x = point[0]
@@ -78,8 +78,8 @@ class Test(unittest.TestCase):
self.answer = baker.run_baker(self.X,self.R,self.S)


# def test_R_contains_X(self):
# self.assertTrue(contains(self.X, self.R.verts))
def test_R_contains_X(self):
self.assertTrue(contains(self.X, self.R.verts))

def test_1(self):
a,b,c,d,e,f = (0,1, 1,2, 2,0)


+ 3
- 3
test/cubic2d.py View File

@@ -2,10 +2,10 @@

import unittest

from interp.baker import run_baker
from interp.baker import run_baker

from interp.grid import grid
from interp.grid.simplex import contains
from interp.grid import grid
from interp.grid import contains

def exact_func(X):
x = X[0]


+ 3
- 3
test/quadratic2d.py View File

@@ -2,10 +2,10 @@

import unittest

from interp.baker import run_baker
from interp.baker import run_baker

from interp.grid import grid
from interp.grid.simplex import contains
from interp.grid import grid
from interp.grid import contains

def exact_func(X):
x = X[0]


Loading…
Cancel
Save