merged the gmsh meshes (2/3D) into a single mesh, updated other files to support this
This commit is contained in:
+12
-11
@@ -4,13 +4,21 @@ import pickle
|
||||
|
||||
import numpy as np
|
||||
|
||||
from optparse import OptionParser
|
||||
|
||||
import interp.bootstrap
|
||||
from interp.grid.delaunay import dgrid
|
||||
from interp.tools import improved_answer, friendly_exact_3D as exact
|
||||
|
||||
|
||||
def test_success(rcount, count):
|
||||
v = np.random.random((rcount, 3)) * 10
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print >> sys.stderr, "usage: %s <number of random points> <number of attempted interps>" % sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
rcount, count = (int(i) for i in sys.argv[1:])
|
||||
|
||||
v = np.random.random((rcount, 3))
|
||||
pickle.dump(v, open('/tmp/v.p', 'w'))
|
||||
q = np.array([exact(x) for x in v])
|
||||
|
||||
@@ -34,15 +42,8 @@ def test_success(rcount, count):
|
||||
results[improved_answer(a, e)] += 1
|
||||
i += 1
|
||||
except Exception as e:
|
||||
print e
|
||||
outside += 1
|
||||
|
||||
print "total skipped points: %d" % outside
|
||||
return results
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 3:
|
||||
print >> sys.stderr, "usage: %s <number of random points> <number of attempted interps>" % sys.argv[0]
|
||||
sys.exit(1)
|
||||
|
||||
rcount, count = (int(i) for i in sys.argv[1:])
|
||||
print test_success(rcount, int(count))
|
||||
print results
|
||||
|
||||
+33
-15
@@ -7,9 +7,9 @@ import numpy as np
|
||||
from optparse import OptionParser
|
||||
|
||||
import interp.bootstrap
|
||||
from interp.grid.gmsh import gmsh_grid3D, gmsh_grid
|
||||
from interp.tools import *
|
||||
|
||||
from interp.grid.gmsh import ggrid
|
||||
from interp.grid.delaunay import dgrid
|
||||
from interp.tools import improved_answer, baker_exact_2D, baker_exact_3D, friendly_exact_2D, friendly_exact_3D
|
||||
|
||||
def get_right_exact_func(options):
|
||||
f = None
|
||||
@@ -25,10 +25,9 @@ def get_right_exact_func(options):
|
||||
f = friendly_exact_2D
|
||||
return f
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = OptionParser(usage = "%prog [options] <input file> <number of attempts>")
|
||||
|
||||
parser = OptionParser(usage = "%prog [options] <input file (gmsh) or random grid count (delaunay)> <number of attempts>")
|
||||
|
||||
parser.add_option("-v", "--verbose",
|
||||
action="store_true", dest="verbose", default=False,
|
||||
@@ -38,12 +37,19 @@ if __name__ == '__main__':
|
||||
action="store_true", dest="baker", default=False,
|
||||
help="use more impressive baker funcs")
|
||||
|
||||
meshtype_options = ('gmsh', 'delaunay')
|
||||
parser.add_option('-t', '--type',
|
||||
type="str", dest="meshtype", default='dgrid',
|
||||
help="specify mesh type (default: %default, options gmsh, delaunay)")
|
||||
|
||||
parser.add_option("-d", "--dimension",
|
||||
type="int", dest="dimension", default=3,
|
||||
help="use 3D or 2D gmsh lib (default: %default)")
|
||||
|
||||
parser.add_option("-o", "--order",
|
||||
type="int", dest="order", default=3,
|
||||
help="order of interpolation (default: %default)")
|
||||
|
||||
parser.add_option("-e", "--extra-points",
|
||||
type="int", dest="extra", default=3,
|
||||
help="number of extra points (default: %default)")
|
||||
@@ -51,26 +57,38 @@ if __name__ == '__main__':
|
||||
|
||||
(options, args) = parser.parse_args()
|
||||
if len(args) != 2:
|
||||
# print >> sys.stderr, "usage: %s <input file> <number of attempts>" % sys.argv[0]
|
||||
parser.print_usage()
|
||||
sys.exit(1)
|
||||
|
||||
input_file, count = args
|
||||
|
||||
if options.dimension == 3:
|
||||
g = gmsh_grid3D(input_file)
|
||||
if options.meshtype == 'gmsh':
|
||||
g = ggrid(input_file, options.dimension)
|
||||
elif options.meshtype == 'delaunay':
|
||||
point_count = int(input_file)
|
||||
v = np.random.random((point_count, options.dimension))
|
||||
g = dgrid(v)
|
||||
else:
|
||||
g = gmsh_grid(input_file)
|
||||
raise Exception("improper mesh type specified. options: %s\n%s" % (str(meshtype_options), options.meshtype))
|
||||
|
||||
g.q = np.array([get_right_exact_func(options)(x) for x in g.verts])
|
||||
|
||||
results = {True:0, False:0}
|
||||
for i in xrange(int(count)):
|
||||
X = np.random.random((1,options.dimension))[0]
|
||||
i = 0
|
||||
outside = 0
|
||||
while i < int(count):
|
||||
try:
|
||||
X = np.random.random((1,options.dimension))[0]
|
||||
|
||||
a = g.run_baker(X, order = options.order, extra_points = options.extra)
|
||||
e = get_right_exact_func(options)(X)
|
||||
a = g.run_baker(X, order = options.order, extra_points = options.extra)
|
||||
e = get_right_exact_func(options)(X)
|
||||
|
||||
results[improved_answer(a, e)] += 1
|
||||
results[improved_answer(a, e)] += 1
|
||||
i += 1
|
||||
except Exception as e:
|
||||
print e
|
||||
print X, i, count
|
||||
outside += 1
|
||||
|
||||
print "total skipped points: %d" % outside
|
||||
print results
|
||||
|
||||
Reference in New Issue
Block a user