Skip to content

Commit 966f24f

Browse files
Added Seth's changes
1 parent 9e2a05f commit 966f24f

12 files changed

+68
-56
lines changed

src/celeritas/optical/CoreTrackView.hh

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ class CoreTrackView
7575
// Return a surface physics view
7676
inline CELER_FUNCTION SurfacePhysicsView surface_physics() const;
7777

78-
// Return a surface model view for the given step
79-
inline CELER_FUNCTION
80-
SurfaceModelView surface_model(SurfacePhysicsOrder) const;
81-
8278
// Return an RNG engine
8379
inline CELER_FUNCTION RngEngine rng() const;
8480

@@ -234,20 +230,6 @@ CELER_FUNCTION auto CoreTrackView::surface_physics() const -> SurfacePhysicsView
234230
this->track_slot_id()};
235231
}
236232

237-
//---------------------------------------------------------------------------//
238-
/*!
239-
* Return a surface model view for the given step.
240-
*/
241-
CELER_FUNCTION auto CoreTrackView::surface_model(SurfacePhysicsOrder step) const
242-
-> SurfaceModelView
243-
{
244-
auto s_physics = this->surface_physics();
245-
CELER_EXPECT(s_physics.is_crossing_boundary());
246-
247-
return s_physics.surface_model(
248-
s_physics.traversal_direction(this->geometry().dir()), step);
249-
}
250-
251233
//---------------------------------------------------------------------------//
252234
/*!
253235
* Return the RNG engine.

src/celeritas/optical/action/ActionLauncher.device.hh

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,25 @@ namespace optical
4444
}
4545
* \endcode
4646
*/
47-
template<class F, class StepActionT = OpticalStepActionInterface>
47+
template<class F>
4848
class ActionLauncher : public KernelLauncher<F>
4949
{
5050
static_assert(
5151
(std::is_trivially_copyable_v<F> || CELERITAS_USE_HIP
5252
|| CELER_COMPILER == CELER_COMPILER_CLANG)
5353
&& !std::is_pointer_v<F> && !std::is_reference_v<F>,
5454
R"(Launched action must be a trivially copyable function object)");
55-
// using StepActionT = OpticalStepActionInterface;
5655

5756
public:
5857
// Create a launcher from a string
5958
using KernelLauncher<F>::KernelLauncher;
6059

6160
// Create a launcher from an action
61+
template<class StepActionT>
6262
explicit ActionLauncher(StepActionT const& action);
6363

6464
// Create a launcher with a string extension
65+
template<class StepActionT>
6566
ActionLauncher(StepActionT const& action, std::string_view ext);
6667

6768
// Launch a kernel for a thread range or number of threads
@@ -76,30 +77,32 @@ class ActionLauncher : public KernelLauncher<F>
7677
/*!
7778
* Create a launcher from an action.
7879
*/
79-
template<class F, class StepActionT>
80-
ActionLauncher<F, StepActionT>::ActionLauncher(StepActionT const& action)
81-
: ActionLauncher{action.label()}
80+
template<class F>
81+
template<class StepActionT>
82+
ActionLauncher<F>::ActionLauncher(StepActionT const& action)
83+
: KernelLauncher<F>{action.label()}
8284
{
8385
}
8486

8587
//---------------------------------------------------------------------------//
8688
/*!
8789
* Create a launcher with a string extension.
8890
*/
89-
template<class F, class StepActionT>
90-
ActionLauncher<F, StepActionT>::ActionLauncher(StepActionT const& action,
91-
std::string_view ext)
92-
: ActionLauncher{std::string(action.label()) + "-" + std::string(ext)}
91+
template<class F>
92+
template<class StepActionT>
93+
ActionLauncher<F>::ActionLauncher(StepActionT const& action,
94+
std::string_view ext)
95+
: KernelLauncher<F>{std::string(action.label()) + "-" + std::string(ext)}
9396
{
9497
}
9598

9699
//---------------------------------------------------------------------------//
97100
/*!
98101
* Launch a kernel for the wrapped executor.
99102
*/
100-
template<class F, class StepActionT>
101-
void ActionLauncher<F, StepActionT>::operator()(
102-
CoreState<MemSpace::device> const& state, F const& call_thread) const
103+
template<class F>
104+
void ActionLauncher<F>::operator()(CoreState<MemSpace::device> const& state,
105+
F const& call_thread) const
103106
{
104107
return (*this)(
105108
range(ThreadId{state.size()}), state.stream_id(), call_thread);

src/celeritas/optical/surface/SurfacePhysicsParams.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
#include "celeritas/inp/SurfacePhysics.hh"
1212
#include "celeritas/phys/SurfacePhysicsMapBuilder.hh"
1313

14-
#include "BuiltinSurfaceModelBuilder.hh"
1514
#include "model/GaussianRoughnessModel.hh"
1615
#include "model/PolishedRoughnessModel.hh"
1716
#include "model/SmearRoughnessModel.hh"
1817

18+
#include "detail/BuiltinSurfaceModelBuilder.hh"
19+
1920
namespace celeritas
2021
{
2122
namespace optical
@@ -133,7 +134,7 @@ auto SurfacePhysicsParams::build_models(
133134
for (auto step : range(SurfacePhysicsOrder::size_))
134135
{
135136
// Build fake models
136-
BuiltinSurfaceModelBuilder build_model{step_models[step]};
137+
detail::BuiltinSurfaceModelBuilder build_model{step_models[step]};
137138
switch (step)
138139
{
139140
case SurfacePhysicsOrder::roughness:

src/celeritas/optical/surface/SurfacePhysicsView.hh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ class SurfacePhysicsView
123123
SurfaceModelView surface_model(SubsurfaceDirection,
124124
SurfacePhysicsOrder) const;
125125

126+
// Get surface model for the given step
127+
inline CELER_FUNCTION SurfaceModelView
128+
surface_model(Real3 const&, SurfacePhysicsOrder) const;
129+
126130
// Get local facet normal
127131
inline CELER_FUNCTION Real3 const& facet_normal() const;
128132

@@ -375,6 +379,21 @@ CELER_FUNCTION SurfaceModelView SurfacePhysicsView::surface_model(
375379
this->subsurface_material(this->subsurface_position() + dir)};
376380
}
377381

382+
//---------------------------------------------------------------------------//
383+
/*!
384+
* Get surface model view of the given step for a track moving in the given
385+
* direction.
386+
*
387+
* Helper function that determines the traversal direction from the track
388+
* direction and constructs a surface model from it.
389+
*/
390+
CELER_FUNCTION SurfaceModelView SurfacePhysicsView::surface_model(
391+
Real3 const& dir, SurfacePhysicsOrder step) const
392+
{
393+
CELER_EXPECT(this->is_crossing_boundary());
394+
return this->surface_model(this->traversal_direction(dir), step);
395+
}
396+
378397
//---------------------------------------------------------------------------//
379398
/*!
380399
* Get local facet normal after roughness sampling.

src/celeritas/optical/surface/TrackSlotExecutor.hh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ struct IsSurfaceModelEqual
2727
CELER_FUNCTION bool operator()(CoreTrackView const& track) const
2828
{
2929
return track.surface_physics().is_crossing_boundary()
30-
&& track.surface_model(step).surface_model() == model;
30+
&& track.surface_physics()
31+
.surface_model(track.geometry().dir(), step)
32+
.surface_model()
33+
== model;
3134
}
3235
};
3336

src/celeritas/optical/surface/BuiltinSurfaceModelBuilder.hh renamed to src/celeritas/optical/surface/detail/BuiltinSurfaceModelBuilder.hh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,18 @@
22
// Copyright Celeritas contributors: see top-level COPYRIGHT file for details
33
// SPDX-License-Identifier: (Apache-2.0 OR MIT)
44
//---------------------------------------------------------------------------//
5-
//! \file celeritas/optical/surface/BuiltinSurfaceModelBuilder.hh
5+
//! \file celeritas/optical/surface/detail/BuiltinSurfaceModelBuilder.hh
66
//---------------------------------------------------------------------------//
77
#pragma once
88

99
#include <memory>
1010

11-
#include "SurfaceModel.hh"
12-
#include "model/BuiltinSurfaceModel.hh"
11+
#include "celeritas/optical/surface/model/BuiltinSurfaceModel.hh"
1312

1413
namespace celeritas
1514
{
1615
namespace optical
1716
{
18-
namespace
19-
{
2017
//---------------------------------------------------------------------------//
2118
template<>
2219
struct BuiltinApplier<SurfacePhysicsOrder::size_>
@@ -25,6 +22,10 @@ struct BuiltinApplier<SurfacePhysicsOrder::size_>
2522
using Applier = TrivialApplier<T>;
2623
};
2724

25+
namespace detail
26+
{
27+
namespace
28+
{
2829
//---------------------------------------------------------------------------//
2930
/*!
3031
* Fake model as a placeholder for surface models yet to be implemented.
@@ -88,7 +89,7 @@ class BuiltinSurfaceModelBuilder
8889

8990
public:
9091
// Construct with storage to fill
91-
inline BuiltinSurfaceModelBuilder(std::vector<SPModel>& models);
92+
explicit inline BuiltinSurfaceModelBuilder(std::vector<SPModel>& models);
9293

9394
// Construct a fake surface model
9495
template<class T>
@@ -190,5 +191,6 @@ std::shared_ptr<M> BuiltinSurfaceModelBuilder::builtin_model_from_input(
190191
}
191192

192193
//---------------------------------------------------------------------------//
194+
} // namespace detail
193195
} // namespace optical
194196
} // namespace celeritas

src/celeritas/optical/surface/detail/InitBoundaryExecutor.hh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,18 @@ CELER_FUNCTION void InitBoundaryExecutor::operator()(CoreTrackView& track) const
9090
oriented_surface.orientation = SubsurfaceDirection::forward;
9191
}
9292

93+
// Enforce surface normal convention, swapping normal if geometry returns
94+
// one not entering the surface
95+
Real3 global_normal = geo.normal();
96+
if (!is_entering_surface(geo.dir(), global_normal))
97+
{
98+
global_normal = -global_normal;
99+
}
100+
93101
surface_physics
94102
= SurfacePhysicsView::Initializer{oriented_surface.surface,
95103
oriented_surface.orientation,
96-
geo.normal(),
104+
global_normal,
97105
pre_volume_material,
98106
post_volume_material};
99107

src/celeritas/optical/surface/model/BuiltinSurfaceModel.hh

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ namespace celeritas
1717
{
1818
namespace optical
1919
{
20-
namespace
21-
{
2220
//---------------------------------------------------------------------------//
2321
/*!
2422
* Trivial applier which just forwards the track to the executor.
@@ -62,8 +60,6 @@ struct BuiltinApplier<SurfacePhysicsOrder::interaction>
6260
using Applier = TrivialApplier<T>;
6361
};
6462

65-
} // namespace
66-
6763
//---------------------------------------------------------------------------//
6864
/*!
6965
* Templated base class for built-in optical surface physics models.
@@ -80,7 +76,7 @@ class BuiltinSurfaceModel : public SurfaceModel
8076
//!@{
8177
//! \name Type aliases
8278
template<class T>
83-
using Applier = typename BuiltinApplier<S>::Applier<T>;
79+
using Applier = typename BuiltinApplier<S>::template Applier<T>;
8480
//!@}
8581

8682
public:

src/celeritas/optical/surface/model/GaussianRoughnessModel.cu

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ void GaussianRoughnessModel::step(CoreParams const& params,
2727
auto execute = this->make_executor(
2828
params, state, GaussianRoughnessExecutor{data_.device_ref()});
2929

30-
static ActionLauncher<decltype(execute), SurfaceModel> const launch_kernel(
31-
*this);
30+
static ActionLauncher<decltype(execute)> const launch_kernel(*this);
3231
launch_kernel(state, execute);
3332
}
3433

src/celeritas/optical/surface/model/PolishedRoughnessModel.cu

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ void PolishedRoughnessModel::step(CoreParams const& params,
2727
auto execute
2828
= this->make_executor(params, state, PolishedRoughnessExecutor{});
2929

30-
static ActionLauncher<decltype(execute), SurfaceModel> const launch_kernel(
31-
*this);
30+
static ActionLauncher<decltype(execute)> const launch_kernel(*this);
3231
launch_kernel(state, execute);
3332
}
3433

0 commit comments

Comments
 (0)