mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
#include <tug/Simulation.hpp>
|
|
#include <iostream>
|
|
#include <fstream>
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
int n[4] = {10, 20, 50, 100};
|
|
int iterations[1] = {100};
|
|
int repetition = 10;
|
|
|
|
ofstream myfile;
|
|
myfile.open("time_measure_experiment_openmp_thread_6.csv");
|
|
|
|
for (int i = 0; i < size(n); i++){
|
|
cout << "Grid size: " << n[i] << " x " << n[i] << endl << endl;
|
|
myfile << "Grid size: " << n[i] << " x " << n[i] << endl << endl;
|
|
for(int j = 0; j < size(iterations); j++){
|
|
cout << "Iterations: " << iterations[j] << endl;
|
|
myfile << "Iterations: " << iterations[j] << endl;
|
|
for (int k = 0; k < repetition; k++){
|
|
cout << "Wiederholung: " << k << endl;
|
|
Grid grid = Grid(n[i], n[i]);
|
|
grid.setDomain(n[i], n[i]);
|
|
|
|
MatrixXd concentrations = MatrixXd::Constant(n[i], n[i], 0);
|
|
concentrations(5,5) = 1;
|
|
grid.setConcentrations(concentrations);
|
|
MatrixXd alpha = MatrixXd::Constant(n[i], n[i], 0.5);
|
|
|
|
Boundary bc = Boundary(grid);
|
|
|
|
Simulation sim = Simulation(grid, bc, FTCS_APPROACH);
|
|
|
|
|
|
sim.setTimestep(0.001);
|
|
sim.setIterations(iterations[j]);
|
|
sim.setOutputCSV(CSV_OUTPUT_OFF);
|
|
|
|
auto begin = std::chrono::high_resolution_clock::now();
|
|
sim.run();
|
|
auto end = std::chrono::high_resolution_clock::now();
|
|
auto milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(end - begin);
|
|
myfile << milliseconds.count() << endl;
|
|
}
|
|
}
|
|
cout << endl;
|
|
myfile << endl;
|
|
|
|
}
|
|
myfile.close();
|
|
} |