cross testing FTCS prototype with existing ADI solution
This commit is contained in:
parent
214cb717d3
commit
5688c82da2
@ -2,6 +2,8 @@
|
|||||||
#include <tug/Diffusion.hpp>
|
#include <tug/Diffusion.hpp>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace tug::diffusion;
|
using namespace tug::diffusion;
|
||||||
@ -10,12 +12,12 @@ using namespace tug::bc;
|
|||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
int dim = 2;
|
int dim = 2;
|
||||||
int n = 5;
|
int n = 20;
|
||||||
int m = 5;
|
int m = 20;
|
||||||
|
|
||||||
vector<double> alpha(n * m, 1e-1);
|
vector<double> alpha(n * m, 1);
|
||||||
vector<double> field(n * m, 0);
|
vector<double> field(n * m, 0);
|
||||||
field[0] = 1e-6;
|
field[0] = 2000;
|
||||||
// for (int i = 1; i<20; i++) {
|
// for (int i = 1; i<20; i++) {
|
||||||
// for (int j = 0; j<20; j++ ) {
|
// for (int j = 0; j<20; j++ ) {
|
||||||
// field[i] = 0;
|
// field[i] = 0;
|
||||||
@ -33,25 +35,55 @@ int main(int argc, char *argv[]) {
|
|||||||
cout << endl;
|
cout << endl;
|
||||||
|
|
||||||
TugInput input_param;
|
TugInput input_param;
|
||||||
input_param.setTimestep(1.);
|
input_param.setTimestep(0.1);
|
||||||
input_param.setGridCellN(n, m);
|
input_param.setGridCellN(n, m);
|
||||||
input_param.setDomainSize(n, m);
|
input_param.setDomainSize(n, m);
|
||||||
BoundaryCondition bc(n, m);
|
BoundaryCondition bc(n, m);
|
||||||
|
boundary_condition bc_constant;
|
||||||
|
bc_constant.type = BC_TYPE_CONSTANT;
|
||||||
|
bc_constant.value = 0;
|
||||||
|
bc.setSide(BC_SIDE_LEFT, bc_constant);
|
||||||
|
bc.setSide(BC_SIDE_TOP, bc_constant);
|
||||||
|
bc.setSide(BC_SIDE_RIGHT, bc_constant);
|
||||||
|
bc.setSide(BC_SIDE_BOTTOM, bc_constant);
|
||||||
input_param.setBoundaryCondition(bc);
|
input_param.setBoundaryCondition(bc);
|
||||||
|
|
||||||
|
// int iterations = 1000;
|
||||||
|
// for (int t = 0; t < iterations; t++) {
|
||||||
|
// double result = ADI_2D(input_param, &field[0], &alpha[0]);
|
||||||
|
|
||||||
|
// if (t % 100 == 0) {
|
||||||
|
// cout << "Iteration " << t << ":" << endl;
|
||||||
|
// for (int i = 0; i<n; i++) {
|
||||||
|
// for (int j = 0; j<m; j++) {
|
||||||
|
// cout << field[n * i + j] << " ";
|
||||||
|
// }
|
||||||
|
// cout << endl;
|
||||||
|
// }
|
||||||
|
// cout << endl;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
ofstream myfile;
|
||||||
|
myfile.open("output.csv");
|
||||||
|
if (!myfile) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
int iterations = 1000;
|
int iterations = 1000;
|
||||||
for (int t = 0; t < iterations; t++) {
|
for (int t = 0; t < iterations; t++) {
|
||||||
double result = ADI_2D(input_param, &field[0], &alpha[0]);
|
double result = ADI_2D(input_param, &field[0], &alpha[0]);
|
||||||
|
|
||||||
if (t % 100 == 0) {
|
for (int i = 0; i < n; i++) {
|
||||||
cout << "Iteration " << t << ":" << endl;
|
for (int j = 0; j < m; j++) {
|
||||||
for (int i = 0; i<n; i++) {
|
myfile << field[i * m + j];
|
||||||
for (int j = 0; j<m; j++) {
|
if (j < m-1) {
|
||||||
cout << field[n * i + j] << " ";
|
myfile << ", ";
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
|
||||||
cout << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
myfile << "\n";
|
||||||
|
}
|
||||||
|
myfile << std::endl << std::endl;
|
||||||
|
}
|
||||||
|
myfile.close();
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user