mirror of
https://git.gfz-potsdam.de/naaice/tug.git
synced 2025-12-15 18:38:23 +01:00
write input of thomas algortithm to file
This commit is contained in:
parent
55509c1934
commit
6e388f3d99
@ -11,6 +11,11 @@
|
|||||||
#include <tug/Boundary.hpp>
|
#include <tug/Boundary.hpp>
|
||||||
#include <omp.h>
|
#include <omp.h>
|
||||||
|
|
||||||
|
#ifdef WRITE_THOMAS_CSV
|
||||||
|
#include<fstream>
|
||||||
|
#include<string>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NUM_THREADS_BTCS 10
|
#define NUM_THREADS_BTCS 10
|
||||||
|
|
||||||
using namespace Eigen;
|
using namespace Eigen;
|
||||||
@ -295,6 +300,28 @@ static VectorXd ThomasAlgorithm(SparseMatrix<double> &A, VectorXd &b) {
|
|||||||
a_diag[n - 1] = A.coeff(n - 1, n - 2);
|
a_diag[n - 1] = A.coeff(n - 1, n - 2);
|
||||||
b_diag[n - 1] = A.coeff(n - 1, n - 1);
|
b_diag[n - 1] = A.coeff(n - 1, n - 1);
|
||||||
|
|
||||||
|
// HACK: write CSV to file
|
||||||
|
#ifdef WRITE_THOMAS_CSV
|
||||||
|
#include<fstream>
|
||||||
|
#include<string>
|
||||||
|
static std::uint32_t file_index = 0;
|
||||||
|
std::string file_name = "Thomas_" + std::to_string(file_index++) + ".csv";
|
||||||
|
|
||||||
|
std::ofstream out_file;
|
||||||
|
|
||||||
|
out_file.open(file_name, std::ofstream::trunc | std::ofstream::out);
|
||||||
|
|
||||||
|
// print header
|
||||||
|
out_file << "Aa, Ab, Ac, b\n";
|
||||||
|
|
||||||
|
// iterate through all elements
|
||||||
|
for (std::size_t i = 0; i < n; i++) {
|
||||||
|
out_file << a_diag[i] << ", " << b_diag[i] << ", " << c_diag[i] << ", " << b[i] << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
out_file.close();
|
||||||
|
#endif
|
||||||
|
|
||||||
// start solving - c_diag and x_vec are overwritten
|
// start solving - c_diag and x_vec are overwritten
|
||||||
n--;
|
n--;
|
||||||
c_diag[0] /= b_diag[0];
|
c_diag[0] /= b_diag[0];
|
||||||
|
|||||||
@ -1,5 +1,11 @@
|
|||||||
add_library(tug Boundary.cpp Grid.cpp Simulation.cpp FTCS.cpp BTCSv2.cpp)
|
add_library(tug Boundary.cpp Grid.cpp Simulation.cpp FTCS.cpp BTCSv2.cpp)
|
||||||
|
|
||||||
|
option(TUG_WRITE_CSV "Write CSV during Thomas algorithm with consecutive numbers for each call" OFF)
|
||||||
|
|
||||||
|
IF(TUG_WRITE_CSV)
|
||||||
|
target_compile_definitions(tug PRIVATE WRITE_THOMAS_CSV)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(tug Eigen3::Eigen)
|
target_link_libraries(tug Eigen3::Eigen)
|
||||||
|
|
||||||
if(TUG_USE_OPENMP AND OpenMP_CXX_FOUND)
|
if(TUG_USE_OPENMP AND OpenMP_CXX_FOUND)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user