pyviewfactor 0.1.15__tar.gz → 0.1.16__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.
Files changed (22) hide show
  1. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/PKG-INFO +1 -1
  2. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/__init__.py +1 -0
  3. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/_version.py +1 -1
  4. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/pvf_geometry_preprocess.py +189 -52
  5. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/pvf_integrators.py +94 -62
  6. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/pvf_plot.py +33 -23
  7. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/pvf_viewfactor_computations.py +123 -88
  8. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor/pvf_visibility_obstruction.py +226 -46
  9. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor.egg-info/PKG-INFO +1 -1
  10. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor.egg-info/SOURCES.txt +2 -1
  11. pyviewfactor-0.1.16/test/test_geometry_preprocess.py +104 -0
  12. pyviewfactor-0.1.15/test/test_utils.py → pyviewfactor-0.1.16/test/test_plot.py +1 -19
  13. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/test/test_visibility_obstruction.py +30 -59
  14. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/LICENSE.txt +0 -0
  15. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/README.md +0 -0
  16. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor.egg-info/dependency_links.txt +0 -0
  17. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor.egg-info/requires.txt +0 -0
  18. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/pyviewfactor.egg-info/top_level.txt +0 -0
  19. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/setup.cfg +0 -0
  20. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/setup.py +0 -0
  21. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/test/__init__.py +0 -0
  22. {pyviewfactor-0.1.15 → pyviewfactor-0.1.16}/test/test_view_factor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyviewfactor
3
- Version: 0.1.15
3
+ Version: 0.1.16
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
@@ -1,6 +1,7 @@
1
1
  """
2
2
  .. include:: ../README.md
3
3
  """
4
+
4
5
  from ._version import __version__
