pyviewfactor 0.1.12__tar.gz → 0.1.14__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/PKG-INFO +1 -1
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/_version.py +1 -1
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/pyviewfactor.py +51 -224
- pyviewfactor-0.1.14/pyviewfactor/pyviewfactor_integration.py +1242 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor.egg-info/PKG-INFO +1 -1
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor.egg-info/SOURCES.txt +1 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/LICENSE.txt +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/README.md +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/11pyviewfactor.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/OLD.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/__init__.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/pyviewfactor_906.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/pyviewfactor_BKP12-06.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/pyviewfactor_v1.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/pyviewfactor_vis_obs_OK.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor/pyviewfactorv2.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor.egg-info/dependency_links.txt +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor.egg-info/requires.txt +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/pyviewfactor.egg-info/top_level.txt +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/setup.cfg +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/setup.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/test/__init__.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/test/test_utils.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/test/test_view_factor.py +0 -0
- {pyviewfactor-0.1.12 → pyviewfactor-0.1.14}/test/test_visibility_obstruction.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyviewfactor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.14
|
|
4
4
|
Summary: A python library to calculate numerically exact radiation view factors between planar faces.
|
|
5
5
|
Home-page: https://gitlab.com/arep-dev/pyViewFactor/
|
|
6
6
|
Author: Mateusz BOGDAN, Edouard WALTHER, Marc ALECIAN, Mina CHAPON
|
|
@@ -24,6 +24,7 @@ class ProcessedGeometry:
|
|
|
24
24
|
self.normals = np.zeros((self.N, 3), dtype=np.float64)
|
|
25
25
|
self.centroids = np.zeros((self.N, 3), dtype=np.float64)
|
|
26
26
|
self.areas = np.zeros(self.N, dtype=np.float64)
|
|
27
|
+
self.sizes = np.zeros(self.N, dtype=np.float64)
|
|
27
28
|
|
|
28
29
|
for i in range(self.N):
|
|
29
30
|
raw = mesh.extract_cells(i)
|
|
@@ -42,6 +43,9 @@ class ProcessedGeometry:
|
|
|
42
43
|
self.normals[i] = norm / np.linalg.norm(norm)
|
|
43
44
|
|
|
44
45
|
self.areas[i] = polygon_area(np.round(face.points, rounding_decimal))
|
|
46
|
+
edges = np.roll(pts, -1, axis=0) - pts
|
|
47
|
+
edge_lengths = np.linalg.norm(edges, axis=1)
|
|
48
|
+
self.sizes[i] = np.mean(edge_lengths)
|
|
45
49
|
|
|
46
50
|
def get_face(self, i):
|
|
47
51
|
return self.points[i]
|
|
@@ -55,52 +59,20 @@ class ProcessedGeometry:
|
|
|
55
59
|
def get_area(self, i):
|
|
56
60
|
return self.areas[i]
|
|
57
61
|
|
|
62
|
+
def get_size(self, i):
|
|
63
|
+
return self.sizes[i]
|
|
64
|
+
|
|
58
65
|
|
|
59
66
|
class FaceMeshPreprocessor:
|
|
60
67
|
def __init__(self, mesh: pv.PolyData):
|
|
61
68
|
if not mesh.is_all_triangles:
|
|
62
|
-
mesh = mesh.triangulate
|
|
63
|
-
self.
|
|
69
|
+
mesh = mesh.triangulate()
|
|
70
|
+
self.points = mesh.points.astype(np.float64)
|
|
64
71
|
# cells array is [n, i0, i1, i2, n, ...]
|
|
65
72
|
cells = mesh.faces.reshape(-1,4)[:,1:]
|
|
66
73
|
self.faces = cells # shape (n_cells,3)
|
|
67
74
|
self.triangles = np.array([self.points[c] for c in cells], dtype=np.float64)
|
|
68
|
-
self.points = []
|
|
69
|
-
self.normals = np.zeros((self.N, 3), dtype=np.float64)
|
|
70
|
-
self.centroids = np.zeros((self.N, 3), dtype=np.float64)
|
|
71
|
-
self.areas = np.zeros(self.N, dtype=np.float64)
|
|
72
|
-
for i in range(self.N):
|
|
73
|
-
raw = mesh.extract_cells(i)
|
|
74
|
-
face = fc_unstruc2poly(raw)
|
|
75
|
-
faces_i = face.faces
|
|
76
|
-
n_i = int(faces_i[0])
|
|
77
|
-
idxs = faces_i[1:1 + n_i]
|
|
78
|
-
pts = np.round(face.points[idxs], rounding_decimal)
|
|
79
|
-
|
|
80
|
-
self.points.append(pts)
|
|
81
|
-
self.centroids[i] = polygon_centroid(pts)
|
|
82
|
-
|
|
83
|
-
v1 = pts[1] - pts[0]
|
|
84
|
-
v2 = pts[2] - pts[0]
|
|
85
|
-
norm = np.cross(v1, v2)
|
|
86
|
-
self.normals[i] = norm / np.linalg.norm(norm)
|
|
87
|
-
|
|
88
|
-
self.areas[i] = polygon_area(np.round(face.points, rounding_decimal))
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
def get_face(self, i):
|
|
93
|
-
return self.points[i]
|
|
94
|
-
|
|
95
|
-
def get_normal(self, i):
|
|
96
|
-
return self.normals[i]
|
|
97
|
-
|
|
98
|
-
def get_centroid(self, i):
|
|
99
|
-
return self.centroids[i]
|
|
100
75
|
|
|
101
|
-
def get_area(self, i):
|
|
102
|
-
return self.areas[i]
|
|
103
|
-
|
|
104
76
|
def aabb_filter(self, aabb_min, aabb_max):
|
|
105
77
|
kept = []
|
|
106
78
|
for tri in self.triangles: # tri.shape == (3,3)
|
|
@@ -121,7 +93,6 @@ class FaceMeshPreprocessor:
|
|
|
121
93
|
return np.array(out, dtype=np.float64)
|
|
122
94
|
|
|
123
95
|
|
|
124
|
-
|
|
125
96
|
def face_to_array(face):
|
|
126
97
|
"""Convert a single-cell PolyData face to an (n,3) ndarray."""
|
|
127
98
|
return face.get_cell(0).points.astype(np.float64)
|
|
@@ -183,8 +154,6 @@ def polygon_centroid(pts: np.ndarray) -> np.ndarray:
|
|
|
183
154
|
return p0 + centroid_2D[0] * u + centroid_2D[1] * w
|
|
184
155
|
|
|
185
156
|
|
|
186
|
-
|
|
187
|
-
|
|
188
157
|
@njit
|
|
189
158
|
def face_normal_numpy(pts):
|
|
190
159
|
"""
|
|
@@ -241,18 +210,6 @@ def tri_overlaps_aabb(tri_pts, aabb_min, aabb_max):
|
|
|
241
210
|
)
|
|
242
211
|
|
|
243
212
|
|
|
244
|
-
def face_vertex_set(face_poly, decimals=8):
|
|
245
|
-
"""
|
|
246
|
-
Return a set of sorted rounded (x, y, z) vertex tuples from a face.
|
|
247
|
-
Sorting ensures symmetry regardless of vertex order.
|
|
248
|
-
"""
|
|
249
|
-
raw_pts = face_poly.get_cell(0).points.astype(np.float64)
|
|
250
|
-
raw_pts = np.round(raw_pts, decimals)
|
|
251
|
-
vert_list = [tuple(p) for p in raw_pts]
|
|
252
|
-
vert_set = frozenset(sorted(vert_list))
|
|
253
|
-
return vert_set
|
|
254
|
-
|
|
255
|
-
|
|
256
213
|
@njit
|
|
257
214
|
def ray_intersects_triangle(orig, dest, v0, v1, v2, eps=1e-6):
|
|
258
215
|
# 0) If origin or dest coincides with a vertex, skip this triangle
|
|
@@ -363,31 +320,32 @@ def get_obstruction_from_cache(i, j, cache, obstacle_mesh, strict=False, print_w
|
|
|
363
320
|
|
|
364
321
|
# Optionally, use a similar cache for the obstacle mesh, or extract triangles as needed.
|
|
365
322
|
# For now, fallback to regular PolyData interface:
|
|
366
|
-
if isinstance(obstacle_mesh, FaceMeshPreprocessor):
|
|
367
|
-
triangles = [obstacle_mesh.get_face(t) for t in range(obstacle_mesh.N)]
|
|
368
|
-
else:
|
|
369
|
-
triangles = [obstacle_mesh.get_cell(t).points for t in range(obstacle_mesh.n_cells)]
|
|
323
|
+
# if isinstance(obstacle_mesh, FaceMeshPreprocessor):
|
|
324
|
+
# triangles = [obstacle_mesh.get_face(t) for t in range(obstacle_mesh.N)]
|
|
325
|
+
# else:
|
|
326
|
+
# triangles = [obstacle_mesh.get_cell(t).points for t in range(obstacle_mesh.n_cells)]
|
|
370
327
|
|
|
371
328
|
# Filter triangles by AABB
|
|
372
329
|
all_pts = np.vstack((pts1, pts2))
|
|
373
330
|
aabb_min = np.min(all_pts, axis=0)
|
|
374
331
|
aabb_max = np.max(all_pts, axis=0)
|
|
375
|
-
cand_tris =
|
|
332
|
+
cand_tris = obstacle_mesh.aabb_filter(aabb_min, aabb_max)
|
|
333
|
+
cand_tris = obstacle_mesh.exclude_exact_match(pts1, pts2, cand_tris)
|
|
376
334
|
|
|
377
335
|
# Exclude any triangles exactly matching face i or j
|
|
378
|
-
set1 = {tuple(np.round(p, 8)) for p in pts1}
|
|
379
|
-
set2 = {tuple(np.round(p, 8)) for p in pts2}
|
|
380
|
-
def is_exact_match(tri, sets):
|
|
381
|
-
s = {tuple(np.round(p, 8)) for p in tri}
|
|
382
|
-
return s == sets[0] or s == sets[1]
|
|
383
|
-
cand_tris = [tri for tri in cand_tris if not is_exact_match(tri, [set1, set2])]
|
|
384
|
-
|
|
385
|
-
if
|
|
336
|
+
# set1 = {tuple(np.round(p, 8)) for p in pts1}
|
|
337
|
+
# set2 = {tuple(np.round(p, 8)) for p in pts2}
|
|
338
|
+
# def is_exact_match(tri, sets):
|
|
339
|
+
# s = {tuple(np.round(p, 8)) for p in tri}
|
|
340
|
+
# return s == sets[0] or s == sets[1]
|
|
341
|
+
# cand_tris = [tri for tri in cand_tris if not is_exact_match(tri, [set1, set2])]
|
|
342
|
+
|
|
343
|
+
if cand_tris.size == 0:
|
|
386
344
|
return True, "fully visible"
|
|
387
345
|
|
|
388
346
|
# Strict/non-strict logic:
|
|
389
347
|
if not strict:
|
|
390
|
-
blocked = is_ray_blocked(c1, c2,
|
|
348
|
+
blocked = is_ray_blocked(c1, c2, cand_tris, eps=eps)
|
|
391
349
|
if blocked:
|
|
392
350
|
return False, ""
|
|
393
351
|
else:
|
|
@@ -395,7 +353,7 @@ def get_obstruction_from_cache(i, j, cache, obstacle_mesh, strict=False, print_w
|
|
|
395
353
|
else:
|
|
396
354
|
for p1 in pts1:
|
|
397
355
|
for p2 in pts2:
|
|
398
|
-
if is_ray_blocked(p1, p2,
|
|
356
|
+
if is_ray_blocked(p1, p2, cand_tris, eps=eps):
|
|
399
357
|
warning = "[PVF-Warning-1] Cells are partially obstructed (strict)."
|
|
400
358
|
if print_warning:
|
|
401
359
|
return False, warning
|
|
@@ -443,39 +401,6 @@ def fc_unstruc2poly(mesh_unstruc):
|
|
|
443
401
|
return pv.PolyData(points, faces)
|
|
444
402
|
|
|
445
403
|
|
|
446
|
-
def trunc(values, decs=0):
|
|
447
|
-
"""
|
|
448
|
-
Truncate numeric values to a fixed number of decimals.
|
|
449
|
-
|
|
450
|
-
Parameters
|
|
451
|
-
----------
|
|
452
|
-
values : float or ndarray
|
|
453
|
-
Float or array of floats to truncate.
|
|
454
|
-
decs : int, optional
|
|
455
|
-
Number of decimals to keep (default=0).
|
|
456
|
-
|
|
457
|
-
Returns
|
|
458
|
-
-------
|
|
459
|
-
float or ndarray
|
|
460
|
-
Truncated values.
|
|
461
|
-
|
|
462
|
-
Examples
|
|
463
|
-
--------
|
|
464
|
-
>>> trunc(1.234567, 2)
|
|
465
|
-
1.23
|
|
466
|
-
>>> import pyvista as pv
|
|
467
|
-
>>> tri = pv.Triangle([[0.111111, 1.111111, 1.111111],
|
|
468
|
-
... [1.222222, 1.222222, 1.222222],
|
|
469
|
-
... [1.333333, 0.333333, 1.333333]])
|
|
470
|
-
>>> trunc(tri.points, 2)
|
|
471
|
-
array([[0.11, 1.11, 1.11],
|
|
472
|
-
[1.22, 1.22, 1.22],
|
|
473
|
-
[1.33, 0.33, 1.33]])
|
|
474
|
-
"""
|
|
475
|
-
factor = 10 ** decs
|
|
476
|
-
return np.trunc(values * factor) / factor
|
|
477
|
-
|
|
478
|
-
|
|
479
404
|
# #########################
|
|
480
405
|
# Visibility / Obstrucitons
|
|
481
406
|
# #########################
|
|
@@ -622,6 +547,8 @@ def get_visibility_from_cache(i, j, cache, strict=False, print_warning=False, ro
|
|
|
622
547
|
return True, warning_str
|
|
623
548
|
|
|
624
549
|
return True, ""
|
|
550
|
+
|
|
551
|
+
|
|
625
552
|
# ########################
|
|
626
553
|
# View Factor Computations
|
|
627
554
|
# ########################
|
|
@@ -946,8 +873,8 @@ def compute_viewfactor(cell1, cell2, *, epsilon=1e-6, rounding_decimal=8):
|
|
|
946
873
|
pts2 = face_to_array(cell2)
|
|
947
874
|
|
|
948
875
|
# 2) Small shift along normal‐bisector if they share vertices
|
|
949
|
-
set1 = {tuple(p) for p in pts1}
|
|
950
|
-
set2 = {tuple(p) for p in pts2}
|
|
876
|
+
set1 = {tuple(np.round(p, rounding_decimal)) for p in pts1}
|
|
877
|
+
set2 = {tuple(np.round(p, rounding_decimal)) for p in pts2}
|
|
951
878
|
use_dblquad = bool(set1 & set2)
|
|
952
879
|
if use_dblquad:
|
|
953
880
|
c1 = polygon_centroid(pts1)
|
|
@@ -1010,117 +937,16 @@ def batch_compute_viewfactors(pts1_arr, nverts1, pts2_arr, nverts2, const_arr, v
|
|
|
1010
937
|
# View Factor Full Matrix Computations
|
|
1011
938
|
# ####################################
|
|
1012
939
|
|
|
1013
|
-
# Helper function to compute VF matrix for a complete mesh
|
|
1014
|
-
def _is_blocked(f_i, f_j, obstacles, obstruction_kwargs, skip_obstruction):
|
|
1015
|
-
"""
|
|
1016
|
-
Check whether any obstacle mesh blocks the view between two facets.
|
|
1017
|
-
|
|
1018
|
-
Parameters
|
|
1019
|
-
----------
|
|
1020
|
-
f_i, f_j : pyvista.PolyData
|
|
1021
|
-
Receiving and emitting facets, respectively.
|
|
1022
|
-
obstacles : list of pyvista.PolyData
|
|
1023
|
-
One or more occluder meshes to test.
|
|
1024
|
-
obstruction_kwargs : dict
|
|
1025
|
-
Keyword args forwarded to `get_obstruction(...)`.
|
|
1026
|
-
skip_obstruction : bool
|
|
1027
|
-
If True, skip all obstruction tests (always returns False).
|
|
1028
|
-
|
|
1029
|
-
Returns
|
|
1030
|
-
-------
|
|
1031
|
-
bool
|
|
1032
|
-
True if any obstacle reports a block (i.e., faces do *not* see each other),
|
|
1033
|
-
False otherwise.
|
|
1034
|
-
"""
|
|
1035
|
-
if skip_obstruction or not obstacles:
|
|
1036
|
-
return False
|
|
1037
|
-
for obs in obstacles:
|
|
1038
|
-
vis_obs, _ = get_obstruction(f_i, f_j, obs, **(obstruction_kwargs or {}))
|
|
1039
|
-
if not vis_obs:
|
|
1040
|
-
return True
|
|
1041
|
-
return False
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
def _compute_pair(i, j,
|
|
1045
|
-
faces, areas,
|
|
1046
|
-
obstacles,
|
|
1047
|
-
skip_visibility, skip_obstruction,
|
|
1048
|
-
visibility_kwargs, obstruction_kwargs,
|
|
1049
|
-
epsilon, rounding_decimal,
|
|
1050
|
-
use_reciprocity):
|
|
1051
|
-
"""
|
|
1052
|
-
Compute the view‐factor pair for two facets in a mesh.
|
|
1053
|
-
|
|
1054
|
-
Applies optional visibility and obstruction culling, then computes
|
|
1055
|
-
F[i,j] (and F[j,i] via reciprocity or explicit integration).
|
|
1056
|
-
|
|
1057
|
-
Parameters
|
|
1058
|
-
----------
|
|
1059
|
-
i, j : int
|
|
1060
|
-
Indices of the two facets in the `faces` list.
|
|
1061
|
-
faces : list of pyvista.PolyData
|
|
1062
|
-
All single‐cell facets extracted from the mesh.
|
|
1063
|
-
areas : list of float
|
|
1064
|
-
Precomputed facet areas, matching `faces`.
|
|
1065
|
-
obstacles : list of pyvista.PolyData
|
|
1066
|
-
Occluder meshes.
|
|
1067
|
-
skip_visibility : bool
|
|
1068
|
-
If False, runs `get_visibility` and sets F=0 on fail.
|
|
1069
|
-
skip_obstruction : bool
|
|
1070
|
-
If False, runs `_is_blocked` and sets F=0 on fail.
|
|
1071
|
-
visibility_kwargs : dict
|
|
1072
|
-
Forwarded to `get_visibility`.
|
|
1073
|
-
obstruction_kwargs : dict
|
|
1074
|
-
Forwarded to `get_obstruction`.
|
|
1075
|
-
epsilon : float
|
|
1076
|
-
Small shift magnitude for shared‐vertex cases.
|
|
1077
|
-
rounding_decimal : int
|
|
1078
|
-
Decimal‐rounding for vertex coords.
|
|
1079
|
-
use_reciprocity : bool
|
|
1080
|
-
If True, uses the relation F[j,i] = (A_i/A_j)*F[i,j]
|
|
1081
|
-
otherwise computes both directions.
|
|
1082
|
-
|
|
1083
|
-
Returns
|
|
1084
|
-
-------
|
|
1085
|
-
tuple of (i, j, F_ij, F_ji)
|
|
1086
|
-
Indices and computed view factors. If culled by visibility or
|
|
1087
|
-
obstruction, returns zeros for both F_ij and F_ji.
|
|
1088
|
-
"""
|
|
1089
|
-
f_i, f_j = faces[i], faces[j]
|
|
1090
|
-
|
|
1091
|
-
# 1) Visibility
|
|
1092
|
-
if not skip_visibility:
|
|
1093
|
-
vis, _ = get_visibility(f_i, f_j, **visibility_kwargs)
|
|
1094
|
-
if not vis:
|
|
1095
|
-
return i, j, 0.0, 0.0
|
|
1096
|
-
|
|
1097
|
-
# 2) Obstruction
|
|
1098
|
-
if _is_blocked(f_i, f_j, obstacles, obstruction_kwargs, skip_obstruction):
|
|
1099
|
-
return i, j, 0.0, 0.0
|
|
1100
|
-
|
|
1101
|
-
# 3) View-factor
|
|
1102
|
-
F_ij = compute_viewfactor(f_i, f_j,
|
|
1103
|
-
epsilon=epsilon,
|
|
1104
|
-
rounding_decimal=rounding_decimal)
|
|
1105
|
-
if use_reciprocity:
|
|
1106
|
-
F_ji = F_ij * (areas[j] / areas[i])
|
|
1107
|
-
else:
|
|
1108
|
-
F_ji = compute_viewfactor(f_j, f_i,
|
|
1109
|
-
epsilon=epsilon,
|
|
1110
|
-
rounding_decimal=rounding_decimal)
|
|
1111
|
-
return i, j, F_ij, F_ji
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
940
|
def compute_viewfactor_matrix(
|
|
1115
941
|
mesh,
|
|
1116
942
|
obstacles=None,
|
|
1117
|
-
use_reciprocity=True,
|
|
943
|
+
# use_reciprocity=True,
|
|
1118
944
|
skip_visibility=False,
|
|
1119
945
|
skip_obstruction=False,
|
|
1120
946
|
strict_visibility=False,
|
|
1121
947
|
strict_obstruction=False,
|
|
1122
948
|
rounding_decimal=8,
|
|
1123
|
-
epsilon=1e-
|
|
949
|
+
epsilon=1e-3,
|
|
1124
950
|
verbose=False
|
|
1125
951
|
):
|
|
1126
952
|
"""
|
|
@@ -1163,7 +989,7 @@ def compute_viewfactor_matrix(
|
|
|
1163
989
|
obstacles = []
|
|
1164
990
|
elif not isinstance(obstacles, (list, tuple)):
|
|
1165
991
|
obstacles = [obstacles]
|
|
1166
|
-
|
|
992
|
+
obs_pre = [FaceMeshPreprocessor(obs) for obs in obstacles]
|
|
1167
993
|
# Precompute vertex sets for "touching" logic
|
|
1168
994
|
vertex_sets = [frozenset(tuple(np.round(vert, rounding_decimal)) for vert in pg.get_face(i)) for i in range(N)]
|
|
1169
995
|
|
|
@@ -1191,12 +1017,12 @@ def compute_viewfactor_matrix(
|
|
|
1191
1017
|
if not vis:
|
|
1192
1018
|
continue
|
|
1193
1019
|
# (B) Optional obstruction test
|
|
1194
|
-
if not skip_obstruction and
|
|
1020
|
+
if not skip_obstruction and obs_pre:
|
|
1195
1021
|
blocked = False
|
|
1196
|
-
for obs in
|
|
1022
|
+
for obs in obs_pre:
|
|
1197
1023
|
# You can use your get_obstruction_general or similar here (adapt as needed)
|
|
1198
1024
|
# if not get_obstruction(pg.get_face(i), pg.get_face(j), obs, strict=strict_obstruction)[0]:
|
|
1199
|
-
if not get_obstruction_from_cache(i, j, pg, obs, strict=False, print_warning=False, eps=1e-6):
|
|
1025
|
+
if not get_obstruction_from_cache(i, j, pg, obs, strict=False, print_warning=False, eps=1e-6)[0]:
|
|
1200
1026
|
blocked = True
|
|
1201
1027
|
break
|
|
1202
1028
|
if blocked:
|
|
@@ -1207,19 +1033,20 @@ def compute_viewfactor_matrix(
|
|
|
1207
1033
|
set1 = vertex_sets[i]
|
|
1208
1034
|
set2 = vertex_sets[j]
|
|
1209
1035
|
pts2_adj = pts2.copy()
|
|
1210
|
-
if set1 & set2:
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1036
|
+
# if set1 & set2:
|
|
1037
|
+
c1 = pg.get_centroid(i)
|
|
1038
|
+
c2 = pg.get_centroid(j)
|
|
1039
|
+
direction = c2 - c1
|
|
1040
|
+
norm = np.linalg.norm(direction)
|
|
1041
|
+
eps_ij = epsilon * 0.5 * (pg.get_size(i) + pg.get_size(j))
|
|
1042
|
+
if norm > 0.0:
|
|
1043
|
+
direction /= norm
|
|
1044
|
+
pts2_adj = pts2_adj + eps_ij * direction
|
|
1218
1045
|
constante = 4.0 * np.pi * pg.get_area(j)
|
|
1219
1046
|
vf = _compute_viewfactor_dblquad(pts1, pts2_adj, constante)
|
|
1220
1047
|
F[i, j] = vf
|
|
1221
|
-
if use_reciprocity:
|
|
1222
|
-
|
|
1048
|
+
# if use_reciprocity:
|
|
1049
|
+
F[j, i] = vf * (pg.get_area(j) / pg.get_area(i))
|
|
1223
1050
|
|
|
1224
1051
|
# DISCONNECTED: Use batch Gauss-Legendre for speed
|
|
1225
1052
|
if verbose:
|
|
@@ -1242,11 +1069,11 @@ def compute_viewfactor_matrix(
|
|
|
1242
1069
|
valid_mask[k] = False
|
|
1243
1070
|
continue
|
|
1244
1071
|
# (B) Optional obstruction test
|
|
1245
|
-
if not skip_obstruction and
|
|
1072
|
+
if not skip_obstruction and obs_pre:
|
|
1246
1073
|
blocked = False
|
|
1247
|
-
for obs in
|
|
1074
|
+
for obs in obs_pre:
|
|
1248
1075
|
# if not get_obstruction(pg.get_face(i), pg.get_face(j), obs, strict=strict_obstruction)[0]:
|
|
1249
|
-
if not get_obstruction_from_cache(i, j, pg, obs, strict=False, print_warning=False, eps=1e-6):
|
|
1076
|
+
if not get_obstruction_from_cache(i, j, pg, obs, strict=False, print_warning=False, eps=1e-6)[0]:
|
|
1250
1077
|
blocked = True
|
|
1251
1078
|
break
|
|
1252
1079
|
if blocked:
|
|
@@ -1296,8 +1123,8 @@ def compute_viewfactor_matrix(
|
|
|
1296
1123
|
i, j = disconnected_pairs[k]
|
|
1297
1124
|
fij = vf_valid[idx]
|
|
1298
1125
|
F[i, j] = fij
|
|
1299
|
-
if use_reciprocity:
|
|
1300
|
-
|
|
1126
|
+
# if use_reciprocity:
|
|
1127
|
+
F[j, i] = fij * (pg.get_area(j) / pg.get_area(i))
|
|
1301
1128
|
|
|
1302
1129
|
return F
|
|
1303
1130
|
|