Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DVGeoMulti test fix #199

Merged
merged 5 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pygeo/parameterization/DVGeoMulti.py
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,7 @@ def update(self, ptSetName, delta):
return delta

# Define an epsilon to avoid dividing by zero later on
eps = 1e-50
eps = 1e-20

# Get the two end points for the line elements
r0 = coor[conn[:, 0]]
Expand Down Expand Up @@ -1508,8 +1508,8 @@ def update(self, ptSetName, delta):
# Compute denominators for the integral evaluations
# Add an epsilon so that these terms never become zero
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but maybe this comment should also be updated slightly now that we use min?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have updated the comment. Please check if the new version makes sense. I also moved the definition of eps to the init so that it is defined once to be consistent between the analysis and derivative routines. Previously it was defined in two places which could have caused some issues if someone forgot to change one of them.

# disc <= 0, sabc and sc >= 0, therefore the den1 and den2 should be <=0
den1 = disc * sabc - eps
den2 = disc * sc - eps
den1 = np.minimum(disc * sabc, -eps)
den2 = np.minimum(disc * sc, -eps)

# integral evaluations
eval1 = (-2 * (2 * a + b) / den1 + 2 * b / den2) * length
Expand Down Expand Up @@ -1550,7 +1550,7 @@ def sens(self, dIdPt, ptSetName, comm):
conn = self.seamConn

# Define an epsilon to avoid dividing by zero later on
eps = 1e-50
eps = 1e-20

# Get the two end points for the line elements
r0 = coor[conn[:, 0]]
Expand Down Expand Up @@ -1598,8 +1598,8 @@ def sens(self, dIdPt, ptSetName, comm):
sc = np.sqrt(c)

# Compute denominators for the integral evaluations
den1 = disc * sabc - eps
den2 = disc * sc - eps
den1 = np.minimum(disc * sabc, -eps)
den2 = np.minimum(disc * sc, -eps)

# integral evaluations
eval1 = (-2 * (2 * a + b) / den1 + 2 * b / den2) * length
Expand Down
36 changes: 18 additions & 18 deletions tests/reg_tests/ref/test_DVGeometryMulti.ref
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
0.5000000000000001
],
[
0.7558449428676686,
-0.24394738447815498,
0.5999996601638932
0.7558449426479021,
-0.2439473847057298,
0.5999997165630315
],
[
0.256052615521845,
-0.2558449428676688,
0.5999996601638931
0.2560526152942702,
-0.2558449426479023,
0.5999997165630314
],
[
0.244155058456546,
Expand All @@ -58,9 +58,9 @@
0.49999999999999994
],
[
0.24708302434712967,
0.11366224292977958,
0.5099995525452042
0.24708313975314067,
0.1136576670970726,
0.5099996220283098
],
[
0.4991275125824375,
Expand All @@ -83,14 +83,14 @@
0.5
],
[
0.5033972433771731,
0.2501558793802895,
0.39999967796693864
0.5034043514208585,
0.2501560711472582,
0.399999734349053
],
[
0.7439510846445981,
0.2556895615629042,
0.599999995198642
0.7439510052288243,
0.25569291087605306,
0.6000000785150911
],
[
0.4940512221529827,
Expand All @@ -103,9 +103,9 @@
0.6
],
[
0.5058601713172411,
-0.2498982730316979,
0.5999996580987095
0.5058672786729258,
-0.24989810383051725,
0.5999997144892112
],
[
0.24999999999999997,
Expand Down
3 changes: 3 additions & 0 deletions tests/reg_tests/test_DVGeometryMulti.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
class TestDVGeoMulti(unittest.TestCase):
N_PROCS = 1

def train_boxes(self, train=True):
self.test_boxes(train=train)

def test_boxes(self, train=False):
# box1 and box2 intersect
# box3 does not intersect anything
Expand Down