pyviewfactor 0.1.4__tar.gz → 0.1.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyviewfactor
3
- Version: 0.1.4
3
+ Version: 0.1.6
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,5 +1,5 @@
1
1
  """Version info for pyViewFactor"""
2
- version_info = 0, 1, 4
2
+ version_info = 0, 1, 6
3
3
 
4
4
  # Nice string for the version
5
5
  __version__ = '.'.join(map(str, version_info))
@@ -533,23 +533,43 @@ def compute_viewfactor(cell_1, cell_2, epsilon=0.00001, rounding_decimal=6):
533
533
  >>> isinstance(vf, float)
534
534
  True
535
535
  """
536
- # prepare points and edge vectors
537
- c1 = cell_1.cast_to_unstructured_grid().get_cell(0).points
538
- c1 = np.round(c1, rounding_decimal)
539
- c2 = cell_2.cast_to_unstructured_grid().get_cell(0).points
540
- c2 = np.round(c2, rounding_decimal)
541
- v1 = np.roll(c1, -1, axis=0) - c1
542
- v2 = np.roll(c2, -1, axis=0) - c2
543
- # area and constant
544
- A2 = cell_2.compute_cell_sizes(area=True)['Area'][0]
545
- C = 4 * np.pi * A2
546
- # virtual displacement if shared vertices
547
- shared = np.argwhere((c2[:, None, :] == c1[None, :, :]).all(axis=2))
548
- if shared.size > 0:
549
- cent = cell_2.cell_centers().points - cell_1.cell_centers().points
550
- cent = cent / np.linalg.norm(cent)
551
- c2 += epsilon * cent[0]
552
- return compute_viewfactor_core(c1, c2, v1, v2, C)
536
+ # 1) Cast to PolyData & unstructured grid
537
+ c1_poly = cell_1
538
+ c2_poly = cell_2
539
+ ug1 = c1_poly.cast_to_unstructured_grid()
540
+ ug2 = c2_poly.cast_to_unstructured_grid()
541
+
542
+ # 2) Get and round the points
543
+ pts1 = np.round(ug1.get_cell(0).points, rounding_decimal)
544
+ pts2 = np.round(ug2.get_cell(0).points, rounding_decimal)
545
+
546
+ # 3) Detect shared vertices
547
+ # Build a set of tuples for quick compare
548
+ set1 = {tuple(p) for p in pts1}
549
+ set2 = {tuple(p) for p in pts2}
550
+ if set1 & set2: # non-empty intersection → shared vertex/edge
551
+ # compute unit centroid direction
552
+ cen1 = c1_poly.cell_centers().points[0]
553
+ cen2 = c2_poly.cell_centers().points[0]
554
+ dir_vec = cen2 - cen1
555
+ dir_vec = dir_vec / np.linalg.norm(dir_vec)
556
+ # translate pts2 by epsilon
557
+ pts2 = pts2 + epsilon * dir_vec
558
+
559
+ # 4) Recompute auxiliary arrays for the Numba core
560
+ # Build the intra‐edge (directed edge) vectors for each facet
561
+ pts1_roll = np.roll(pts1, -1, axis=0)
562
+ vect_intra_1 = pts1_roll - pts1
563
+ pts2_roll = np.roll(pts2, -1, axis=0)
564
+ vect_intra_2 = pts2_roll - pts2
565
+
566
+ # Compute the 4π·Area constant from cell_2
567
+ area2 = cell_2.compute_cell_sizes(area=True)['Area'][0]
568
+ constante = 4.0 * np.pi * area2
569
+ # 5) Call the Numba core:
570
+ return compute_viewfactor_core(pts1, pts2,
571
+ vect_intra_1, vect_intra_2,
572
+ constante)
553
573
 
554
574
 
555
575
  def compute_viewfactor_matrix(mesh, obstacle=None,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyviewfactor
3
- Version: 0.1.4
3
+ Version: 0.1.6
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
File without changes
File without changes
File without changes
File without changes