Implement compute_sequence*() in terms of compute_reorder_sequence_graph().
While here, insert various white-space adjustments.
This commit is contained in:
parent
7645733fb9
commit
27bb7a4854
@ -27,11 +27,20 @@ struct SortByAbsFlux
|
|||||||
const double* flux_;
|
const double* flux_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Construct adjacency matrix of upwind graph wrt flux. Column
|
/* Construct adjacency matrix of upwind graph wrt flux. Column
|
||||||
indices are not sorted. */
|
indices are not sorted. */
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
static void
|
static void
|
||||||
make_upwind_graph(int nc, int *cellfaces, int *faceptr, int *face2cell,
|
make_upwind_graph(int nc ,
|
||||||
const double *flux, int *ia, int *ja, int *work)
|
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
|
/* Using topology (conn, cptr), and direction, construct adjacency
|
||||||
matrix of graph. */
|
matrix of graph. */
|
||||||
@ -90,82 +99,46 @@ make_upwind_graph(int nc, int *cellfaces, int *faceptr, int *face2cell,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
static void
|
static void
|
||||||
compute_reorder_sequence(int nc, int nf, int *cellfaces, int *faceptr, int *face2cell,
|
compute_reorder_sequence_graph(int nc,
|
||||||
const double *flux, int *sequence, int *components, int *ncomponents)
|
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;
|
make_upwind_graph(nc, cellfaces, facepos, face2cell,
|
||||||
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,
|
|
||||||
flux, ia, ja, work);
|
flux, ia, ja, work);
|
||||||
|
|
||||||
tarjan (nc, ia, ja, sequence, components, ncomponents, work);
|
tarjan (nc, ia, ja, sequence, components, ncomponents, work);
|
||||||
|
|
||||||
std::free(ja);
|
|
||||||
std::free(ia);
|
|
||||||
std::free(work);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
// ---------------------------------------------------------------------
|
||||||
compute_reorder_sequence_graph(int nc, int nf, int *cellfaces, int *faceptr, int *face2cell,
|
void
|
||||||
const double *flux, int *sequence, int *components, int *ncomponents,
|
compute_sequence(const struct UnstructuredGrid* grid ,
|
||||||
int *ia, int *ja)
|
const double* flux ,
|
||||||
|
int* sequence ,
|
||||||
|
int* components ,
|
||||||
|
int* ncomponents)
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
{
|
{
|
||||||
int *work;
|
const std::size_t nc = grid->number_of_cells;
|
||||||
int sz = nf;
|
const std::size_t nf = grid->number_of_faces;
|
||||||
if (nf < 3*nc)
|
const std::size_t sz = std::max(nf, 3 * nc);
|
||||||
{
|
|
||||||
sz = 3*nc;
|
|
||||||
}
|
|
||||||
|
|
||||||
work = (int*) std::malloc( sz * sizeof *work);
|
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... */
|
||||||
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)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
if (work && ia && ja) {
|
||||||
compute_reorder_sequence_graph(grid->number_of_cells,
|
compute_reorder_sequence_graph(grid->number_of_cells,
|
||||||
grid->number_of_faces,
|
|
||||||
grid->cell_faces,
|
grid->cell_faces,
|
||||||
grid->cell_facepos,
|
grid->cell_facepos,
|
||||||
grid->face_cells,
|
grid->face_cells,
|
||||||
@ -173,7 +146,45 @@ void compute_sequence_graph(const struct UnstructuredGrid *grid, const double *f
|
|||||||
sequence,
|
sequence,
|
||||||
components,
|
components,
|
||||||
ncomponents,
|
ncomponents,
|
||||||
ia, ja);
|
ia, ja, work);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::free(ja);
|
||||||
|
std::free(ia);
|
||||||
|
std::free(work);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
void
|
||||||
|
compute_sequence_graph(const struct UnstructuredGrid* grid ,
|
||||||
|
const double* flux ,
|
||||||
|
int* sequence ,
|
||||||
|
int* components ,
|
||||||
|
int* ncomponents,
|
||||||
|
int* ia ,
|
||||||
|
int* ja )
|
||||||
|
// ---------------------------------------------------------------------
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::free(work);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user