mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Made reordersequence a C++ source file, in order to use std::sort().
This is for the experimental change of the graph topology, putting the connections in the graph sorted by flux magnitude. Currently the changes are in the file, but commented out until further experiments have been done.
This commit is contained in:
parent
5b9e67518d
commit
5a2d26360b
@ -12,6 +12,20 @@
|
||||
#include <opm/core/transport/reorder/tarjan.h>
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
|
||||
struct SortByAbsFlux
|
||||
{
|
||||
SortByAbsFlux(const double* flux)
|
||||
: flux_(flux)
|
||||
{}
|
||||
bool operator() (int f1, int f2)
|
||||
{
|
||||
return std::fabs(flux_[f1]) < std::fabs(flux_[f2]);
|
||||
}
|
||||
const double* flux_;
|
||||
};
|
||||
|
||||
/* Construct adjacency matrix of upwind graph wrt flux. Column
|
||||
indices are not sorted. */
|
||||
@ -64,11 +78,15 @@ make_upwind_graph(int nc, int *cellfaces, int *faceptr, int *face2cell,
|
||||
|
||||
if ( theflux < 0)
|
||||
{
|
||||
// ja[p++] = f;
|
||||
ja[p++] = work[f];
|
||||
}
|
||||
}
|
||||
|
||||
ia[i+1] = p;
|
||||
// std::sort(ja + ia[i], ja + ia[i+1], SortByAbsFlux(flux));
|
||||
// for (j = ia[i]; j < ia[i+1]; ++j) {
|
||||
// ja[j] = work[ja[j]];
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@ -84,9 +102,9 @@ compute_reorder_sequence(int nc, int nf, int *cellfaces, int *faceptr, int *face
|
||||
sz = 3*nc;
|
||||
}
|
||||
|
||||
work = malloc( sz * sizeof *work);
|
||||
ia = malloc((nc+1) * sizeof *ia);
|
||||
ja = malloc( nf * sizeof *ja); /* A bit too much... */
|
||||
work = (int*) malloc( sz * sizeof *work);
|
||||
ia = (int*) malloc((nc+1) * sizeof *ia);
|
||||
ja = (int*) malloc( nf * sizeof *ja); /* A bit too much... */
|
||||
|
||||
|
||||
make_upwind_graph(nc, cellfaces, faceptr, face2cell,
|
Loading…
Reference in New Issue
Block a user