Add a couple of debugging aids to assist in FIBO development.

This commit is contained in:
Bård Skaflestad 2013-05-30 18:43:11 +02:00
parent d23a1c3066
commit bac1a3a364

View File

@ -24,7 +24,6 @@
#include <opm/core/grid.h>
#include <opm/core/utility/ErrorMacros.hpp>
// -------------------- class HelperOps --------------------
/// Contains vectors and sparse matrices that represent subsets or
@ -99,6 +98,7 @@ struct HelperOps
#if !defined(NDEBUG)
#include <cstdio>
#include <string>
namespace {
void
@ -133,6 +133,39 @@ namespace {
std::fclose(fp);
}
void
writeAsMATLAB(const std::vector< Eigen::SparseMatrix<double> >& vA,
std::FILE* fp ,
const char* const vname)
{
const int n = static_cast<int>(vA.size());
fprintf(fp, "%s = cell([1, %d]);\n\n", vname, n);
for (int i = 0; i < n; ++i) {
fprintf(fp, "%s{%d} = spconvert([\n", vname, i + 1);
printSparseMatrix(vA[i], fp);
const int rows = vA[i].rows();
const int cols = vA[i].cols();
fprintf(fp, "%d %d 0.0]);\n\n", rows, cols);
}
}
void
writeAsMATLAB(const std::vector< Eigen::SparseMatrix<double> >& vA,
const char* const fn ,
const char* const vname)
{
std::FILE* fp;
fp = std::fopen(fn, "w");
if (fp != 0) {
writeAsMATLAB(vA, fp, vname);
}
std::fclose(fp);
}
} // anonymous namespace
#endif // !defined(NDEBUG)