tug/src/main.cpp
2022-01-27 10:11:47 +01:00

38 lines
1004 B
C++

#include "BTCSDiffusion.hpp" // for BTCSDiffusion, BTCSDiffusion::BC_DIRICHLET
#include <algorithm> // for copy, max
#include <iostream> // for std
#include <vector> // for vector
using namespace std;
int main(int argc, char *argv[]) {
// dimension of grid
int dim = 1;
int n = 20;
// create input + diffusion coefficients for each grid cell
std::vector<double> alpha(n, 1 * pow(10, -1));
std::vector<double> field(n, 1 * std::pow(10, -6));
// create instance of diffusion module
BTCSDiffusion diffu(dim);
diffu.setXDimensions(1, n);
// set the boundary condition for the left ghost cell to dirichlet
diffu.setBoundaryCondition(0, 5. * std::pow(10, -6),
BTCSDiffusion::BC_CONSTANT);
// set timestep for simulation to 1 second
diffu.setTimestep(1.);
// loop 100 times
// output is currently generated by the method itself
for (int i = 0; i < 100; i++) {
diffu.simulate(field, alpha);
}
return 0;
}