TugJulia/julia/tests/cpp_bench/FTCS_20_20_500.cpp
2023-11-30 14:36:27 +01:00

47 lines
1.3 KiB
C++

#include <Eigen/Eigen>
#include <tug/Simulation.hpp>
#include <chrono>
#include <iostream>
using namespace Eigen;
using namespace tug;
using namespace std::chrono;
int main(int argc, char *argv[])
{
// **** GRID ****
int rows = 20;
int cols = 20;
Grid64 grid(rows, cols);
MatrixXd concentrations = MatrixXd::Constant(rows, cols, 0);
concentrations(10, 10) = 2000;
grid.setConcentrations(concentrations);
MatrixXd alphax = MatrixXd::Constant(rows, cols, 1);
MatrixXd alphay = MatrixXd::Constant(rows, cols, 1);
grid.setAlpha(alphax, alphay);
// **** BOUNDARY ****
Boundary bc = Boundary(grid);
bc.setBoundarySideClosed(BC_SIDE_LEFT);
bc.setBoundarySideClosed(BC_SIDE_RIGHT);
bc.setBoundarySideClosed(BC_SIDE_TOP);
bc.setBoundarySideClosed(BC_SIDE_BOTTOM);
// **** SIMULATION ****
Simulation simulation = Simulation<double, tug::FTCS_APPROACH>(grid, bc);
simulation.setTimestep(0.1);
simulation.setIterations(500);
simulation.setOutputCSV(CSV_OUTPUT_ON);
simulation.setOutputConsole(CONSOLE_OUTPUT_OFF);
// **** RUN SIMULATION ****
auto start = high_resolution_clock::now();
simulation.run();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<nanoseconds>(stop - start);
std::cout << duration.count() << std::endl;
}