Skip to content

Commit b4695ce

Browse files
authored
Fix/blocking (#187)
2 parents b6954b4 + 2fdff6d commit b4695ce

6 files changed

Lines changed: 18 additions & 13 deletions

File tree

artist/core/heliostat_ray_tracer.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -438,19 +438,18 @@ def trace_rays(
438438
)
439439

440440
flux_distributions = []
441+
global_active_indices = torch.nonzero(active_heliostats_mask, as_tuple=True)[0]
441442
for batch_index, (batch_u, batch_e) in enumerate(self.distortions_loader):
442443
sampler_indices = list(self.distortions_sampler)
443-
444+
batch_mask_indices = sampler_indices[
445+
batch_index * self.batch_size : (batch_index + 1) * self.batch_size
446+
]
444447
active_heliostats_mask_batch = torch.zeros(
445448
self.heliostat_group.number_of_active_heliostats,
446449
dtype=torch.bool,
447450
device=device,
448451
)
449-
active_heliostats_mask_batch[
450-
sampler_indices[
451-
batch_index * self.batch_size : (batch_index + 1) * self.batch_size
452-
]
453-
] = True
452+
active_heliostats_mask_batch[batch_mask_indices] = True
454453

455454
rays = self.scatter_rays(
456455
distortion_u=batch_u,
@@ -486,9 +485,10 @@ def trace_rays(
486485
points_at_ray_origins = self.heliostat_group.active_surface_points[
487486
active_heliostats_mask_batch, None, :, :3
488487
].expand(-1, self.light_source.number_of_rays, -1, -1)
489-
ray_to_heliostat_mapping = torch.arange(
490-
number_of_heliostats, device=device
491-
).repeat_interleave(number_of_rays * number_of_points)
488+
batch_global_indices = global_active_indices[batch_mask_indices]
489+
ray_to_heliostat_mapping = batch_global_indices.repeat_interleave(
490+
number_of_rays * number_of_points
491+
)
492492

493493
# Filter out the blocking primitives that are relevant for blocking.
494494
filtered_blocking_primitive_indices = (
@@ -499,7 +499,7 @@ def trace_rays(
499499
..., :3
500500
],
501501
ray_to_heliostat_mapping=ray_to_heliostat_mapping,
502-
max_stack_size=128,
502+
max_stack_size=64,
503503
device=device,
504504
)
505505
)

docs/heliostats.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ As you can see, each facet has a ``position`` relative to the heliostat's center
2626
(``canting_e``, ``canting_n``) that define its orientation.
2727

2828
Kinematics
29-
^^^^^^^^^
29+
^^^^^^^^^^
3030
The heliostat's kinematics model describes the motion of its mechanical system. It's used to predict the final orientation
3131
of the heliostat surface based on variable inputs. The kinematics model is also used to calculate the aligned surface points
3232
and normals for a predicted orientation. The choice of kinematics type can depend on the type and number of actuators or

docs/nurbs_tutorial.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ NURBS in ``ARTIST``
1313

1414
Here we first consider some **NURBS Theory** before investigating **NURBS in
1515
ARTIST**.
16+
All NURBS figures on this page were generated with the tool provided by Yu-Sung Chang (2007), "B-Spline Curve with Knots"
17+
`Wolfram Demonstrations Project`_.
18+
1619

1720
NURBS Theory
1821
------------
@@ -247,3 +250,5 @@ For this calculation of the surface points and surface normals, three internal s
247250
``basis_function_and_derivatives()``.
248251
3. Lastly, the surface points and normals are calculated from the basis functions, their derivatives, and the control
249252
points.
253+
254+
.. _Wolfram Demonstrations Project: https://demonstrations.wolfram.com/BSplineCurveWithKnots/

docs/tutorial_surface_reconstruction.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ in the generated image individually.
103103
104104
105105
Optimizer, Scheduler, Regularizer, and Constraints Configuration
106-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
106+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107107

108108
The surface reconstruction internally uses the ``torch.optim.Adam`` optimizer. Depending on the data you use, different
109109
parameters may perform better for the optimizer - including a different learning rate scheduler. Therefore, we first have

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def device(request: pytest.FixtureRequest) -> torch.device:
3737

3838
os_name = platform.system()
3939
if os_name in {config_dictionary.linux, config_dictionary.windows}:
40-
return torch.device("cuda:1" if torch.cuda.is_available() else "cpu")
40+
return torch.device("cuda" if torch.cuda.is_available() else "cpu")
4141
elif os_name == config_dictionary.mac:
4242
return torch.device("cpu")
4343
else:

0 commit comments

Comments
 (0)