working on the containing simplex problem. the get containing simplex function works, if the point is in the domain. I am trying to force the domain to contain the point (placing points along perimiter of the mesh). I am not doing that right, but have to run
--HG-- rename : bin/qhull-029.txt => data/qhull-029.txt rename : bin/qhull-029.txt.gv => data/qhull-029.txt.gv
This commit is contained in:
+17
-32
@@ -1,4 +1,5 @@
|
||||
from baker import *
|
||||
from baker.tools import logging as log
|
||||
import numpy as np
|
||||
import sys
|
||||
|
||||
@@ -30,7 +31,7 @@ def get_phis(X, R):
|
||||
phi = np.linalg.solve(A,b)
|
||||
except np.linalg.LinAlgError as e:
|
||||
msg = "warning: get_phis: calculation of phis yielded a linearly dependant system (%s)" % e
|
||||
# TODO: log this -- > print >> sys.stderr, msg
|
||||
log.error(msg)
|
||||
raise smberror(msg)
|
||||
phi = np.dot(np.linalg.pinv(A), b)
|
||||
|
||||
@@ -136,7 +137,7 @@ def get_error_quadratic(phi, R, S):
|
||||
+ b * phi[1] * phi[2]\
|
||||
+ c * phi[2] * phi[0]
|
||||
|
||||
return error_term, a, b, c
|
||||
return error_term
|
||||
|
||||
def get_error_cubic(phi, R, S):
|
||||
B = [] # baker eq 9
|
||||
@@ -181,7 +182,7 @@ def get_error_cubic(phi, R, S):
|
||||
+ f * phi[2] * phi[1] * phi[1]\
|
||||
+ g * phi[0] * phi[1] * phi[2]\
|
||||
|
||||
return error_term, a, b, c
|
||||
return error_term
|
||||
|
||||
|
||||
def run_baker(X, R, S, order=2):
|
||||
@@ -195,37 +196,29 @@ def run_baker(X, R, S, order=2):
|
||||
S = extra points
|
||||
"""
|
||||
|
||||
answer = {
|
||||
'qlin': None,
|
||||
'error': None,
|
||||
'final': None,
|
||||
}
|
||||
# calculate values only for the simplex triangle
|
||||
phi, qlin = qlinear(X, R)
|
||||
|
||||
if len(S.points) == 0:
|
||||
answer = {
|
||||
'a': None,
|
||||
'b': None,
|
||||
'c': None,
|
||||
'qlin': qlin,
|
||||
'error': None,
|
||||
'final': None,
|
||||
}
|
||||
if order == 1:
|
||||
answer['qlin'] = qlin
|
||||
return answer
|
||||
|
||||
if order == 2:
|
||||
error_term, a, b, c = get_error_quadratic(phi, R, S)
|
||||
elif order == 2:
|
||||
error_term = get_error_quadratic(phi, R, S)
|
||||
elif order == 3:
|
||||
error_term, a, b, c = get_error_cubic(phi, R, S)
|
||||
error_term = get_error_cubic(phi, R, S)
|
||||
else:
|
||||
raise smberror('unacceptable order for baker method')
|
||||
|
||||
q_final = qlin + error_term
|
||||
|
||||
answer = {
|
||||
'a': a,
|
||||
'b': b,
|
||||
'c': c,
|
||||
'qlin': qlin,
|
||||
'error': error_term,
|
||||
'final': q_final,
|
||||
}
|
||||
answer['qlin' ] = qlin
|
||||
answer['error'] = error_term
|
||||
answer['final'] = q_final
|
||||
|
||||
return answer
|
||||
|
||||
@@ -243,14 +236,6 @@ def run_baker_3D(X, R, S):
|
||||
# calculate values only for the triangle
|
||||
phi, qlin = qlinear_3D(X, R)
|
||||
|
||||
if [i for i in phi if i <= 0.0]:
|
||||
s = "this is not a containing simplex:\n"
|
||||
s += " X: %s\n" % X
|
||||
s += " R: %s\n" % R
|
||||
s += " phi: %s, sum(%0.4e)\n" % (phi, sum(phi))
|
||||
print >> sys.stderr, s
|
||||
raise smberror("not containing simplex")
|
||||
|
||||
if len(S.points) == 0:
|
||||
answer = {
|
||||
'a': None,
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import os
|
||||
import logging
|
||||
|
||||
logging.basicConfig(
|
||||
level = logging.DEBUG,
|
||||
format = '%(asctime)s %(levelname)s %(message)s',
|
||||
filename = os.path.join(os.sep, 'tmp', 'baker.lol'),
|
||||
)
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
class smberror(Exception):
|
||||
"""
|
||||
this is a silly little exception subclass
|
||||
|
||||
Reference in New Issue
Block a user