mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-13 17:38:23 +01:00
Move output from library to test application
This commit is contained in:
parent
9bce8be092
commit
54d1a396f4
@ -5,8 +5,6 @@
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
@ -145,20 +143,14 @@ void BTCSDiffusion::simulate1D(std::vector<double> &c, boundary_condition left,
|
||||
b_vector[i] = -c[i + !(left_is_constant)];
|
||||
}
|
||||
|
||||
std::cout << b_vector << "\n" << A_matrix << std::endl;
|
||||
|
||||
Eigen::SparseLU<Eigen::SparseMatrix<double>, Eigen::COLAMDOrdering<int>>
|
||||
solver;
|
||||
solver.analyzePattern(A_matrix);
|
||||
|
||||
solver.factorize(A_matrix);
|
||||
|
||||
std::cout << solver.lastErrorMessage() << std::endl;
|
||||
|
||||
x_vector = solver.solve(b_vector);
|
||||
|
||||
std::cout << std::setprecision(10) << x_vector << std::endl << std::endl;
|
||||
|
||||
for (int i = 0; i < c.size(); i++) {
|
||||
c[i] = x_vector[i + !left_is_constant];
|
||||
}
|
||||
|
||||
12
src/main.cpp
12
src/main.cpp
@ -1,5 +1,7 @@
|
||||
#include "BTCSDiffusion.hpp" // for BTCSDiffusion, BTCSDiffusion::BC_DIRICHLET
|
||||
#include <Eigen/src/Core/arch/SSE/PacketMath.h>
|
||||
#include <algorithm> // for copy, max
|
||||
#include <iomanip>
|
||||
#include <iostream> // for std
|
||||
#include <vector> // for vector
|
||||
using namespace std;
|
||||
@ -27,10 +29,20 @@ int main(int argc, char *argv[]) {
|
||||
// set timestep for simulation to 1 second
|
||||
diffu.setTimestep(1.);
|
||||
|
||||
cout << setprecision(12);
|
||||
|
||||
// loop 100 times
|
||||
// output is currently generated by the method itself
|
||||
for (int i = 0; i < 100; i++) {
|
||||
diffu.simulate(field, alpha);
|
||||
|
||||
cout << "Iteration: " << i << "\n\n";
|
||||
|
||||
for (int j = 0; j < field.size(); j++) {
|
||||
cout << field[j] << "\n";
|
||||
}
|
||||
|
||||
cout << "\n" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user