51 lines
1.7 KiB
C++
51 lines
1.7 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 = 500;
|
|
int cols = 500;
|
|
Grid64 grid(rows, cols);
|
|
|
|
MatrixXd concentrations = MatrixXd::Constant(rows, cols, 0);
|
|
concentrations.block(50, 50, 100, 100) = MatrixXd::Constant(100, 100, 1500);
|
|
concentrations.block(350, 350, 100, 100) = MatrixXd::Constant(100, 100, 1200);
|
|
concentrations(250, 250) = 2000;
|
|
grid.setConcentrations(concentrations);
|
|
|
|
MatrixXd alphax = MatrixXd::Constant(rows, cols, 0.7);
|
|
MatrixXd alphay = MatrixXd::Constant(rows, cols, 0.7);
|
|
alphax.block(200, 200, 100, 100) = MatrixXd::Constant(100, 100, 0.4);
|
|
alphay.block(200, 200, 100, 100) = MatrixXd::Constant(100, 100, 0.4);
|
|
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(2.5);
|
|
simulation.setIterations(300);
|
|
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 << "Simulation Time (nanoseconds): " << duration.count() << std::endl;
|
|
}
|