Skip to content

Commit f43e0ad

Browse files
committed
improve loop for mpr phase 2
1 parent 200e671 commit f43e0ad

File tree

1 file changed

+13
-5
lines changed
  • src/contactDetection/ContactDetectionMPR

1 file changed

+13
-5
lines changed

src/contactDetection/ContactDetectionMPR/mpr.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ end
118118
# loop around to "ensure" the tetrahedron r0,r1,r2 and r3 encloses the origin
119119
# stimmt so nicht wirklich, muss ich nochmal nachlesen!!!
120120
# Der Ursprung muss nicht enthalten sein!!!
121-
function tetrahedronEncloseOrigin(r0::SupportPoint,r1::SupportPoint,r2::SupportPoint,r3::SupportPoint,
122-
neps::Float64, niter_max::Int64,
123-
shapeA::Composition.Object3D,shapeB::Composition.Object3D, scale::Float64)
121+
function tetrahedronEncloseOrigin(r0::SupportPoint, r1::SupportPoint,
122+
r2::SupportPoint, r3::SupportPoint,
123+
neps::Float64, niter_max::Int64,
124+
shapeA::Composition.Object3D, shapeB::Composition.Object3D, scale::Float64)
125+
r1org = r1
126+
r2org = r2
127+
r3org = r3
124128
aux = Modia3D.ZeroVector3D
125129
success = false
126130
for i in 1:niter_max
@@ -140,9 +144,13 @@ function tetrahedronEncloseOrigin(r0::SupportPoint,r1::SupportPoint,r2::SupportP
140144
break
141145
end
142146
if success != true
143-
error("MPR: Max. number of iterations is reached in phase2. Look at shapeA = ", shapeA, " shapeB = ", shapeB)
147+
@warn("MPR (phase 2): Max. number of iterations (= $niter_max) is reached. niter_max increased locally by 10 and phase 2 is rerun until counter is bigger than 100.")
148+
if niter_max < 100
149+
tetrahedronEncloseOrigin(r0, r1org, r2org, r3org, neps, niter_max + 10, shapeA, shapeB, scale)
150+
else
151+
error("MPR (phase 2): Max. number of iterations (= $niter_max) is reached and $niter_max > 100.")
152+
end
144153
end
145-
# pointInTetrahedron(r0.p,r1.p,r2.p,r3.p,SVector(0.0, 0.0, 0.0))
146154
return (r1, r2, r3)
147155
end
148156

0 commit comments

Comments
 (0)