diff --git a/docs_sphinx/index.rst b/docs_sphinx/index.rst index 1301f7e..6c5d9ce 100644 --- a/docs_sphinx/index.rst +++ b/docs_sphinx/index.rst @@ -10,8 +10,9 @@ Welcome to the documentation of the TUG project, a simulation program for solving transport equations in one- and two-dimensional uniform grids using cell centered finite differences. +--------- Diffusion ------------ +--------- TUG can solve diffusion problems with heterogeneous and anisotropic diffusion coefficients. The partial differential equation expressing diff --git a/examples/profiling_openmp.cpp b/examples/profiling_openmp.cpp index 0b07a80..1c83542 100644 --- a/examples/profiling_openmp.cpp +++ b/examples/profiling_openmp.cpp @@ -2,47 +2,60 @@ #include #include #include -#include - int main(int argc, char *argv[]) { - EASY_MAIN_THREAD; - EASY_PROFILER_ENABLE; - profiler::startListen(); - int n = 1000; + int n[4] = {100, 500, 1000, 2000}; + int threads[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; + int iterations[1] = {5}; + int repetition = 1; - Grid grid = Grid(n, n); - grid.setDomain(10, 10); + ofstream myfile; + myfile.open("testLarge.csv"); - MatrixXd concentrations = MatrixXd::Constant(n, n, 0); - concentrations(n/2,n/2) = 1; - grid.setConcentrations(concentrations); - MatrixXd alpha = MatrixXd::Constant(n, n, 0.001); - - Boundary bc = Boundary(grid); - - Simulation sim = Simulation(grid, bc, BTCS_APPROACH); - sim.setSolver(THOMAS_ALGORITHM_SOLVER); - sim.setNumberThreads(1); - - sim.setTimestep(0.001); - sim.setIterations(2); - sim.setOutputCSV(CSV_OUTPUT_OFF); - - auto begin = std::chrono::high_resolution_clock::now(); + 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(1, 1); - EASY_BLOCK("SIMULATION"); - sim.run(); - EASY_END_BLOCK; + MatrixXd concentrations = MatrixXd::Constant(n[i], n[i], 0); + concentrations(n[i]/2,n[i]/2) = 1; + grid.setConcentrations(concentrations); + MatrixXd alpha = MatrixXd::Constant(n[i], n[i], 0.5); - auto end = std::chrono::high_resolution_clock::now(); + Boundary bc = Boundary(grid); - auto milliseconds = std::chrono::duration_cast(end - begin); - cout << milliseconds.count() << endl; + Simulation sim = Simulation(grid, bc, BTCS_APPROACH); + sim.setSolver(THOMAS_ALGORITHM_SOLVER); - profiler::dumpBlocksToFile("./mytest_profile.prof"); - profiler::stopListen(); + if(argc == 2){ + int numThreads = atoi(argv[1]); + sim.setNumberThreads(numThreads); + } + else{ + sim.setNumberThreads(1); + } - return(0); -} + 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(end - begin); + myfile << milliseconds.count() << endl; + } + } + cout << endl; + myfile << endl; + + } + myfile.close(); +} \ No newline at end of file