2010-04-29 22:29:35 -07:00
|
|
|
#!/usr/bin/env python
|
2010-04-23 15:29:31 -07:00
|
|
|
|
|
|
|
import math
|
|
|
|
from baker import run_baker
|
2010-04-29 22:29:35 -07:00
|
|
|
from baker.tools import improved_answer
|
|
|
|
|
|
|
|
from baker.tools import smblog
|
2010-04-23 15:29:31 -07:00
|
|
|
|
|
|
|
from grid.DD import grid
|
|
|
|
from grid.simplex import contains
|
|
|
|
|
|
|
|
def exact_func(X):
|
|
|
|
x = X[0]
|
|
|
|
y = X[0]
|
|
|
|
return 1 - math.sin((x-0.5)**2 + (y-0.5)**2)
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
points = [
|
|
|
|
[ 0.25, 0.40], # 0
|
|
|
|
[ 0.60, 0.80], # 1
|
|
|
|
[ 0.65, 0.28], # 2
|
|
|
|
[ 0.28, 0.65], # 3
|
|
|
|
[ 1.00, 0.75], # 4
|
|
|
|
[ 0.30, 0.95], # 5
|
|
|
|
[ 0.80, 0.50], # 6
|
|
|
|
[ 0.35, 0.15], # 7
|
|
|
|
]
|
|
|
|
q = [exact_func(p) for p in points]
|
|
|
|
|
|
|
|
X = [0.55, 0.45]
|
|
|
|
|
|
|
|
g = grid(points, q)
|
|
|
|
g.construct_connectivity()
|
|
|
|
R = g.create_mesh(range(3))
|
|
|
|
|
|
|
|
print contains(X, R.points)
|
|
|
|
|
2010-04-29 22:29:35 -07:00
|
|
|
try:
|
|
|
|
extra = int(sys.argv[1])
|
|
|
|
except:
|
|
|
|
extra = 3
|
|
|
|
|
2010-04-23 15:29:31 -07:00
|
|
|
S = g.create_mesh(range(3, 3 + extra))
|
|
|
|
|
2010-04-29 22:29:35 -07:00
|
|
|
for i in xrange(1,4):
|
|
|
|
answer = run_baker(X, R, S, i)
|
|
|
|
exact = exact_func(X)
|
|
|
|
smblog.debug(improved_answer(answer, exact))
|
|
|
|
|
|
|
|
smblog.debug(improved_answer(g.run_baker(X), exact))
|