MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / InitRandom

Method InitRandom

Src/Particle/AMReX_ParticleInit.H:972–1362  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

970template <typename ParticleType, int NArrayReal, int NArrayInt,
971 template<class> class Allocator, class CellAssignor>
972void
973ParticleContainer_impl<ParticleType, NArrayReal, NArrayInt, Allocator, CellAssignor>::
974InitRandom (Long icount,
975 ULong iseed,
976 const ParticleInitData& pdata,
977 bool serialize,
978 RealBox containing_bx)
979{
980 BL_PROFILE("ParticleContainer<NSR, NSI, NAR, NAI>::InitRandom()");
981 AMREX_ASSERT(iseed > 0);
982 AMREX_ASSERT(icount > 0);
983
984 AMREX_ASSERT(m_gdb != nullptr);
985
986 const int MyProc = ParallelDescriptor::MyProc();
987 const int NProcs = ParallelDescriptor::NProcs();
988 const int IOProc = ParallelDescriptor::IOProcessorNumber();
989 const auto strttime = amrex::second();
990 const Geometry& geom = Geom(0);
991
992 Real r, x, len[AMREX_SPACEDIM] = { AMREX_D_DECL(geom.ProbLength(0),
993 geom.ProbLength(1),
994 geom.ProbLength(2)) };
995
996 // We will enforce that the particles are within the containing_bx.
997 // If containing_bx is not passed in, it defaults to the full domain.
998 if (!containing_bx.ok()) { containing_bx = geom.ProbDomain(); }
999
1000 // containing_bx is assumed to lie within the domain.
1001 if (!geom.ProbDomain().contains(containing_bx))
1002 {
1003 containing_bx.setLo(geom.ProbLo());
1004 containing_bx.setHi(geom.ProbHi());
1005 }
1006
1007 const Real* xlo = containing_bx.lo();
1008 const Real* xhi = containing_bx.hi();
1009
1010 amrex::InitRandom(iseed+MyProc);
1011
1012 if (serialize)
1013 {
1014 if(icount*AMREX_SPACEDIM >= std::numeric_limits<int>::max())
1015 {
1016 amrex::Abort(
1017 "InitRandom has serialize=true, but this would cause too much "
1018 "particle data to be sent from IOProc. Set serialize=false, "
1019 "or use fewer than " +
1020 std::to_string(
1021 amrex::Math::ceil(
1022 amrex::Real(std::numeric_limits<int>::max()) /
1023 amrex::Real(AMREX_SPACEDIM)
1024 )
1025 ) + " particles."
1026 );
1027 }
1028 //
1029 // We'll let IOProc generate the particles so we get the same

Callers

nothing calls this directly

Calls 15

IOProcessorNumberFunction · 0.85
secondFunction · 0.85
InitRandomFunction · 0.85
AbortFunction · 0.85
IOProcessorFunction · 0.85
RandomFunction · 0.85
ParticleIDWrapperClass · 0.85
ParticleCPUWrapperClass · 0.85
copyAsyncFunction · 0.85
streamSynchronizeFunction · 0.85
PrintClass · 0.85
ProbLengthMethod · 0.80

Tested by

no test coverage detected