mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Add a couple of debugging aids to assist in FIBO development.
This commit is contained in:
parent
d23a1c3066
commit
bac1a3a364
@ -24,7 +24,6 @@
|
|||||||
#include <opm/core/grid.h>
|
#include <opm/core/grid.h>
|
||||||
#include <opm/core/utility/ErrorMacros.hpp>
|
#include <opm/core/utility/ErrorMacros.hpp>
|
||||||
|
|
||||||
|
|
||||||
// -------------------- class HelperOps --------------------
|
// -------------------- class HelperOps --------------------
|
||||||
|
|
||||||
/// Contains vectors and sparse matrices that represent subsets or
|
/// Contains vectors and sparse matrices that represent subsets or
|
||||||
@ -99,6 +98,7 @@ struct HelperOps
|
|||||||
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
void
|
void
|
||||||
@ -133,6 +133,39 @@ namespace {
|
|||||||
|
|
||||||
std::fclose(fp);
|
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
|
} // anonymous namespace
|
||||||
#endif // !defined(NDEBUG)
|
#endif // !defined(NDEBUG)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user