Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
LDD-for-two-phase-flow-systems
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Seus
LDD-for-two-phase-flow-systems
Commits
cb821ed5
Commit
cb821ed5
authored
6 years ago
by
David Seus
Browse files
Options
Downloads
Patches
Plain Diff
fix marking of vertical interfaces
parent
fb380216
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LDDsimulation/boundary_and_interface.py
+11
-7
11 additions, 7 deletions
LDDsimulation/boundary_and_interface.py
with
11 additions
and
7 deletions
LDDsimulation/boundary_and_interface.py
+
11
−
7
View file @
cb821ed5
...
...
@@ -171,17 +171,21 @@ class BoundaryPart(df.SubDomain):
ymin
=
min
(
p1
[
1
],
p2
[
1
])
ymax
=
max
(
p1
[
1
],
p2
[
1
])
# print(f"test if point {p} is on line segment between {p1} or {p2}")
#
equality check
if
np
.
abs
olute
((
p
[
0
]
-
xmax
)
*
(
p
[
0
]
-
xmin
))
<
tol
and
np
.
abs
olute
((
p
[
1
]
-
ymax
)
*
(
p
[
1
]
-
ymin
))
<
tol
:
#
check if p == p1 or p == p2
if
np
.
f
abs
((
p
[
0
]
-
xmax
)
*
(
p
[
0
]
-
xmin
))
<
tol
and
np
.
f
abs
((
p
[
1
]
-
ymax
)
*
(
p
[
1
]
-
ymin
))
<
tol
:
#print(f"point {p} is close to either {p1} or {p2}")
return
True
# check there holds p1[0] < p[0] < p2[0]. If not, p cannot be on the line segment
# the test ((p[0] - xmax)*(p[0] - xmin) < 0) might fail if p[0] and one of p1[0]
# or p2[0] are equal. In pp1 or pp2 is vertical. We need to still calculate
# the distance to the line segment in this case
if
((
p
[
0
]
-
xmax
)
*
(
p
[
0
]
-
xmin
)
<
tol
)
or
np
.
absolute
((
p
[
0
]
-
xmax
)
*
(
p
[
0
]
-
xmin
))
<
tol
:
# same needs to be done for p1[1] < p[1] < p2[1]
# the test ((p[0] - xmax)*(p[0] - xmin) < 0) might fail if p[0] and one
# of p1[0] or p2[0] are equal. In this case the line pp1 or pp2 is
# vertical. We need to still calculate the distance to the line segment
# in this case. Same is true for ((p[1] - ymax)*(p[1] - ymin) < 0)
x_is_in_range
=
((
p
[
0
]
-
xmax
)
*
(
p
[
0
]
-
xmin
)
<
tol
)
or
np
.
fabs
((
p
[
0
]
-
xmax
)
*
(
p
[
0
]
-
xmin
))
<
tol
y_is_in_range
=
((
p
[
1
]
-
ymax
)
*
(
p
[
1
]
-
ymin
)
<
tol
)
or
np
.
fabs
((
p
[
1
]
-
ymax
)
*
(
p
[
1
]
-
ymin
))
<
tol
if
x_is_in_range
and
y_is_in_range
:
# here we have a chance to actually lie on the line segment.
segment_direction
=
(
p2
-
p1
)
/
np
.
linalg
.
norm
(
p2
-
p1
)
distance
=
(
p
-
p1
)
-
np
.
dot
(
segment_direction
,
p
-
p1
)
*
segment_direction
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment