mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-18 21:43:27 -06:00
Implement compute_sequence*() in terms of compute_reorder_sequence_graph().
While here, insert various white-space adjustments.
This commit is contained in:
parent
2e02731ed8
commit
7d57530df5
@ -27,11 +27,20 @@ struct SortByAbsFlux
|
||||
const double* flux_;
|
||||
};
|
||||
|
||||
|
||||
/* Construct adjacency matrix of upwind graph wrt flux. Column
|
||||
indices are not sorted. */
|
||||
// ---------------------------------------------------------------------
|
||||
static void
|
||||
make_upwind_graph(int nc, int *cellfaces, int *faceptr, int *face2cell,
|
||||
const double *flux, int *ia, int *ja, int *work)
|
||||
make_upwind_graph(int nc ,
|
||||
const int *cellfaces,
|
||||
const int *faceptr ,
|
||||
const int *face2cell,
|
||||
const double *flux ,
|
||||
int *ia ,
|
||||
int *ja ,
|
||||
int *work )
|
||||
// ---------------------------------------------------------------------
|
||||
{
|
||||
/* Using topology (conn, cptr), and direction, construct adjacency
|
||||
matrix of graph. */
|
||||
@ -90,27 +99,55 @@ make_upwind_graph(int nc, int *cellfaces, int *faceptr, int *face2cell,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
static void
|
||||
compute_reorder_sequence(int nc, int nf, int *cellfaces, int *faceptr, int *face2cell,
|
||||
const double *flux, int *sequence, int *components, int *ncomponents)
|
||||
compute_reorder_sequence_graph(int nc,
|
||||
const int *cellfaces,
|
||||
const int *facepos,
|
||||
const int *face2cell,
|
||||
const double *flux,
|
||||
int *sequence,
|
||||
int *components,
|
||||
int *ncomponents,
|
||||
int *ia, int *ja, int* work)
|
||||
// ---------------------------------------------------------------------
|
||||
{
|
||||
int *ia, *ja;
|
||||
int *work;
|
||||
int sz = nf;
|
||||
if (nf < 3*nc)
|
||||
{
|
||||
sz = 3*nc;
|
||||
}
|
||||
|
||||
work = (int*) std::malloc( sz * sizeof *work);
|
||||
ia = (int*) std::malloc((nc+1) * sizeof *ia);
|
||||
ja = (int*) std::malloc( nf * sizeof *ja); /* A bit too much... */
|
||||
|
||||
|
||||
make_upwind_graph(nc, cellfaces, faceptr, face2cell,
|
||||
make_upwind_graph(nc, cellfaces, facepos, face2cell,
|
||||
flux, ia, ja, work);
|
||||
|
||||
tarjan (nc, ia, ja, sequence, components, ncomponents, work);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
void
|
||||
compute_sequence(const struct UnstructuredGrid* grid ,
|
||||
const double* flux ,
|
||||
int* sequence ,
|
||||
int* components ,
|
||||
int* ncomponents)
|
||||
// ---------------------------------------------------------------------
|
||||
{
|
||||
const std::size_t nc = grid->number_of_cells;
|
||||
const std::size_t nf = grid->number_of_faces;
|
||||
const std::size_t sz = std::max(nf, 3 * nc);
|
||||
|
||||
int* work = (int*) std::malloc( sz * sizeof *work);
|
||||
int* ia = (int*) std::malloc((nc + 1) * sizeof *ia );
|
||||
int* ja = (int*) std::malloc( nf * sizeof *ja ); /* A bit too much... */
|
||||
|
||||
if (work && ia && ja) {
|
||||
compute_reorder_sequence_graph(grid->number_of_cells,
|
||||
grid->cell_faces,
|
||||
grid->cell_facepos,
|
||||
grid->face_cells,
|
||||
flux,
|
||||
sequence,
|
||||
components,
|
||||
ncomponents,
|
||||
ia, ja, work);
|
||||
}
|
||||
|
||||
std::free(ja);
|
||||
std::free(ia);
|
||||
@ -118,65 +155,39 @@ compute_reorder_sequence(int nc, int nf, int *cellfaces, int *faceptr, int *face
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
compute_reorder_sequence_graph(int nc, int nf, int *cellfaces, int *faceptr, int *face2cell,
|
||||
const double *flux, int *sequence, int *components, int *ncomponents,
|
||||
int *ia, int *ja)
|
||||
// ---------------------------------------------------------------------
|
||||
void
|
||||
compute_sequence_graph(const struct UnstructuredGrid* grid ,
|
||||
const double* flux ,
|
||||
int* sequence ,
|
||||
int* components ,
|
||||
int* ncomponents,
|
||||
int* ia ,
|
||||
int* ja )
|
||||
// ---------------------------------------------------------------------
|
||||
{
|
||||
int *work;
|
||||
int sz = nf;
|
||||
if (nf < 3*nc)
|
||||
{
|
||||
sz = 3*nc;
|
||||
const std::size_t nc = grid->number_of_cells;
|
||||
const std::size_t nf = grid->number_of_faces;
|
||||
const std::size_t sz = std::max(nf, 3 * nc);
|
||||
|
||||
int* work = (int*) std::malloc(sz * sizeof *work);
|
||||
|
||||
if (work) {
|
||||
compute_reorder_sequence_graph(grid->number_of_cells,
|
||||
grid->cell_faces,
|
||||
grid->cell_facepos,
|
||||
grid->face_cells,
|
||||
flux,
|
||||
sequence,
|
||||
components,
|
||||
ncomponents,
|
||||
ia, ja, work);
|
||||
}
|
||||
|
||||
work = (int*) std::malloc( sz * sizeof *work);
|
||||
|
||||
|
||||
make_upwind_graph(nc, cellfaces, faceptr, face2cell,
|
||||
flux, ia, ja, work);
|
||||
|
||||
tarjan (nc, ia, ja, sequence, components, ncomponents, work);
|
||||
|
||||
std::free(work);
|
||||
}
|
||||
|
||||
|
||||
void compute_sequence(const struct UnstructuredGrid *grid, const double *flux,
|
||||
int *sequence,
|
||||
int *components, int *ncomponents)
|
||||
{
|
||||
|
||||
compute_reorder_sequence(grid->number_of_cells,
|
||||
grid->number_of_faces,
|
||||
grid->cell_faces,
|
||||
grid->cell_facepos,
|
||||
grid->face_cells,
|
||||
flux,
|
||||
sequence,
|
||||
components,
|
||||
ncomponents);
|
||||
}
|
||||
|
||||
void compute_sequence_graph(const struct UnstructuredGrid *grid, const double *flux,
|
||||
int *sequence,
|
||||
int *components, int *ncomponents,
|
||||
int *ia, int *ja)
|
||||
{
|
||||
|
||||
compute_reorder_sequence_graph(grid->number_of_cells,
|
||||
grid->number_of_faces,
|
||||
grid->cell_faces,
|
||||
grid->cell_facepos,
|
||||
grid->face_cells,
|
||||
flux,
|
||||
sequence,
|
||||
components,
|
||||
ncomponents,
|
||||
ia, ja);
|
||||
}
|
||||
|
||||
|
||||
/* Local Variables: */
|
||||
/* c-basic-offset:4 */
|
||||
/* End: */
|
||||
|
Loading…
Reference in New Issue
Block a user