TugJulia/julia/tests/cpp_bench/BTCS_2027_1999_200.cpp
2023-12-01 19:36:59 +01:00

67 lines
1.9 KiB
C++

#include <Eigen/Eigen>
#include <tug/Simulation.hpp>
#include <chrono>
#include <iostream>
#include <cmath>
using namespace Eigen;
using namespace tug;
using namespace std::chrono;
int main(int argc, char *argv[])
{
// **** GRID ****
int rows = 2027;
int cols = 1999;
Grid64 grid(rows, cols);
MatrixXd concentrations(rows, cols);
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < cols; ++j)
{
concentrations(i, j) = static_cast<double>((i + 1) * (j + 1)) / 1e2;
}
}
concentrations(10, 10) = 15000;
concentrations(2020, 1994) = 7500;
concentrations(10, 1994) = 7500;
concentrations(2020, 10) = 7500;
grid.setConcentrations(concentrations);
// Complex alpha patterns
MatrixXd alphax = MatrixXd(rows, cols);
MatrixXd alphay = MatrixXd(rows, cols);
for (int i = 0; i < rows; ++i)
{
for (int j = 0; j < cols; ++j)
{
alphax(i, j) = std::sin((i + 1) / 100.0) * std::cos((j + 1) / 100.0);
alphay(i, j) = std::cos((i + 1) / 100.0) * std::sin((j + 1) / 100.0);
}
}
grid.setAlpha(alphax, alphay);
// **** BOUNDARY ****
Boundary bc = Boundary(grid);
bc.setBoundarySideClosed(BC_SIDE_LEFT);
bc.setBoundarySideConstant(BC_SIDE_RIGHT, 1.5);
bc.setBoundarySideClosed(BC_SIDE_TOP);
bc.setBoundarySideConstant(BC_SIDE_BOTTOM, 0.75);
// **** SIMULATION ****
Simulation simulation = Simulation(grid, bc);
simulation.setTimestep(0.005);
simulation.setIterations(200);
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;
}