64 lines
1.8 KiB
C++
64 lines
1.8 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 = 2000;
|
|
int cols = 2000;
|
|
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)) / 1e6);
|
|
}
|
|
}
|
|
concentrations(1000, 1000) = 2000;
|
|
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) + 1;
|
|
alphay(i, j) = std::cos((i + 1) / 100.0) * std::sin((j + 1) / 100.0) + 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.setBoundarySideConstant(BC_SIDE_BOTTOM, 0.75);
|
|
|
|
// **** SIMULATION ****
|
|
Simulation simulation = Simulation<double, tug::FTCS_APPROACH>(grid, bc);
|
|
simulation.setTimestep(0.005);
|
|
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;
|
|
}
|