-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParaCell.cpp
More file actions
114 lines (69 loc) · 2.34 KB
/
Copy pathParaCell.cpp
File metadata and controls
114 lines (69 loc) · 2.34 KB
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//============================================================================
// Name : CellCycleSimulator.cpp
// Author : M. Herajy
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include "simulators/serialcellsimulator.h"
#include "export/resultexporter.h"
#include "simulators/parallelsimulator.h"
#include <chrono>
#include <time.h>
#include <mpi.h>
using namespace std;
typedef std::chrono::steady_clock StopWatch;
//comment this line for serial simulation
#define PARASIM
//Symmetric division (df=0.5)
//#define SYMDIVISION
int main() {
clock_t t1,t2;
t1=clock();
#if defined(PARASIM)
//parallel simulation
int myrank, size;
//initialize MPI communication
MPI_Init(NULL, NULL);
//get the number of processes
MPI_Comm_size(MPI_COMM_WORLD, &size);
//get the processor rank
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
//a simulator object is created for each process
ParallelSimulator* l_pcParaSim=new ParallelSimulator(myrank);
//initialize the simulation
l_pcParaSim->InitSimulator();
//simulate a cell
l_pcParaSim->StartSimulation();
//finalize the MPI work
MPI_Finalize();
//record the run time
if(myrank==0){
t2=clock();
float diff = ((float)t2-(float)t1)/CLOCKS_PER_SEC;
cout << "Running time: " << diff <<" s"<< endl;
}
#else
//serial simulation
SerialCellSimulator* l_nCellSimulator=new SerialCellSimulator();
ResultExporter* m_pcResultExporter=new ResultExporter();
//initialize the simulator
l_nCellSimulator->InitSimulator();
l_nCellSimulator->SimulateCell();
//get the result matrix
Matrix2D m_nmResultMatrix=l_nCellSimulator->GetResultMatrix();
VectorDouble m_anTime=l_nCellSimulator->GetTime();
//volume results
VectorDouble m_anVolumeResult=l_nCellSimulator->GetCellularVolumeResult();
//export volume
m_pcResultExporter->ExportVolume(m_anTime,m_anVolumeResult,"volume.csv");
//delete the simulation objects
delete l_nCellSimulator;
delete m_pcResultExporter;
t2=clock();
float diff = ((float)t2-(float)t1)/CLOCKS_PER_SEC;
cout << "Running time: " << diff <<" s"<< endl;
#endif
return 0;
}