75 for (
int i = 0; i < 3; i++) {
78 rmin(i) = (rmin(i) + mu[i]) *
sigmaR_m[i];
79 rmax(i) = (rmax(i) + mu[i]) *
sigmaR_m[i];
83 const double par[6] = {mu[0], sd[0], mu[1], sd[1], mu[2], sd[2]};
85 using Dist_t = ippl::random::NormalDistribution<double, 3>;
86 using sampling_t = ippl::random::InverseTransformSampling<double, 3, Kokkos::DefaultExecutionSpace, Dist_t>;
89 MPI_Comm comm = MPI_COMM_WORLD;
91 MPI_Comm_size(comm, &nranks);
92 MPI_Comm_rank(comm, &rank);
94 size_t nlocal = floor(numberOfParticles / nranks);
95 size_t remaining = numberOfParticles - nlocal * nranks;
97 if (remaining > 0 && rank == 0) {
101 sampling_t sampling(dist, rmax, rmin, rmax, rmin, nlocal);
102 nlocal = sampling.getLocalSamplesNum();
103 pc_m->create(nlocal);
104 sampling.generate(Rview, rand_pool64);
108 double meanR[3], loc_meanR[3];
109 for(
int i=0; i<3; i++){
114 Kokkos::parallel_reduce(
115 "calc moments of particle distr.", nlocal,
117 const int k,
double& cent0,
double& cent1,
double& cent2) {
118 cent0 += Rview(k)[0];
119 cent1 += Rview(k)[1];
120 cent2 += Rview(k)[2];
122 Kokkos::Sum<double>(loc_meanR[0]), Kokkos::Sum<double>(loc_meanR[1]), Kokkos::Sum<double>(loc_meanR[2]));
125 MPI_Allreduce(loc_meanR, meanR, 3, MPI_DOUBLE, MPI_SUM, ippl::Comm->getCommunicator());
126 ippl::Comm->barrier();
128 for(
int i=0; i<3; i++){
129 meanR[i] = meanR[i]/(1.0*numberOfParticles);
132 Kokkos::parallel_for(
133 nlocal, KOKKOS_LAMBDA(
135 Rview(k)[0] -= meanR[0];
136 Rview(k)[1] -= meanR[1];
137 Rview(k)[2] -= meanR[2];
143 for (
int i = 0; i < 3; i++) {
149 Kokkos::parallel_for(
151 ippl::random::randn<double, 3>(Pview, rand_pool64, mu, sd)
156 Kokkos::parallel_for(
158 KOKKOS_LAMBDA(
const int k) {
159 Pview(k)[2] += avrgpz;
Gaussian(std::shared_ptr< ParticleContainer_t > &pc, std::shared_ptr< FieldContainer_t > &fc, std::shared_ptr< Distribution_t > &opalDist)
Constructor for the Gaussian sampler.