pyviewfactor 0.1.7__tar.gz → 0.1.8__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.7 → pyviewfactor-0.1.8}/PKG-INFO +1 -1
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor/_version.py +1 -1
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor/pyviewfactor.py +4 -3
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor.egg-info/PKG-INFO +1 -1
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/test/test_utils.py +4 -3
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/test/test_view_factor.py +24 -26
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/test/test_visibility_obstruction.py +13 -8
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/LICENSE.txt +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/README.md +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor/__init__.py +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor.egg-info/SOURCES.txt +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor.egg-info/dependency_links.txt +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor.egg-info/requires.txt +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/pyviewfactor.egg-info/top_level.txt +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/setup.cfg +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/setup.py +0 -0
- {pyviewfactor-0.1.7 → pyviewfactor-0.1.8}/test/__init__.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.8
|
|
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
|
|
@@ -391,7 +391,7 @@ def get_obstruction(face1, face2, obstacle, strict=False, print_debug=False):
|
|
|
391
391
|
|
|
392
392
|
@njit # numba's just in time compilation offers a x2 speedup
|
|
393
393
|
def _integrand_dblquad(x, y, norm_q_carree, norm_p_carree, scal_qpq,
|
|
394
|
-
|
|
394
|
+
scal_qpp, scal_pq, norm_qp_carree):
|
|
395
395
|
"""
|
|
396
396
|
Return the integrand for a pair of edges of two facets for the view factor
|
|
397
397
|
computation.
|
|
@@ -567,7 +567,7 @@ def compute_viewfactor(cell1, cell2, *, epsilon=1e-6, rounding_decimal=6):
|
|
|
567
567
|
return VF
|
|
568
568
|
|
|
569
569
|
|
|
570
|
-
|
|
570
|
+
# Helper function to compute VF matrix for a complete mesh
|
|
571
571
|
def _is_blocked(f_i, f_j, obstacles, obstruction_kwargs, skip_obstruction):
|
|
572
572
|
"""Return True if any obstacle blocks f_i→f_j."""
|
|
573
573
|
if skip_obstruction or not obstacles:
|
|
@@ -703,7 +703,6 @@ def compute_viewfactor_matrix(mesh, obstacle=None,
|
|
|
703
703
|
else:
|
|
704
704
|
obstacles = [obstacle]
|
|
705
705
|
|
|
706
|
-
|
|
707
706
|
# build a callable with all those locals pre-filled
|
|
708
707
|
compute_pair = partial(
|
|
709
708
|
_compute_pair,
|
|
@@ -739,6 +738,8 @@ def compute_viewfactor_matrix(mesh, obstacle=None,
|
|
|
739
738
|
return F
|
|
740
739
|
|
|
741
740
|
|
|
741
|
+
# Helper function to plot a mesh with view factor from one of the cells
|
|
742
|
+
# to all others.
|
|
742
743
|
def plot_viewfactor(mesh: pv.PolyData,
|
|
743
744
|
F: np.ndarray,
|
|
744
745
|
cell_id: int,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: pyviewfactor
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.8
|
|
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
|
|
@@ -28,14 +28,15 @@ def test_fc_unstruc2poly_roundtrip():
|
|
|
28
28
|
def test_plotter_runs_and_returns_plotter():
|
|
29
29
|
# Create a minimal mesh with 2 cells
|
|
30
30
|
mesh = pv.PolyData()
|
|
31
|
-
pts = np.array([[0
|
|
31
|
+
pts = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0],
|
|
32
|
+
[0.0, 1.0, 0.0], [0.0, 0.0, 1.0]])
|
|
32
33
|
# two triangles sharing a point
|
|
33
|
-
faces = np.hstack([[3, 0,1,2], [3, 0,2,3]])
|
|
34
|
+
faces = np.hstack([[3, 0, 1, 2], [3, 0, 2, 3]])
|
|
34
35
|
mesh.points = pts
|
|
35
36
|
mesh.faces = faces
|
|
36
37
|
|
|
37
38
|
# Dummy VF vector of length n_cells
|
|
38
|
-
vf = np.array([[0.3, 0.7],[0.2,0.8]])
|
|
39
|
+
vf = np.array([[0.3, 0.7], [0.2, 0.8]])
|
|
39
40
|
|
|
40
41
|
# Should not raise and should return a Plotter
|
|
41
42
|
pl = pvf.plot_viewfactor(mesh, vf, cell_id=1, show=False)
|
|
@@ -3,14 +3,19 @@ import pyvista as pv
|
|
|
3
3
|
import pytest
|
|
4
4
|
import pyviewfactor as pvf
|
|
5
5
|
import numpy as np
|
|
6
|
-
from pyviewfactor.pyviewfactor import
|
|
6
|
+
from pyviewfactor.pyviewfactor import _compute_viewfactor_gauss_legendre
|
|
7
7
|
from pyviewfactor.pyviewfactor import _integrand_gauss_legendre
|
|
8
8
|
from pyviewfactor.pyviewfactor import _integrand_dblquad
|
|
9
|
+
from pyviewfactor import compute_viewfactor_matrix
|
|
10
|
+
from pyviewfactor import compute_viewfactor
|
|
11
|
+
from pyviewfactor import fc_unstruc2poly
|
|
12
|
+
|
|
9
13
|
|
|
10
14
|
def test_integrand_raw_kernel():
|
|
11
15
|
# at (0,0) → log(nqp)*spq
|
|
12
|
-
v =
|
|
13
|
-
|
|
16
|
+
v = _integrand_dblquad.py_func(0.0, 0.0, 2.0, 3.0,
|
|
17
|
+
0.0, 0.0, 5.0, 4.0)
|
|
18
|
+
assert v == pytest.approx(np.log(4.0) * 5.0)
|
|
14
19
|
|
|
15
20
|
|
|
16
21
|
# two identical parallel unit squares 1 unit apart → known VF = 1/(π)
|
|
@@ -56,7 +61,7 @@ def test_closed_geometry_parrallel():
|
|
|
56
61
|
chosen_face = sphere.extract_cells(cell_extracted_id)
|
|
57
62
|
# convert to PolyData
|
|
58
63
|
chosen_face = pvf.fc_unstruc2poly(chosen_face)
|
|
59
|
-
|
|
64
|
+
|
|
60
65
|
F = pvf.compute_viewfactor_matrix(
|
|
61
66
|
sphere,
|
|
62
67
|
skip_visibility=True,
|
|
@@ -68,7 +73,6 @@ def test_closed_geometry_parrallel():
|
|
|
68
73
|
assert sum_vf == pytest.approx(1.0, rel=1e-3)
|
|
69
74
|
|
|
70
75
|
|
|
71
|
-
|
|
72
76
|
def test_skip_obstruction_flag_respected():
|
|
73
77
|
# use the same two‐triangle mesh and place an obstacle that blocks only 1→0
|
|
74
78
|
pts = np.array([
|
|
@@ -78,13 +82,13 @@ def test_skip_obstruction_flag_respected():
|
|
|
78
82
|
[0.0, 0.0, 1.0]
|
|
79
83
|
], float)
|
|
80
84
|
# triangle 0: pts[0,1,2], triangle 1: pts[0,2,3]
|
|
81
|
-
faces = np.hstack([[3,0,1,2], [3,0,2,3]])
|
|
85
|
+
faces = np.hstack([[3, 0, 1, 2], [3, 0, 2, 3]])
|
|
82
86
|
mesh = pv.PolyData(pts, faces)
|
|
83
87
|
mesh.triangulate(inplace=True)
|
|
84
88
|
tri0 = mesh.extract_cells(0)
|
|
85
|
-
tri1 = mesh.extract_cells(1)
|
|
89
|
+
# tri1 = mesh.extract_cells(1)
|
|
86
90
|
# obstacle: a small triangle between centroids
|
|
87
|
-
obs = tri0.translate([0.1,0.0,0.3])
|
|
91
|
+
obs = tri0.translate([0.1, 0.0, 0.3])
|
|
88
92
|
obs = pvf.fc_unstruc2poly(obs)
|
|
89
93
|
# compute with obstruction
|
|
90
94
|
F_blocked = pvf.compute_viewfactor_matrix(
|
|
@@ -94,7 +98,7 @@ def test_skip_obstruction_flag_respected():
|
|
|
94
98
|
skip_obstruction=False,
|
|
95
99
|
visibility_kwargs={"strict": True},
|
|
96
100
|
obstruction_kwargs={"strict": True},
|
|
97
|
-
compute_kwargs={"epsilon":1e-6, "rounding_decimal":6},
|
|
101
|
+
compute_kwargs={"epsilon": 1e-6, "rounding_decimal": 6},
|
|
98
102
|
n_jobs=1
|
|
99
103
|
)
|
|
100
104
|
# compute with skip_obstruction=True
|
|
@@ -105,14 +109,13 @@ def test_skip_obstruction_flag_respected():
|
|
|
105
109
|
skip_obstruction=True,
|
|
106
110
|
visibility_kwargs={"strict": False},
|
|
107
111
|
obstruction_kwargs={"strict": False},
|
|
108
|
-
compute_kwargs={"epsilon":1e-6, "rounding_decimal":6},
|
|
112
|
+
compute_kwargs={"epsilon": 1e-6, "rounding_decimal": 6},
|
|
109
113
|
n_jobs=1
|
|
110
114
|
)
|
|
111
115
|
# now only in the first case do we zero out the blocked direction
|
|
112
116
|
assert F_blocked[0, 1] == pytest.approx(0.0)
|
|
113
117
|
assert F_no_block[0, 1] > 0.0
|
|
114
|
-
|
|
115
|
-
#tests avec un full mesh
|
|
118
|
+
|
|
116
119
|
|
|
117
120
|
def test_compute_matrix_against_individual_calls():
|
|
118
121
|
pts = np.array([
|
|
@@ -125,20 +128,16 @@ def test_compute_matrix_against_individual_calls():
|
|
|
125
128
|
faces = np.hstack([[3, 0, 1, 2], [3, 0, 2, 3]])
|
|
126
129
|
mesh = pv.PolyData(pts, faces)
|
|
127
130
|
mesh.triangulate(inplace=True)
|
|
128
|
-
from pyviewfactor import compute_viewfactor_matrix
|
|
129
|
-
from pyviewfactor import compute_viewfactor
|
|
130
|
-
from pyviewfactor import fc_unstruc2poly
|
|
131
131
|
|
|
132
132
|
F = compute_viewfactor_matrix(
|
|
133
133
|
mesh,
|
|
134
134
|
skip_visibility=True,
|
|
135
135
|
skip_obstruction=True,
|
|
136
|
-
compute_kwargs={'epsilon':1e-6, 'rounding_decimal':6},
|
|
136
|
+
compute_kwargs={'epsilon': 1e-6, 'rounding_decimal': 6},
|
|
137
137
|
n_jobs=1
|
|
138
138
|
)
|
|
139
139
|
|
|
140
140
|
# convert to PolyData
|
|
141
|
-
from pyviewfactor import fc_unstruc2poly
|
|
142
141
|
f0 = fc_unstruc2poly(mesh.extract_cells(0))
|
|
143
142
|
f1 = fc_unstruc2poly(mesh.extract_cells(1))
|
|
144
143
|
direct = compute_viewfactor(f0, f1, epsilon=1e-6, rounding_decimal=6)
|
|
@@ -146,13 +145,12 @@ def test_compute_matrix_against_individual_calls():
|
|
|
146
145
|
|
|
147
146
|
|
|
148
147
|
def test_compute_viewfactor_fixed_nonzero_overlap():
|
|
149
|
-
|
|
150
|
-
pts1 = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0],[0.0, 1.0, 0.0]], float)
|
|
148
|
+
pts1 = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]], float)
|
|
151
149
|
# shift only in x by 0.5: they “face” each other partially
|
|
152
150
|
pts2 = pts1 + np.array([0.5, 0.0, 1.0])
|
|
153
151
|
pts2 = pts2[::-1]
|
|
154
152
|
constante = 4.0 * np.pi * 0.5
|
|
155
|
-
vf =
|
|
153
|
+
vf = _compute_viewfactor_gauss_legendre.py_func(pts1, pts2, constante)
|
|
156
154
|
# Should be positive but <1
|
|
157
155
|
assert vf > 0.0
|
|
158
156
|
assert vf < 1.0
|
|
@@ -168,15 +166,15 @@ def test_fast_integrand_zero_when_scal_pq_zero():
|
|
|
168
166
|
np_ = 1.7
|
|
169
167
|
sqpq = -0.5
|
|
170
168
|
sqpp = 0.8
|
|
171
|
-
nqp
|
|
172
|
-
val =
|
|
169
|
+
nqp = 10.0
|
|
170
|
+
val = _integrand_gauss_legendre.py_func(nq, np_, sqpq, sqpp, 0.0, nqp)
|
|
173
171
|
assert val == pytest.approx(0.0, abs=0.0)
|
|
174
172
|
|
|
175
173
|
|
|
176
174
|
def test_compute_matrix_len3_visibility_cull():
|
|
177
175
|
# Build two triangles whose normals both point +Z
|
|
178
|
-
tri1 = pv.Triangle([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
|
|
179
|
-
tri2 = pv.Triangle([[0.0, 0.0, 1.0], [1.0, 0.0, 1.0], [0.0, 1.0, 1.0]])
|
|
176
|
+
tri1 = pv.Triangle([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]])
|
|
177
|
+
tri2 = pv.Triangle([[0.0, 0.0, 1.0], [1.0, 0.0, 1.0], [0.0, 1.0, 1.0]])
|
|
180
178
|
|
|
181
179
|
# Merge them into one mesh
|
|
182
180
|
mesh = tri1.merge(tri2)
|
|
@@ -200,5 +198,5 @@ def test_compute_matrix_len3_visibility_cull():
|
|
|
200
198
|
assert F[1, 0] == pytest.approx(0.0)
|
|
201
199
|
|
|
202
200
|
# And obviously self‐view is zero
|
|
203
|
-
assert F[0,0] == pytest.approx(0.0)
|
|
204
|
-
assert F[1,1] == pytest.approx(0.0)
|
|
201
|
+
assert F[0, 0] == pytest.approx(0.0)
|
|
202
|
+
assert F[1, 1] == pytest.approx(0.0)
|
|
@@ -3,7 +3,7 @@ import pyvista as pv
|
|
|
3
3
|
# import pytest
|
|
4
4
|
from pyviewfactor import get_visibility
|
|
5
5
|
from pyviewfactor import get_obstruction
|
|
6
|
-
from pyviewfactor import is_ray_obstructed
|
|
6
|
+
# from pyviewfactor import is_ray_obstructed
|
|
7
7
|
from pyviewfactor import batch_ray_obstruction
|
|
8
8
|
|
|
9
9
|
import numpy as np
|
|
@@ -34,6 +34,7 @@ obs_multi.translate([0, 0, 0.5], inplace=True)
|
|
|
34
34
|
obs_multi2 = obs_multi.copy()
|
|
35
35
|
obs_multi2.translate([1.7, 0.0, 0.0], inplace=True)
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
def test_visibility_strict_true():
|
|
38
39
|
vis, warn = get_visibility(tri1, tri2, strict=True)
|
|
39
40
|
assert vis and warn == ""
|
|
@@ -59,6 +60,7 @@ def test_visibility_strict_false_warn():
|
|
|
59
60
|
vis, warn = get_visibility(tri1, tri3, strict=False, print_warning=True)
|
|
60
61
|
assert not vis and warn == ""
|
|
61
62
|
|
|
63
|
+
|
|
62
64
|
def test_visibility_not_strict_false():
|
|
63
65
|
# flip tri2 so normals face away
|
|
64
66
|
tri3 = tri2.copy()
|
|
@@ -71,18 +73,22 @@ def test_visibility_partial_strict_true():
|
|
|
71
73
|
vis, warn = get_visibility(tri1, triP, strict=True)
|
|
72
74
|
assert not vis and "[PVF-Warning-1]" in warn
|
|
73
75
|
|
|
76
|
+
|
|
74
77
|
def test_visibility_partial_strict_true_debug():
|
|
75
78
|
vis, warn = get_visibility(tri1, triP, strict=True, print_warning=True)
|
|
76
79
|
assert not vis and "[PVF-Warning-1]" in warn
|
|
77
80
|
|
|
81
|
+
|
|
78
82
|
def test_visibility_partial_strict_false():
|
|
79
83
|
vis, warn = get_visibility(tri1, triP, strict=False)
|
|
80
84
|
assert vis and "[PVF-Warning-2]" in warn
|
|
81
85
|
|
|
86
|
+
|
|
82
87
|
def test_visibility_partial_strict_false_debug():
|
|
83
88
|
vis, warn = get_visibility(tri1, triP, strict=False, print_warning=True)
|
|
84
89
|
assert vis and "[PVF-Warning-2]" in warn
|
|
85
|
-
|
|
90
|
+
|
|
91
|
+
|
|
86
92
|
def test_obstruction_strict_true():
|
|
87
93
|
# obstacle sits between tri1 and tri2
|
|
88
94
|
vis, warn = get_obstruction(tri1, tri2, obs, strict=True)
|
|
@@ -105,8 +111,6 @@ def test_partial_obstruction_strict_true():
|
|
|
105
111
|
assert not vis and "[PVF-Warning-4]" in warn
|
|
106
112
|
|
|
107
113
|
|
|
108
|
-
|
|
109
|
-
|
|
110
114
|
def test_obstruction_multi_strict_true():
|
|
111
115
|
# obstacle sits between tri1 and tri2
|
|
112
116
|
vis, warn = get_obstruction(tri1, tri2, obs_multi, strict=True)
|
|
@@ -130,9 +134,10 @@ def test_partial_multi_obstruction_strict_true():
|
|
|
130
134
|
|
|
131
135
|
|
|
132
136
|
def test_batch_ray_obstruction_hits_and_misses():
|
|
133
|
-
tri_arr = np.array([[[0,0,0],[1
|
|
137
|
+
tri_arr = np.array([[[0.0, 0.0, 0.0], [1.0, 0.0, 0.0],
|
|
138
|
+
[0.0, 1.0, 0.0]]], dtype=np.float64)
|
|
134
139
|
# one ray misses, one hits
|
|
135
|
-
starts = np.array([[2,2,1.0],[0.2,0.2,1.0]], dtype=np.float64)
|
|
136
|
-
ends
|
|
140
|
+
starts = np.array([[2.0, 2.0, 1.0], [0.2, 0.2, 1.0]], dtype=np.float64)
|
|
141
|
+
ends = np.array([[2.0, 2.0, -1.0], [0.2, 0.2, -1.0]], dtype=np.float64)
|
|
137
142
|
mask = batch_ray_obstruction.py_func(starts, ends, tri_arr)
|
|
138
|
-
assert mask.tolist() == [True, False]
|
|
143
|
+
assert mask.tolist() == [True, False]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|