mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
added test executable
This commit is contained in:
parent
f2e80c2c48
commit
9461dad147
@ -19,17 +19,28 @@
|
||||
const BCSide BTCSDiffusion::LEFT = 0;
|
||||
const BCSide BTCSDiffusion::RIGHT = 1;
|
||||
|
||||
BTCSDiffusion::BTCSDiffusion(int x) : dim_x(x) { this->grid_dim = 1; }
|
||||
BTCSDiffusion::BTCSDiffusion(int x) : dim_x(x) {
|
||||
this->grid_dim = 1;
|
||||
this->bc.reserve(2);
|
||||
}
|
||||
BTCSDiffusion::BTCSDiffusion(int x, int y) : dim_x(x), dim_y(y) {
|
||||
|
||||
this->grid_dim = 2;
|
||||
this->bc.reserve(x * 2 + y * 2);
|
||||
}
|
||||
BTCSDiffusion::BTCSDiffusion(int x, int y, int z)
|
||||
: dim_x(x), dim_y(y), dim_z(z) {
|
||||
|
||||
this->grid_dim = 3;
|
||||
//TODO: reserve memory for boundary conditions
|
||||
}
|
||||
|
||||
void BTCSDiffusion::setBoundaryCondition(std::vector<double> input,
|
||||
BCSide side) {
|
||||
if (this->grid_dim == 1) {
|
||||
bc[side] = input[0];
|
||||
}
|
||||
}
|
||||
void BTCSDiffusion::simulate(std::vector<double> &c, std::vector<double> &alpha,
|
||||
double timestep) {
|
||||
double dx = 1. / this->dim_x;
|
||||
|
||||
33
src/test_class.cpp
Normal file
33
src/test_class.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
#include "BTCSDiffusion.hpp"
|
||||
#include "diffusion.hpp"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
int x = 20;
|
||||
|
||||
std::vector<double> alpha(x, 1 * pow(10, -1));
|
||||
std::vector<double> input(x, 1 * std::pow(10, -6));
|
||||
std::vector<double> bc_left, bc_right;
|
||||
|
||||
bc_left.push_back(5. * std::pow(10, -6));
|
||||
bc_right.push_back(1. * std::pow(10, -6));
|
||||
// input[x + 2] = 5.5556554 * std::pow(10, -6);
|
||||
// input[x + 3] = 5.234564213 * std::pow(10, -6);
|
||||
|
||||
BTCSDiffusion diffu(x);
|
||||
|
||||
diffu.setBoundaryCondition(bc_left, BTCSDiffusion::LEFT);
|
||||
diffu.setBoundaryCondition(bc_right, BTCSDiffusion::RIGHT);
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
diffu.simulate(input, alpha, 1.);
|
||||
// BTCS1D(x, input, alpha, 1., bc);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user