48 lines
1.4 KiB
C++
48 lines
1.4 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 = 100;
|
|
int cols = 100;
|
|
Grid64 grid(rows, cols);
|
|
|
|
MatrixXd concentrations = MatrixXd::Constant(rows, cols, 0);
|
|
concentrations(10, 10) = 2000;
|
|
concentrations(90, 90) = 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.setBoundarySideConstant(BC_SIDE_LEFT, 1);
|
|
bc.setBoundarySideConstant(BC_SIDE_RIGHT, 1);
|
|
bc.setBoundarySideConstant(BC_SIDE_TOP, 0);
|
|
bc.setBoundarySideConstant(BC_SIDE_BOTTOM, 2);
|
|
|
|
// **** SIMULATION ****
|
|
Simulation simulation = Simulation(grid, bc);
|
|
simulation.setTimestep(0.05);
|
|
simulation.setIterations(1000);
|
|
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;
|
|
}
|