-
Notifications
You must be signed in to change notification settings - Fork 55
/
Copy pathiPic3D.cpp
96 lines (73 loc) · 3.12 KB
/
iPic3D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iomanip>
#include "iPic3D.h"
#include "MyClock.h"
MyClock *clocks;
using namespace iPic3D;
int main(int argc, char **argv) {
iPic3D::c_Solver KCode;
bool b_err = false;
/* ------------------------------ */
/* 0- Initialize the solver class */
/* ------------------------------ */
KCode.Init(argc, argv);
KCode.InjectBoundaryParticles();
KCode.GatherMoments();
KCode.WriteOutput(KCode.FirstCycle());
/* ------------ */
/* 1- Main loop */
/* ------------ */
for (int i = KCode.FirstCycle()+1; i <= KCode.LastCycle(); i++) {
if (KCode.get_myrank() == 0) cout << " ======= Cycle " << i << " ======= " << endl;
/* ----------------------------------------------------- */
/* 2- Calculate fields and move particles */
/* Exit if there is a memory issue with the particles */
/* ----------------------------------------------------- */
KCode.UpdateCycleInfo(i);
clocks->start(2);
KCode.CalculateField();
clocks->stop(2);
clocks->start(3);
b_err = KCode.ParticlesMover();
if (!b_err) KCode.CalculateBField();
clocks->stop(3);
clocks->start(1);
if (!b_err) KCode.GatherMoments();
clocks->stop(1);
if ( b_err) i = KCode.LastCycle() + 1;
/* --------------- */
/* 3- Output files */
/* --------------- */
clocks->start(4);
KCode.WriteOutput(i);
KCode.WriteConserved(i);
KCode.WriteRestart(i);
clocks->stop(4);
/* if (i == 0 || i%(10)==0) {
if (KCode.get_myrank() == 0) {
std::cout << "################################################" << std::endl
<< "Initialization : " << clocks->get(0) << " s" << std::endl
<< "Moments Gathering : " << clocks->get(1) << " s" << std::endl
<< "Field Calculation : " << clocks->get(2) << " s" << std::endl
<< "Particle Mover : " << clocks->get(3) << " s" << std::endl
<< "Writing : " << clocks->get(4) << " s" << std::endl
<< "**************************************************" << std::endl;
}
}
*/
}
int myrank;
myrank = KCode.get_myrank();
//MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
KCode.Finalize();
if (myrank == 0) {
std::cout << "################################################" << std::endl
<< "Initialization : " << clocks->get(0) << " s" << std::endl
<< "Moments Gathering : " << clocks->get(1) << " s" << std::endl
<< "Field Calculation : " << clocks->get(2) << " s" << std::endl
<< "Particle Mover : " << clocks->get(3) << " s" << std::endl
<< "Writing : " << clocks->get(4) << " s" << std::endl
<< "----------------------------------------------------------" << std::endl
<< "Total : " << clocks->get(5)<< " s" << std::endl;
}
return 0;
}