@@ -73,7 +73,7 @@ void printUsage() {
7373 " -o, --output: output directory name "
7474 " (default is " APP_NAME
7575 " _output)\n "
76- " -e, --example: example number (between 1 and 5 , default is 1)\n "
76+ " -e, --example: example number (between 1 and 6 , default is 1)\n "
7777 " -m, --format: particle output format (xyz or pos. default is xyz)\n "
7878 " -h, --help: print this message\n " );
7979}
@@ -476,13 +476,20 @@ void runExample6(const std::string& rootDir, size_t resolutionX,
476476
477477 // Manually emit particles
478478 std::mt19937 rng;
479- std::uniform_real_distribution<> dist (0 , 1 );
480- for (size_t i = 0 ; i < 8 * resolutionX * resolutionX * resolutionX; ++i) {
481- Vector3D pt{dist (rng), dist (rng), dist (rng)};
482- if ((pt - sphere->center ).length () < sphere->radius && pt.x > 0.5 ) {
483- solver->particleSystemData ()->addParticle (pt);
484- }
485- }
479+ std::uniform_real_distribution<> dist (-0.1 * solver->gridSpacing ().x ,
480+ 0.1 * solver->gridSpacing ().x );
481+ BccLatticePointGenerator pointGenerator;
482+ pointGenerator.forEachPoint (
483+ BoundingBox3D ({0.75 , 0 , 0 }, {1 , 1 , 1 }), 0.5 * solver->gridSpacing ().x ,
484+ [&](const Vector3D& pt) -> bool {
485+ Vector3D newPos = pt + Vector3D{dist (rng), dist (rng), dist (rng)};
486+ if ((pt - Vector3D{0.5 , 0.5 , 0.5 }).length () < 0.4 ) {
487+ solver->particleSystemData ()->addParticle (newPos);
488+ }
489+ return true ;
490+ });
491+ printf (" Number of particles: %zu\n " ,
492+ solver->particleSystemData ()->numberOfParticles ());
486493
487494 // Print simulation info
488495 printf (" Running example 6 (sphere boundary with APIC)\n " );
0 commit comments