test: added FTCS testcase with large timestep
[skip ci]
This commit is contained in:
parent
6269805eba
commit
5660783929
50
julia/tests/cpp_bench/FTCS_500_500_300.cpp
Normal file
50
julia/tests/cpp_bench/FTCS_500_500_300.cpp
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
39
julia/tests/julia_bench/FTCS_500_500_300.jl
Normal file
39
julia/tests/julia_bench/FTCS_500_500_300.jl
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
include("../../tug/Simulation.jl")
|
||||||
|
|
||||||
|
function main()
|
||||||
|
# **** GRID ****
|
||||||
|
rows::Int = 500
|
||||||
|
cols::Int = 500
|
||||||
|
|
||||||
|
alphaX = fill(0.7, rows, cols)
|
||||||
|
alphaY = fill(0.7, rows, cols)
|
||||||
|
alphaX[201:300, 201:300] .= 0.4
|
||||||
|
alphaY[201:300, 201:300] .= 0.4
|
||||||
|
grid::Grid = Grid{Float64}(rows, cols, alphaX, alphaY)
|
||||||
|
|
||||||
|
concentrations = fill(0.0, rows, cols)
|
||||||
|
concentrations[51:150, 51:150] .= 1500
|
||||||
|
concentrations[351:450, 351:450] .= 1200
|
||||||
|
concentrations[251, 251] = 2000
|
||||||
|
setConcentrations!(grid, concentrations)
|
||||||
|
|
||||||
|
# **** BOUNDARY ****
|
||||||
|
bc::Boundary = Boundary(grid)
|
||||||
|
setBoundarySideClosed!(bc, LEFT)
|
||||||
|
setBoundarySideClosed!(bc, RIGHT)
|
||||||
|
setBoundarySideClosed!(bc, TOP)
|
||||||
|
setBoundarySideClosed!(bc, BOTTOM)
|
||||||
|
|
||||||
|
# **** SIMULATION ****
|
||||||
|
simulation::Simulation = Simulation(grid, bc, FTCS)
|
||||||
|
simulation = setTimestep(simulation, 2.5)
|
||||||
|
simulation = setIterations(simulation, 300)
|
||||||
|
simulation = setOutputConsole(simulation, CONSOLE_OUTPUT_OFF)
|
||||||
|
simulation = setOutputCSV(simulation, CSV_OUTPUT_ON)
|
||||||
|
|
||||||
|
# **** RUN SIMULATION ****
|
||||||
|
elapsed_time_ns = (@elapsed run(simulation)) * 1e9
|
||||||
|
println("Simulation Time (nanoseconds): ", elapsed_time_ns)
|
||||||
|
end
|
||||||
|
|
||||||
|
main()
|
||||||
Loading…
x
Reference in New Issue
Block a user