IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
LandauDamping.cpp
Go to the documentation of this file.
1// Landau Damping Test
2// Usage:
3// srun ./LandauDamping
4// <nx> [<ny>...] <Np> <Nt> <stype> <lbthres>
5// <t_method> --overallocate <ovfactor> --info 10
6// nx = No. cell-centered points in the x-direction
7// ny... = No. cell-centered points in the y-, z-, ...-direction
8// Np = Total no. of macro-particles in the simulation
9// Nt = Number of time steps
10// stype = Field solver type (FFT and CG supported)
11// lbthres = Load balancing threshold i.e., lbthres*100 is the maximum load imbalance
12// percentage which can be tolerated and beyond which
13// particle load balancing occurs. A value of 0.01 is good for many typical
14// simulations.
15// t_method = Time-stepping method used e.g. Leapfrog
16// ovfactor = Over-allocation factor for the buffers used in the communication. Typical
17// values are 1.0, 2.0. Value 1.0 means no over-allocation.
18// Example:
19// srun ./LandauDamping 128 128 128 10000 10 FFT 0.01 LeapFrog --overallocate 2.0 --info 10
20
21constexpr unsigned Dim = 3;
22using T = double;
23const char* TestName = "LandauDamping";
24
25#include "Ippl.h"
26
27#include <Kokkos_MathematicalConstants.hpp>
28#include <Kokkos_MathematicalFunctions.hpp>
29#include <Kokkos_Random.hpp>
30#include <chrono>
31#include <iostream>
32#include <random>
33#include <set>
34#include <string>
35#include <vector>
36
37#include "Manager/datatypes.h"
38
39#include "Utility/IpplTimings.h"
40
42#include "Manager/PicManager.h"
43
44int main(int argc, char* argv[]) {
45 ippl::initialize(argc, argv);
46 {
47 Inform msg(TestName);
49
50 static IpplTimings::TimerRef mainTimer = IpplTimings::getTimer("total");
51 static IpplTimings::TimerRef initializeTimer = IpplTimings::getTimer("initialize");
52 IpplTimings::startTimer(mainTimer);
53 IpplTimings::startTimer(initializeTimer);
54
55 // Read input parameters, assign them to the corresponding memebers of manager
56 int arg = 1;
58 for (unsigned d = 0; d < Dim; d++) {
59 nr[d] = std::atoi(argv[arg++]);
60 }
61
62 size_type totalP = std::atoll(argv[arg++]);
63 int nt = std::atoi(argv[arg++]);
64 std::string solver = argv[arg++];
65
66 double lbt = std::atof(argv[arg++]);
67 std::string step_method = argv[arg++];
68
69 std::vector<std::string> preconditioner_params;
70
71 // Create an instance of a manger for the considered application
72 if (solver == "PCG") {
73 for (int i = 0; i < 5; i++) {
74 preconditioner_params.push_back(argv[arg++]);
75 }
76 }
77
78 LandauDampingManager<T, Dim> manager(totalP, nt, nr, lbt, solver, step_method,
79 preconditioner_params);
80
81 // Perform pre-run operations, including creating mesh, particles,...
82 manager.pre_run();
83
84 IpplTimings::stopTimer(initializeTimer);
85
86 manager.setTime(0.0);
87
88 msg << "Starting iterations ..." << endl;
89
90 manager.run(manager.getNt());
91
92 msg << "End." << endl;
93
94 IpplTimings::stopTimer(mainTimer);
96 IpplTimings::print(std::string("timing.dat"));
97 }
99
100 return 0;
101}
constexpr unsigned Dim
int main(int argc, char *argv[])
ippl::detail::size_type size_type
Definition datatypes.h:23
const char * TestName
ippl::Vector< T, Dim > Vector_t
Definition datatypes.h:38
Inform & endl(Inform &inf)
Definition Inform.cpp:42
#define INFORM_ALL_NODES
Definition Inform.h:38
void initialize(int &argc, char *argv[], MPI_Comm comm)
Definition Ippl.cpp:16
void finalize()
Definition Ippl.cpp:94
void run(int nt)
The main for loop fro running a simulation.
Definition BaseManager.h:63
Timing::TimerRef TimerRef
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
static void print()
static void startTimer(TimerRef t)
void setTime(double time_)
int getNt() const
void pre_run() override
A method that should be used for setting up the simulation.