Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TopFarm2
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
TOPFARM
TopFarm2
Commits
85751de7
Commit
85751de7
authored
6 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
fixed issues
parent
1725ae6b
No related branches found
No related tags found
1 merge request
!94
Handle disabled mpi
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
topfarm/constraint_components/boundary_component.py
+25
-13
25 additions, 13 deletions
topfarm/constraint_components/boundary_component.py
with
25 additions
and
13 deletions
topfarm/constraint_components/boundary_component.py
+
25
−
13
View file @
85751de7
...
...
@@ -300,7 +300,7 @@ class PolygonBoundaryComp(BoundaryComp):
"""
X
,
Y
=
[
np
.
tile
(
xy
,
(
len
(
self
.
x1
),
1
)).
T
for
xy
in
[
x
,
y
]]
# dim = (ntb, nEdges)
X1
,
Y1
,
X2
,
Y2
=
[
np
.
tile
(
xy
,
(
len
(
x
),
1
))
for
xy
in
[
self
.
x1
,
self
.
y1
,
self
.
x2
,
self
.
y2
]]
X1
,
Y1
,
X2
,
Y2
,
ddist_dX
,
ddist_dY
=
[
np
.
tile
(
xy
,
(
len
(
x
),
1
))
for
xy
in
[
self
.
x1
,
self
.
y1
,
self
.
x2
,
self
.
y2
,
self
.
dEdgeDist_dx
,
self
.
dEdgeDist_dy
]]
# perpendicular distance to edge (dot product)
d12
=
(
self
.
x1
-
X
)
*
self
.
edge_unit_vec
[
0
]
+
(
self
.
y1
-
Y
)
*
self
.
edge_unit_vec
[
1
]
...
...
@@ -339,18 +339,30 @@ class PolygonBoundaryComp(BoundaryComp):
distance
[
use_xy1
]
=
sign_use_xy1
*
d1
[
use_xy1
]
distance
[
use_xy2
]
=
sign_use_xy2
*
d2
[
use_xy2
]
length
=
np
.
sqrt
((
X1
[
use_xy1
]
-
X
[
use_xy1
])
**
2
+
(
Y1
[
use_xy1
]
-
Y
[
use_xy1
])
**
2
)
ddist_dX
[
use_xy1
]
=
sign_use_xy1
*
(
2
*
X
[
use_xy1
]
-
2
*
X1
[
use_xy1
])
/
(
2
*
length
)
ddist_dY
[
use_xy1
]
=
sign_use_xy1
*
(
2
*
Y
[
use_xy1
]
-
2
*
Y1
[
use_xy1
])
/
(
2
*
length
)
length
=
np
.
sqrt
((
X2
[
use_xy2
]
-
X
[
use_xy2
])
**
2
+
(
Y2
[
use_xy2
]
-
Y
[
use_xy2
])
**
2
)
ddist_dX
[
use_xy2
]
=
sign_use_xy2
*
(
2
*
X
[
use_xy2
]
-
2
*
X2
[
use_xy2
])
/
(
2
*
length
)
ddist_dY
[
use_xy2
]
=
sign_use_xy2
*
(
2
*
Y
[
use_xy2
]
-
2
*
Y2
[
use_xy2
])
/
(
2
*
length
)
closest_edge_index
=
np
.
argmin
(
np
.
abs
(
distance
),
1
)
ddist_dx
=
np
.
choose
(
closest_edge_index
,
self
.
dEdgeDist_dx
)
ddist_dy
=
np
.
choose
(
closest_edge_index
,
self
.
dEdgeDist_dy
)
for
use_xy
,
x_p
,
y_p
in
[(
use_xy1
,
self
.
x1
,
self
.
y1
),
(
use_xy2
,
self
.
x2
,
self
.
y2
)]:
tb_i
=
np
.
choose
(
closest_edge_index
,
use_xy
.
T
)
# index of tb that is closer to start/end-point of edge
pt_i
=
np
.
where
(
use_xy
[
tb_i
])[
1
]
# index of points
length
=
np
.
sqrt
((
x_p
[
pt_i
]
-
x
[
tb_i
])
**
2
+
(
y_p
[
pt_i
]
-
y
[
tb_i
])
**
2
)
sign
=
np
.
sign
(
np
.
choose
(
pt_i
,
d12
[
tb_i
].
T
))
ddist_dx
[
tb_i
]
=
sign
*
(
2
*
x
[
tb_i
]
-
2
*
x_p
[
pt_i
])
/
(
2
*
length
)
ddist_dy
[
tb_i
]
=
sign
*
(
2
*
y
[
tb_i
]
-
2
*
y_p
[
pt_i
])
/
(
2
*
length
)
return
np
.
choose
(
closest_edge_index
,
distance
.
T
)
,
ddist_d
x
,
ddist_d
y
#
ddist_dx = np.choose(closest_edge_index, self.dEdgeDist_dx)
#
ddist_dy = np.choose(closest_edge_index, self.dEdgeDist_dy)
#
#
for use_xy, x_p, y_p in [(use_xy1, self.x1, self.y1), (use_xy2, self.x2, self.y2)]:
#
tb_i = np.choose(closest_edge_index, use_xy.T) # index of tb that is closer to start/end-point of edge
#
pt_i = np.where(use_xy[tb_i])[1] # index of points
#
length = np.sqrt((x_p[pt_i] - x[tb_i])**2 + (y_p[pt_i] - y[tb_i])**2)
#
sign = np.sign(np.choose(pt_i, d12[tb_i].T))
#
ddist_dx[tb_i] = sign * (2 * x[tb_i] - 2 * x_p[pt_i]) / (2 * length)
#
ddist_dy[tb_i] = sign * (2 * y[tb_i] - 2 * y_p[pt_i]) / (2 * length)
return
[
np
.
choose
(
closest_edge_index
,
v
.
T
)
for
v
in
[
distance
,
ddist_d
X
,
ddist_d
Y
]]
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