67 lines
1.9 KiB
C++
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 * j) / 1e6;
|
|
}
|
|
}
|
|
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 / 100.0) * std::cos(j / 100.0);
|
|
alphay(i, j) = std::cos(i / 100.0) * std::sin(j / 100.0);
|
|
}
|
|
}
|
|
grid.setAlpha(alphax, alphay);
|
|
|
|
// **** BOUNDARY ****
|
|
Boundary bc = Boundary(grid);
|
|
bc.setBoundarySideConstant(BC_SIDE_LEFT, 1.5);
|
|
bc.setBoundarySideConstant(BC_SIDE_RIGHT, 1.5);
|
|
bc.setBoundarySideConstant(BC_SIDE_TOP, 0.75);
|
|
bc.setBoundarySideConstant(BC_SIDE_BOTTOM, 0.75);
|
|
|
|
// **** SIMULATION ****
|
|
Simulation simulation = Simulation<double, tug::FTCS_APPROACH>(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;
|
|
}
|