66int main(
int argc,
char* argv[]) {
71 Inform msg(
"UniformPlasmaTest");
74 auto start = std::chrono::high_resolution_clock::now();
78 for (
unsigned d = 0; d <
Dim; d++)
79 nr[d] = std::atoi(argv[arg++]);
94 const size_type totalP = std::atoll(argv[arg++]);
95 const unsigned int nt = std::atoi(argv[arg++]);
97 msg <<
"Uniform Plasma Test" <<
endl
98 <<
"nt " << nt <<
" Np= " << totalP <<
" grid = " << nr <<
endl;
102 std::unique_ptr<bunch_type> P;
105 for (
unsigned i = 0; i <
Dim; i++) {
115 const double dt = 1.0;
117 std::array<bool, Dim> isParallel;
118 isParallel.fill(
true);
120 const bool isAllPeriodic =
true;
126 std::string solver = argv[arg++];
127 P = std::make_unique<bunch_type>(PL, hr, rmin, rmax, isParallel, Q, solver);
132 int rest = (int)(totalP - nloc *
ippl::Comm->size());
142 for (
unsigned d = 0; d <
Dim; ++d) {
143 Rmin[d] = origin[d] + lDom[d].
first() * hr[d];
144 Rmax[d] = origin[d] + (lDom[d].
last() + 1) * hr[d];
148 Kokkos::parallel_for(
150 P->R.getView(), rand_pool64, Rmin, Rmax));
152 P->q = P->Q_m / totalP;
156 P->initializeFields(mesh, FL);
162 msg <<
"particles created and initial conditions assigned " <<
endl;
166 P->loadbalancefreq_m = std::atoi(argv[arg++]);
173 P->scatterCIC(totalP, 0, hr);
174 P->initializeORB(FL, mesh);
175 bool fromAnalyticDensity =
false;
185 P->gatherStatistics(totalP);
189 msg <<
"Starting iterations ..." <<
endl;
191 for (
unsigned int it = 0; it < nt; it++) {
198 P->P = P->P - 0.5 * dt * P->E;
202 Kokkos::parallel_for(
205 P->P.getView(), rand_pool64, -hr, hr));
211 P->R = P->R + dt * P->P;
220 if (P->balance(totalP, it + 1)) {
221 msg <<
"Starting repartition" <<
endl;
223 P->repartition(FL, mesh, fromAnalyticDensity);
228 P->scatterCIC(totalP, it + 1, hr);
240 P->P = P->P - 0.5 * dt * P->E;
246 P->gatherStatistics(totalP);
248 msg <<
"Finished time step: " << it + 1 <<
" time: " << P->time_m <<
endl;
257 msg <<
"Uniform Plasma Test: End." <<
endl;
261 auto end = std::chrono::high_resolution_clock::now();
263 std::chrono::duration<double> time_chrono =
264 std::chrono::duration_cast<std::chrono::duration<double>>(end - start);
265 std::cout <<
"Elapsed time: " << time_chrono.count() << std::endl;