55#include < raygTraceDisk.hpp>
66#include < raygTraceTriangle.hpp>
77
8- // #define useDiskMesh
8+ #define USE_DISK_MESH
9+ #ifdef USE_DISK_MESH
10+ #define FILE_POST " _disk"
11+ #else
12+ #define FILE_POST " _tri"
13+ #endif
914
1015constexpr int D = 3 ;
1116using NumericType = float ;
12- constexpr bool useGPU = true ;
17+ constexpr bool useGPU = false ;
1318
1419template <class T > auto createCylinderLS (T gridDelta, T radius, T length) {
1520 double bounds[2 * D] = {-1.0 , 1.0 , -1.0 , 1.0 , 0.0 , length + gridDelta};
@@ -104,12 +109,12 @@ auto createCylinderDiskMesh(NumericType gridDelta, NumericType radius,
104109 lsMesh->insertNextNode (Vec3Df{0 .0f , 0 .0f , 0 .0f });
105110 materialIds.push_back (1 );
106111 normals->push_back (Vec3Df{0 .0f , 0 .0f , 1 .0f });
107- radii.push_back (radius);
112+ radii.push_back (radius * 1 . 5f ); // make sure rays hit the plane
108113
109114 lsMesh->insertNextNode (Vec3Df{0 .0f , 0 .0f , float (length)});
110115 materialIds.push_back (2 );
111116 normals->push_back (Vec3Df{0 .0f , 0 .0f , -1 .0f });
112- radii.push_back (radius);
117+ radii.push_back (radius * 1 . 5f ); // make sure rays hit the plane
113118
114119 // viennals::VTKWriter<float>(lsMesh, "cylinder.vtp").apply();
115120
@@ -209,16 +214,19 @@ std::array<NumericType, N> logSpace(NumericType start, NumericType end) {
209214}
210215
211216int main () {
212- auto lengths = logSpace<20 >(.01 , 10000.0 );
217+ auto lengths = logSpace<25 >(.01 , 10000.0 );
213218 // std::array<NumericType, 1> lengths = {100.0};
214219 constexpr NumericType radius = 10.0 ;
215220 constexpr NumericType gridDelta = .5 ;
216221 constexpr int nRays = int (1e7 );
217222 std::vector<unsigned > counts (4 , 0 );
218223
219224 if constexpr (useGPU) {
220- viennacore::CudaBuffer customDataBuffer;
221- customDataBuffer.allocUpload (counts);
225+ #ifdef USE_DISK_MESH
226+ viennacore::Logger::getInstance ()
227+ .addError (" No GPU disk mesh implementation" )
228+ .print ();
229+ #endif
222230
223231 auto context = viennacore::DeviceContext::createContext ();
224232 viennaray::gpu::TraceTriangle<NumericType, D> tracer (context);
@@ -245,7 +253,10 @@ int main() {
245253 tracer.insertNextParticle (particle);
246254 tracer.prepareParticlePrograms ();
247255
248- std::ofstream logFile (" transmission_log_tri_GPU.txt" );
256+ std::string fileName = " transmission_log_GPU" ;
257+ fileName.append (FILE_POST );
258+ fileName.append (" .txt" );
259+ std::ofstream logFile (fileName);
249260 logFile << " LR\t Transmission\t Reflection\t HitsToTransmission\t HitsToReflect"
250261 " ion\n " ;
251262
@@ -281,10 +292,9 @@ int main() {
281292 }
282293
283294 logFile.close ();
284- customDataBuffer.free ();
285295 } else {
286296
287- #ifdef useDiskMesh
297+ #ifdef USE_DISK_MESH
288298 viennaray::TraceDisk<NumericType, D> tracer;
289299#else
290300 viennaray::TraceTriangle<NumericType, D> tracer;
@@ -302,14 +312,17 @@ int main() {
302312 auto particle = std::make_unique<TransmissionParticle>();
303313 tracer.setParticleType (particle);
304314
305- std::ofstream logFile (" transmission_log_disk_CPU.txt" );
315+ std::string fileName = " transmission_log_CPU" ;
316+ fileName.append (FILE_POST );
317+ fileName.append (" .txt" );
318+ std::ofstream logFile (fileName);
306319 logFile << " LR\t Transmission\t Reflection\t HitsToTransmission\t HitsToReflect"
307320 " ion\n " ;
308321
309322 for (auto length : lengths) {
310323 std::cout << " Length: " << length << std::endl;
311324 std::cout << " L/R: " << length / radius << std::endl;
312- #ifdef useDiskMesh
325+ #ifdef USE_DISK_MESH
313326 auto [mesh, materialIds] =
314327 createCylinderDiskMesh (gridDelta, radius, length);
315328#else
@@ -323,6 +336,13 @@ int main() {
323336
324337 tracer.apply ();
325338
339+ // auto info = tracer.getRayTraceInfo();
340+ // std::cout << "Non geo hits: " << info.nonGeometryHits << std::endl;
341+ // std::cout << "Num rays: " << info.numRays << std::endl;
342+ // std::cout << "Boundary hits: " << info.boundaryHits << std::endl;
343+ // std::cout << "Reflections: " << info.reflections << std::endl;
344+ // std::cout << "Rays terminated: " << info.raysTerminated << std::endl;
345+
326346 auto &localData = tracer.getLocalData ();
327347 counts[0 ] = static_cast <unsigned >(
328348 localData.getVectorData (0 )[0 ]); // Transmission count
0 commit comments