1+ #pragma once
2+
3+ #include " ../process/psProcessModel.hpp"
4+ #include " ../psMaterials.hpp"
5+
6+ #include < rayParticle.hpp>
7+ #include < rayReflection.hpp>
8+
9+ namespace viennaps {
10+
11+ using namespace viennacore ;
12+
13+ namespace impl {
14+ template <typename NumericType, int D>
15+ class TestFluxParticle
16+ : public viennaray::Particle<TestFluxParticle<NumericType, D>,
17+ NumericType> {
18+ public:
19+ TestFluxParticle (NumericType sticking, NumericType sourcePower)
20+ : stickingProbability_(sticking), sourcePower_(sourcePower) {}
21+
22+ void surfaceCollision (NumericType rayWeight, const Vec3D<NumericType> &,
23+ const Vec3D<NumericType> &, const unsigned int primID,
24+ const int ,
25+ viennaray::TracingData<NumericType> &localData,
26+ const viennaray::TracingData<NumericType> *,
27+ RNG &) override final {
28+ if (!isReflected_) {
29+ localData.getVectorData (0 )[primID] += rayWeight;
30+ } else {
31+ localData.getVectorData (1 )[primID] += rayWeight;
32+ }
33+ }
34+ std::pair<NumericType, Vec3D<NumericType>>
35+ surfaceReflection (NumericType, const Vec3D<NumericType> &,
36+ const Vec3D<NumericType> &geomNormal, const unsigned int ,
37+ const int , const viennaray::TracingData<NumericType> *,
38+ RNG &rngState) override final {
39+ isReflected_ = true ;
40+ auto direction =
41+ viennaray::ReflectionDiffuse<NumericType, D>(geomNormal, rngState);
42+ return std::pair<NumericType, Vec3D<NumericType>>{stickingProbability_,
43+ direction};
44+ }
45+ void initNew (RNG &) override final { isReflected_ = false ; }
46+ NumericType getSourceDistributionPower () const override final {
47+ return sourcePower_;
48+ }
49+ std::vector<std::string> getLocalDataLabels () const override final {
50+ return {" primaryFlux" , " secondaryFlux" };
51+ }
52+
53+ private:
54+ const NumericType stickingProbability_;
55+ const NumericType sourcePower_;
56+ bool isReflected_ = false ;
57+ };
58+ } // namespace impl
59+
60+ #ifdef VIENNACORE_COMPILE_GPU
61+ namespace gpu {
62+
63+ template <typename NumericType, int D>
64+ class TestFluxModel final : public ProcessModelGPU<NumericType, D> {
65+ public:
66+ TestFluxModel (NumericType stickingProbability, NumericType sourceExponent) {
67+ // particles
68+ viennaray::gpu::Particle<NumericType> particle{
69+ .name = " TestFluxParticle" ,
70+ .sticking = stickingProbability,
71+ .cosineExponent = sourceExponent};
72+ particle.dataLabels .push_back (" primaryFlux" );
73+ particle.dataLabels .push_back (" secondaryFlux" );
74+
75+ std::unordered_map<std::string, unsigned > pMap = {{" TestFluxParticle" , 0 }};
76+ std::vector<viennaray::gpu::CallableConfig> cMap = {
77+ {0 , viennaray::gpu::CallableSlot::COLLISION ,
78+ " __direct_callable__testFluxCollision" },
79+ {0 , viennaray::gpu::CallableSlot::REFLECTION ,
80+ " __direct_callable__singleNeutralReflection" }};
81+ this ->setParticleCallableMap (pMap, cMap);
82+ this ->setCallableFileName (" CallableWrapper" );
83+
84+ // surface model
85+ auto surfModel = SmartPointer<::viennaps::SurfaceModel<NumericType>>::New ();
86+
87+ // velocity field
88+ auto velField =
89+ SmartPointer<::viennaps::DefaultVelocityField<NumericType, D>>::New ();
90+
91+ this ->setSurfaceModel (surfModel);
92+ this ->setVelocityField (velField);
93+ this ->insertNextParticleType (particle);
94+ this ->setProcessName (" TestFluxModel" );
95+ this ->hasGPU = true ;
96+ }
97+ };
98+ } // namespace gpu
99+ #endif
100+
101+ // Etching or deposition based on a single particle model with diffuse
102+ // reflections.
103+ template <typename NumericType, int D>
104+ class TestFluxModel : public ProcessModelCPU <NumericType, D> {
105+ NumericType stickingProbability_ = 1 .;
106+ NumericType sourceDistributionPower_ = 1 .;
107+
108+ public:
109+ TestFluxModel (NumericType stickingProbability = 1 .,
110+ NumericType sourceDistributionPower = 1 .)
111+ : stickingProbability_(stickingProbability),
112+ sourceDistributionPower_ (sourceDistributionPower) {
113+
114+ auto particle = std::make_unique<impl::TestFluxParticle<NumericType, D>>(
115+ stickingProbability_, sourceDistributionPower_);
116+
117+ // surface model
118+ auto surfModel = SmartPointer<SurfaceModel<NumericType>>::New ();
119+
120+ // velocity field
121+ auto velField = SmartPointer<DefaultVelocityField<NumericType, D>>::New ();
122+
123+ this ->setSurfaceModel (surfModel);
124+ this ->setVelocityField (velField);
125+ this ->insertNextParticleType (particle);
126+ this ->setProcessName (" TestFluxModel" );
127+ this ->hasGPU = true ;
128+ }
129+
130+ #ifdef VIENNACORE_COMPILE_GPU
131+ SmartPointer<ProcessModelBase<NumericType, D>> getGPUModel () final {
132+ return SmartPointer<gpu::TestFluxModel<NumericType, D>>::New (
133+ stickingProbability_, sourceDistributionPower_);
134+ }
135+ #endif
136+ };
137+
138+ } // namespace viennaps
0 commit comments