5
6
  from .pvf_geometry_preprocess import (
6
7
  ProcessedGeometry,
@@ -1,5 +1,5 @@
1
1
  """Version info for pyViewFactor"""
2
- version_info = 0, 1, 15
2
+ version_info = 0, 1, 16
3
3
 
4
4
  # Nice string for the version
5
5
  __version__ = ".".join(map(str, version_info))
@@ -1,11 +1,12 @@
1
1
  """
2
- file: pvf_geometry.py
2
+ `file: pvf_geometry.py`
3
3
  """
4
4
 
5
5
  import numpy as np
6
6
  import pyvista as pv
7
7
  from numba import njit
8
8
 
9
+
9
10
  def fc_unstruc2poly(mesh_unstruc):
10
11
  """Convenience conversion function from UnstructuredGrid to PolyData
11
12
 
@@ -47,14 +48,74 @@ def fc_unstruc2poly(mesh_unstruc):
47
48
 
48
49
 
49
50
  def face_to_array(face):
50
- """Extract and return the vertices of a PyVista PolyData face as ndarray."""
51
- faces = face.faces
52
- n_pts = int(faces[0])
53
- idxs = faces[1:1 + n_pts]
54
- return np.array(face.points[idxs], dtype=np.float64)
51
+ """
52
+ Extract the vertex coordinates of a single PolyData face as a NumPy array.
53
+
54
+ Parameters
55
+ ----------
56
+ * **face** : *pyvista.PolyData*
57
+
58
+ > PolyData containing exactly one face.
59
+
60
+ Returns
61
+ -------
62
+ * *numpy.ndarray* (n, 3)
63
+
64
+ > The (x, y, z) coordinates of the face's vertices.
65
+ """
66
+ return face.get_cell(0).points.astype(np.float64)
67
+
68
+
69
+ @njit
70
+ def face_normal_numpy(pts):
71
+ """
72
+ Compute the right-handed unit normal vector of a planar polygon.
73
+
74
+ Parameters
75
+ ----------
76
+ * **pts** : *numpy.ndarray*, shape (n, 3)
77
+
78
+ > Coordinates of the polygon's vertices in order.
79
+ Handles n>3
80
+
81
+ Returns
82
+ -------
83
+ * *numpy.ndarray* (3,)
84
+
85
+ > Unit normal vector (x, y, z). If degenerate, returns [0, 0, 1].
86
+ """
87
+ n = pts.shape[0]
88
+ # Newell's method (robust for convex planar polygons)
89
+ nx = 0.0
90
+ ny = 0.0
91
+ nz = 0.0
92
+ for i in range(n):
93
+ j = (i + 1) % n
94
+ nx += (pts[i, 1] - pts[j, 1]) * (pts[i, 2] + pts[j, 2])
95
+ ny += (pts[i, 2] - pts[j, 2]) * (pts[i, 0] + pts[j, 0])
96
+ nz += (pts[i, 0] - pts[j, 0]) * (pts[i, 1] + pts[j, 1])
97
+ norm = np.sqrt(nx*nx + ny*ny + nz*nz)
98
+ if norm < 1e-12:
99
+ return np.array([0.0, 0.0, 1.0])
100
+ return np.array([nx, ny, nz]) / norm
55
101
 
56
102
 
57
103
  def polygon_area(pts):
104
+ """
105
+ Compute the area of a planar polygon given its ordered vertices.
106
+
107
+ Parameters
108
+ ----------
109
+ * **pts** : *numpy.ndarray*, shape (n, 3)
110
+
111
+ > Coordinates of the polygon's vertices.
112
+
113
+ Returns
114
+ -------
115
+ * *float*
116
+
117
+ > Area of the polygon.
118
+ """
58
119
  # Compute normal
59
120
  n = face_normal_numpy(pts)
60
121
  # Use polygon centroid and cross product trick
@@ -69,20 +130,17 @@ def polygon_area(pts):
69
130
 
70
131
  def polygon_centroid(pts: np.ndarray) -> np.ndarray:
71
132
  """
72
- Compute the area centroid ( area-weighted centroid) of a planar polygon in 3D.
73
-
74
- Uses fan triangulation around pts[0]. If polygon is degenerate,
75
- returns the arithmetic mean of pts.
133
+ Compute the area-weighted centroid of a planar polygon in 3D.
76
134
 
77
135
  Parameters
78
136
  ----------
79
- pts : ndarray, shape (n,3)
80
- Ordered vertex coordinates.
137
+ * **pts** : *numpy.ndarray*, shape (n, 3)
138
+ > Ordered vertex coordinates.
81
139
 
82
140
  Returns
83
141
  -------
84
- ndarray, shape (3,)
85
- Area centroid.
142
+ * *numpy.ndarray*, shape (3,)
143
+ > The (x, y, z) centroid coordinates.
86
144
  """
87
145
  p0, p1, p2 = pts[0], pts[1], pts[2]
88
146
  v1 = p1 - p0
@@ -111,34 +169,26 @@ def polygon_centroid(pts: np.ndarray) -> np.ndarray:
111
169
 
112
170
 
113
171
  @njit
114
- def face_normal_numpy(pts):
115
- """
116
- Compute a unit normal for a planar polygon with vertex coords in pts (n×3).
117
- Returns the *right-handed* normal. Handles n > 3.
118
- If degenerate, returns [0,0,1].
172
+ def tri_overlaps_aabb(tri_pts, aabb_min, aabb_max):
119
173
  """
120
- n = pts.shape[0]
121
- if n < 3:
122
- return np.array([0.0, 0.0, 1.0])
123
- # Newell's method (robust for convex planar polygons)
124
- nx = 0.0
125
- ny = 0.0
126
- nz = 0.0
127
- for i in range(n):
128
- j = (i + 1) % n
129
- nx += (pts[i,1] - pts[j,1]) * (pts[i,2] + pts[j,2])
130
- ny += (pts[i,2] - pts[j,2]) * (pts[i,0] + pts[j,0])
131
- nz += (pts[i,0] - pts[j,0]) * (pts[i,1] + pts[j,1])
132
- norm = np.sqrt(nx*nx + ny*ny + nz*nz)
133
- if norm < 1e-12:
134
- return np.array([0.0, 0.0, 1.0])
135
- return np.array([nx, ny, nz]) / norm
174
+ JIT-compatible test if a triangle (by vertex coordinates)
175
+ overlaps an axis-aligned bounding box.
176
+
177
+ Parameters
178
+ ----------
179
+ * **tri_pts** : *numpy.ndarray*, shape (3, 3)
180
+ > Vertices of the triangle.
136
181
 
182
+ * **aabb_min** : *numpy.ndarray*, shape (3,)
183
+ > Minimum x, y, z of the bounding box.
137
184
 
138
- @njit
139
- def tri_overlaps_aabb(tri_pts, aabb_min, aabb_max):
140
- """
141
- JIT‐compatible AABB overlap test without using axis keywords.
185
+ * **aabb_max** : *numpy.ndarray*, shape (3,)
186
+ > Maximum x, y, z of the bounding box.
187
+
188
+ Returns
189
+ -------
190
+ * *bool*
191
+ > True if the triangle overlaps the box, False otherwise.
142
192
  """
143
193
  # initialize with the first vertex
144
194
  tri_min0 = tri_pts[0, 0]
@@ -151,12 +201,18 @@ def tri_overlaps_aabb(tri_pts, aabb_min, aabb_max):
151
201
  # find true min/max over the three vertices
152
202
  for i in range(1, tri_pts.shape[0]):
153
203
  x, y, z = tri_pts[i, 0], tri_pts[i, 1], tri_pts[i, 2]
154
- if x < tri_min0: tri_min0 = x
155
- if y < tri_min1: tri_min1 = y
156
- if z < tri_min2: tri_min2 = z
157
- if x > tri_max0: tri_max0 = x
158
- if y > tri_max1: tri_max1 = y
159
- if z > tri_max2: tri_max2 = z
204
+ if x < tri_min0:
205
+ tri_min0 = x
206
+ if y < tri_min1:
207
+ tri_min1 = y
208
+ if z < tri_min2:
209
+ tri_min2 = z
210
+ if x > tri_max0:
211
+ tri_max0 = x
212
+ if y > tri_max1:
213
+ tri_max1 = y
214
+ if z > tri_max2:
215
+ tri_max2 = z
160
216
 
161
217
  # now test overlap
162
218
  return (
@@ -168,8 +224,59 @@ def tri_overlaps_aabb(tri_pts, aabb_min, aabb_max):
168
224
 
169
225
  class ProcessedGeometry:
170
226
  """
171
- A lightweight structure to cache face geometry (points, normals, centroids, area)
172
- for high-performance view factor computation.
227
+ Cache geometry of all faces in a mesh for high-performance view factor computation.
228
+
229
+ Attributes
230
+ ----------
231
+ * **rounding_decimal** : *int*
232
+
233
+ > Number of decimals to round coordinates for robustness.
234
+
235
+ * **N** : *int*
236
+
237
+ > Number of faces in the mesh.
238
+
239
+ * **points** : list of ndarray
240
+
241
+ > List of (n, 3) arrays with the coordinates of each face's vertices.
242
+
243
+ * **normals** : *ndarray*, shape (N, 3)
244
+
245
+ > Unit normal vectors for each face.
246
+
247
+ * **centroids** : *ndarray*, shape (N, 3)
248
+
249
+ > Area-weighted centroid for each face.
250
+
251
+ * **areas** : *ndarray*, shape (N,)
252
+
253
+ > Area of each face.
254
+
255
+ **sizes** : *ndarray*, shape (N,)
256
+
257
+ > Mean edge length for each face.
258
+
259
+ Methods
260
+ -------
261
+ * `get_face(i)`
262
+
263
+ > Return the (n, 3) vertex array for face i.
264
+
265
+ `get_normal(i)`
266
+
267
+ > Return the normal vector for face i.
268
+
269
+ * `get_centroid(i)`
270
+
271
+ > Return the centroid for face i.
272
+
273
+ `get_area(i)`
274
+
275
+ > Return the area for face i.
276
+
277
+ * `get_size(i)`
278
+
279
+ > Return the average edge length for face i.
173
280
  """
174
281
  def __init__(self, mesh, rounding_decimal=8):
175
282
  self.rounding_decimal = rounding_decimal
@@ -218,12 +325,41 @@ class ProcessedGeometry:
218
325
 
219
326
 
220
327
  class FaceMeshPreprocessor:
328
+ """
329
+ Efficiently preprocess a PolyData mesh for obstruction and overlap queries.
330
+
331
+ Converts mesh to all triangles and provides fast spatial filtering.
332
+
333
+ Attributes
334
+ ----------
335
+ * **points** : *ndarray* (N_pts, 3)
336
+
337
+ > All vertex coordinates.
338
+
339
+ * **faces** : *ndarray* (N_cells, 3)
340
+
341
+ > Triangle vertex indices.
342
+
343
+ * **triangles** : *ndarray* (N_cells, 3, 3)
344
+
345
+ > Vertices of all triangles.
346
+
347
+ Methods
348
+ -------
349
+ * `aabb_filter(aabb_min, aabb_max)`
350
+
351
+ > Return only those triangles overlapping a given axis-aligned bounding box.
352
+
353
+ * `exclude_exact_match(pts1, pts2, tris)`
354
+
355
+ > Remove triangles that exactly match either pts1 or pts2.
356
+ """
221
357
  def __init__(self, mesh: pv.PolyData):
222
358
  if not mesh.is_all_triangles:
223
359
  mesh = mesh.triangulate()
224
360
  self.points = mesh.points.astype(np.float64)
225
361
  # cells array is [n, i0, i1, i2, n, ...]
226
- cells = mesh.faces.reshape(-1,4)[:,1:]
362
+ cells = mesh.faces.reshape(-1, 4)[:, 1:]
227
363
  self.faces = cells # shape (n_cells,3)
228
364
  self.triangles = np.array([self.points[c] for c in cells], dtype=np.float64)
229
365
 
@@ -236,14 +372,15 @@ class FaceMeshPreprocessor:
236
372
 
237
373
  def exclude_exact_match(self, pts1, pts2, tris):
238
374
  # build frozensets of each vertex array
239
- vs1 = frozenset(sorted(tuple(np.round(p,8)) for p in pts1))
240
- vs2 = frozenset(sorted(tuple(np.round(p,8)) for p in pts2))
375
+ vs1 = frozenset(sorted(tuple(np.round(p, 8)) for p in pts1))
376
+ vs2 = frozenset(sorted(tuple(np.round(p, 8)) for p in pts2))
241
377
  out = []
242
378
  for tri in tris:
243
- tri_set = frozenset(sorted(tuple(np.round(p,8)) for p in tri))
379
+ tri_set = frozenset(sorted(tuple(np.round(p, 8)) for p in tri))
244
380
  if not tri_set.isdisjoint(vs1) or not tri_set.isdisjoint(vs2):
245
381
  continue
246
382
  out.append(tri)
247
383
  return np.array(out, dtype=np.float64)
248
384
 
249
-
385
+ # #-----------------------------------------------------------------------------------#
386
+ # End of File
@@ -1,5 +1,5 @@
1
1
  """
2
- file: pvf_integrators.py
2
+ `file: pvf_integrators.py`
3
3
  """
4
4
 
5
5
  import numpy as np
@@ -7,41 +7,53 @@ from numpy.polynomial.legendre import leggauss
7
7
  import scipy.integrate
8
8
  from numba import njit
9
9
 
10
- # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
11
10
  # SCIPY DBLQUAD INTEGRATION
12
11
 
12
+
13
13
  @njit
14
- def _integrand_dblquad(x, y, norm_q_carree, norm_p_carree, scal_qpq,
15
- scal_qpp, scal_pq, norm_qp_carree):
14
+ def integrand_dblquad(x, y, norm_q_carree, norm_p_carree, scal_qpq,
15
+ scal_qpp, scal_pq, norm_qp_carree):
16
16
  """
17
17
  Represents the logarithmic integrand of the contour form‐factor integral
18
18
  for one edge‐pair between two facets.
19
19
 
20
- Used in the *compute_viewfactor* function.
20
+ Used in the `compute_viewfactor_dblquad` function.
21
21
 
22
22
  Core integrand function for SciPy dblquad contour integration.
23
23
 
24
24
  Parameters
25
25
  ----------
26
- x, y : float
27
- Quadrature parameters in [0,1].
28
- norm_q_carree : float
29
- Squared length of one directed edge vector (facet1).
30
- norm_p_carree : float
31
- Squared length of the other directed edge vector (facet2).
32
- scal_qpq : float
33
- Dot(edge1, edge2) term coupling the two edges in the log.
34
- scal_qpp : float
35
- Dot(edge2, vector between vertices).
36
- scal_pq : float
37
- Dot(edge1, vector between vertices); also multiplies the log.
38
- norm_qp_carree : float
39
- Squared length of the inter‐vertex vector.
26
+ * **x, y** : *float*
27
+
28
+ > Quadrature parameters in [0,1].
29
+
30
+ * **norm_q_carree** : *float*
31
+
32
+ > Squared length of one directed edge vector (facet1).
33
+
34
+ * **norm_p_carree** : *float*
35
+
36
+ > Squared length of the other directed edge vector (facet2).
37
+
38
+ * **scal_qpq** : *float*
39
+
40
+ > dot(edge1, edge2) term coupling the two edges in the log.
41
+
42
+ * **scal_qpp** : *float*
43
+
44
+ > dot(edge2, vector between vertices).
45
+
46
+ * **scal_pq** : *float*
47
+
48
+ > dot(edge1, vector between vertices); also multiplies the log.
49
+
50
+ * **norm_qp_carree** : *float*
51
+
52
+ > Squared length of the inter‐vertex vector.
40
53
 
41
54
  Returns
42
55
  -------
43
- float
44
- V
56
+ * *float*
45
57
 
46
58
  """
47
59
  integrand_function = np.log(y**2 * norm_q_carree
@@ -54,7 +66,7 @@ def _integrand_dblquad(x, y, norm_q_carree, norm_p_carree, scal_qpq,
54
66
  return integrand_function
55
67
 
56
68
 
57
- def _compute_viewfactor_dblquad(pts1, pts2, constante):
69
+ def compute_viewfactor_dblquad(pts1, pts2, constante):
58
70
  """
59
71
  Robust fallback integrator using SciPy’s dblquad for contour integration.
60
72
 
@@ -65,18 +77,24 @@ def _compute_viewfactor_dblquad(pts1, pts2, constante):
65
77
 
66
78
  Parameters
67
79
  ----------
68
- pts1 : ndarray, shape (n1, 3)
69
- Rounded vertex coordinates of the *receiving* facet.
70
- pts2 : ndarray, shape (n2, 3)
71
- Rounded (and possibly epsilon-shifted) vertex coordinates of the
80
+ * **pts1** : ndarray, shape (n1, 3)
81
+
82
+ > Rounded vertex coordinates of the *receiving* facet.
83
+
84
+ * **pts2** : *ndarray*, shape (n2, 3)
85
+
86
+ > Rounded (and possibly epsilon-shifted) vertex coordinates of the
72
87
  *emitting* facet.
73
- constante : float
74
- Normalization constant = 4π × area of the emitting facet.
88
+
89
+ * **constante** : *float*
90
+
91
+ > Normalization constant = 4π × area of the emitting facet.
75
92
 
76
93
  Returns
77
94
  -------
78
- float
79
- The computed view factor from emitting→receiving (non-negative).
95
+ * **float**
96
+
97
+ > The computed view factor from F<sub>2→1</sub> (non-negative).
80
98
 
81
99
  Notes
82
100
  -----
@@ -103,7 +121,7 @@ def _compute_viewfactor_dblquad(pts1, pts2, constante):
103
121
  sqpp = np.dot(d, e2)
104
122
  spq = scal[i, j]
105
123
  val, _ = scipy.integrate.dblquad(
106
- _integrand_dblquad,
124
+ integrand_dblquad,
107
125
  0.0, 1.0,
108
126
  lambda xx: 0.0, lambda xx: 1.0,
109
127
  args=(nq, np_, sqpq, sqpp, spq, nqp)
@@ -116,10 +134,9 @@ def _compute_viewfactor_dblquad(pts1, pts2, constante):
116
134
  return 0.0
117
135
 
118
136
 
119
- # #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
120
137
  # GAUSS LEGENDRE INTEGRATION
121
138
 
122
- # Default settings.
139
+ # Default settings.
123
140
  # Precompute 30×30 nodes & weights once
124
141
  _GL_ORDER = 30
125
142
  _nodes, _weights = leggauss(_GL_ORDER)
@@ -162,9 +179,8 @@ def set_quadrature_order(order: int):
162
179
  _GL_W = 0.5 * weights
163
180
 
164
181
 
165
-
166
182
  @njit
167
- def _integrand_gauss_legendre(norm_q, norm_p, scal_qpq, scal_qpp, scal_pq, norm_qp):
183
+ def integrand_gauss_legendre(norm_q, norm_p, scal_qpq, scal_qpp, scal_pq, norm_qp):
168
184
  """
169
185
  Fixed‐order Gauss–Legendre quadrature kernel for one edge‐pair.
170
186
 
@@ -173,23 +189,35 @@ def _integrand_gauss_legendre(norm_q, norm_p, scal_qpq, scal_qpp, scal_pq, norm_
173
189
 
174
190
  Parameters
175
191
  ----------
176
- norm_q : float
177
- Squared length of the directed edge from the receiving facet.
178
- norm_p : float
179
- Squared length of the directed edge from the emitting facet.
180
- scal_qpq : float
181
- Dot(edge_q, vector between vertices).
182
- scal_qpp : float
183
- Dot(edge_p, vector between vertices).
184
- scal_pq : float
185
- Dot(edge_q, edge_p).
186
- norm_qp : float
192
+ * **norm_q**: *float*
193
+
194
+ > Squared length of the directed edge from the receiving facet.
195
+
196
+ * **norm_p**: *float*
197
+
198
+ > Squared length of the directed edge from the emitting facet.
199
+
200
+ * **scal_qpq**: *float*
201
+
202
+ > Dot(edge_q, vector between vertices).
203
+
204
+ * **scal_qpp**: *float*
205
+
206
+ > dot(edge_p, vector between vertices).
207
+
208
+ * **scal_pq**: *float*
209
+
210
+ > dot(edge_q, edge_p).
211
+
212
+ * **norm_qp** : *float*
213
+
187
214
  Squared length of the vector between a vertex on facet1 and a vertex on facet2.
188
215
 
189
216
  Returns
190
217
  -------
191
- float
192
- Contribution of this edge‐pair to the contour integral,
218
+ * **float**
219
+
220
+ > Contribution of this edge‐pair to the contour integral,
193
221
  already multiplied by the Gauss–Legendre weights.
194
222
  """
195
223
  total = 0.0
@@ -210,29 +238,34 @@ def _integrand_gauss_legendre(norm_q, norm_p, scal_qpq, scal_qpp, scal_pq, norm_
210
238
  return total
211
239
 
212
240
 
213
-
214
241
  @njit
215
- def _compute_viewfactor_gauss_legendre(pts1, pts2, constante):
242
+ def compute_viewfactor_gauss_legendre(pts1, pts2, constante):
216
243
  """
217
244
  Fast Numba‐JITed contour integrator using fixed‐order Gauss–Legendre.
218
245
 
219
246
  This routine evaluates the view‐factor contour integral by looping
220
247
  over every pair of directed edges on two convex planar facets,
221
- approximating the double integral with a 10×10 Gauss–Legendre rule
222
- (or _GL_ORDER value is modified)
223
- .
248
+ approximating the double integral with a 30×30 Gauss–Legendre rule
249
+ (or _GL_ORDER value can modified)
250
+
224
251
  Parameters
225
252
  ----------
226
- pts1 : ndarray, shape (n1,3)
227
- Ordered vertex coordinates of the *receiving* facet.
228
- pts2 : ndarray, shape (n2,3)
229
- Ordered (and possibly shifted) vertex coordinates of the *emitting* facet.
230
- constante : float
231
- Normalization factor = 4π × area of the emitting facet.
253
+ * **pts1** : *ndarray*, shape (n1,3)
254
+
255
+ > Ordered vertex coordinates of the *receiving* facet.
256
+
257
+ * **pts2** : *ndarray*, shape (n2,3)
258
+
259
+ > Ordered (and possibly shifted) vertex coordinates of the *emitting* facet.
260
+
261
+ * **constante** : *float*
262
+
263
+ > Normalization factor = 4π × area of the emitting facet.
232
264
 
233
265
  Returns
234
266
  -------
235
- float
267
+ * **float**
268
+
236
269
  The view factor F<sub>2→1</sub>, clamped to ≥0.
237
270
 
238
271
  Notes
@@ -277,7 +310,6 @@ def _compute_viewfactor_gauss_legendre(pts1, pts2, constante):
277
310
  sqpq = np.dot(d, e1)
278
311
  sqpp = np.dot(d, e2)
279
312
  spq = scal[i, j]
280
- total += _integrand_gauss_legendre(nq, np_, sqpq, sqpp, spq, nqp)
313
+ total += integrand_gauss_legendre(nq, np_, sqpq, sqpp, spq, nqp)
281
314
  vf = total / constante
282
315
  return vf
283
-
@@ -1,8 +1,10 @@
1
- # plot.py
1
+ """
2
+ `file: pvf_plot.py`
3
+ """
2
4
  import pyvista as pv
3
5
  import numpy as np
4
- # Helper function to plot a mesh with view factor from one of the cells
5
- # to all others.
6
+
7
+
6
8
  def plot_viewfactor(mesh: pv.PolyData,
7
9
  F: np.ndarray,
8
10
  cell_id: int,
@@ -11,32 +13,43 @@ def plot_viewfactor(mesh: pv.PolyData,
11
13
  """
12
14
  Render a mesh colored by the view‐factor distribution from one source cell.
13
15
 
14
- This helper attaches the row F[cell_id, :] as a new cell‐array
16
+ This helper attaches the row F[:, cell_id] as a new cell‐array
15
17
  `'ViewFactor'` and displays it via PyVista.
16
18
 
17
19
  Parameters
18
20
  ----------
19
- mesh : pyvista.PolyData
20
- Closed or open mesh whose cells correspond to both rows and columns of F.
21
- F : ndarray, shape (n_cells, n_cells)
22
- Precomputed view‐factor matrix.
23
- cell_id : int
24
- Index of the source cell whose F → others will be plotted.
25
- cmap : str, optional
26
- Name of a Matplotlib colormap (default=`"viridis"`).
27
- show : bool, optional
28
- If `True`, calls `pl.show()` before returning.
21
+ * **mesh** : *pyvista.PolyData*
22
+
23
+ > Closed or open mesh whose cells correspond to both rows and columns of F.
24
+
25
+ * **F** : *ndarray*, shape (n_cells, n_cells)
26
+
27
+ > Precomputed view‐factor matrix.
28
+
29
+ * **cell_id** : *int*
30
+
31
+ > Index of the source cell whose F → others will be plotted.
32
+
33
+ * **cmap** : *str*, optional
34
+
35
+ > Name of a Matplotlib colormap (default=`"viridis"`).
36
+
37
+ * **show** : *bool*, optional
38
+
39
+ > If `True`, calls `pl.show()` before returning.
29
40
  If `False`, returns the `Plotter` for further customization.
30
41
 
31
42
  Returns
32
43
  -------
33
- pv.Plotter
34
- The PyVista Plotter instance with the view‐factor plot.
44
+ * **pv.Plotter**
45
+
46
+ >The PyVista Plotter instance with the view‐factor plot.
35
47
 
36
48
  Raises
37
49
  ------
38
- ValueError
39
- If `F.shape != (mesh.n_cells, mesh.n_cells)`.
50
+ * **ValueError**
51
+
52
+ > If `F.shape != (mesh.n_cells, mesh.n_cells)`.
40
53
 
41
54
  Examples
42
55
  --------
@@ -55,7 +68,7 @@ def plot_viewfactor(mesh: pv.PolyData,
55
68
 
56
69
  # Make a copy so we don’t overwrite the original cell_data
57
70
  mesh_pf = mesh.copy()
58
- mesh_pf.cell_data["ViewFactor"] = F[cell_id, :]
71
+ mesh_pf.cell_data["ViewFactor"] = F[:, cell_id]
59
72
 
60
73
  pl = pv.Plotter()
61
74
  pl.add_mesh(
@@ -71,7 +84,4 @@ def plot_viewfactor(mesh: pv.PolyData,
71
84
  pl.show()
72
85
  return pl
73
86
 
74
-
75
-
76
-
77
- """ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ End Of File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ """
87
+ # End of file