diff --git a/opm/core/transport/reorder/reordersequence.h b/opm/core/transport/reorder/reordersequence.h index 696f51fe2..47bb786c4 100644 --- a/opm/core/transport/reorder/reordersequence.h +++ b/opm/core/transport/reorder/reordersequence.h @@ -2,12 +2,66 @@ #ifndef REORDERSEQUENCE_H_INCLUDED #define REORDERSEQUENCE_H_INCLUDED +/** + * \file + * + * Facilities for computing a causal permutation of the cells in an + * UnstructuredGrid such that fluid transport may be subsequently + * solved by going from sources and up-stream cells to sinks and + * down-stream cells. + */ + #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ struct UnstructuredGrid; + +/** + * Compute causal permutation sequence of grid cells with respect to + * specific Darcy flux field. + * + * \param[in] grid Grid structure for which to compute causal cell + * permutation. + * + * \param[in] flux Darcy flux field. One scalar value for each + * interface/connection in the grid. We assume that + * flux[f] is positive if the flow is + * from cell grid->face_cells[2*f + 0] to + * cell grid->face_cells[2*f + 1]. + * + * \param[out] sequence + * Causal grid cell permutation. Ordered according to + * topological sorting of the strongly connected + * components of the Darcy flux upwind graph. Array + * of size grid->number_of_cells. + * + * \param[out] components + * Indirection pointers that describe the strongly + * connected components (i.e., loops) of the Darcy + * flux upwind graph. Specifically, the \f$i\f$'th + * strongly connected components constitutes cells + * sequence[components[i] ... components[i + 1] + * - 1]. + * + * In the ideal case of a perfectly reordered upwind + * graph, this array will hold + * grid->number_of_cells + 1 elements, + * and the relation components[i + 1] - + * components[i] == 1 holds for all \f$i\f$. + * Thus, the components parameter must + * point to an array of grid->number_of_cells + + * 1 elements. + * + * \param[out] ncomponents + * Number of strongly connected components. Pointer + * to a single integer. The components + * output are valid for all i = 0 + * ... *ncomponents. Furhtermore, the number of + * components must be in the interval [1 + * .. grid->number_of_cells]. + */ void compute_sequence(const struct UnstructuredGrid *grid , const double *flux , @@ -15,6 +69,64 @@ compute_sequence(const struct UnstructuredGrid *grid , int *components , int *ncomponents); + +/** + * Compute causal permutation sequence of grid cells with respect to + * specific Darcy flux field. Also return the permuted upwind graph. + * + * \param[in] grid Grid structure for which to compute causal cell + * permutation. + * + * \param[in] flux Darcy flux field. One scalar value for each + * interface/connection in the grid. We assume that + * flux[f] is positive if the flow is + * from cell grid->face_cells[2*f + 0] to + * cell grid->face_cells[2*f + 1]. + * + * \param[out] sequence + * Causal grid cell permutation. Ordered according to + * topological sorting of the strongly connected + * components of the Darcy flux upwind graph. Array + * of size grid->number_of_cells. + * + * \param[out] components + * Indirection pointers that describe the strongly + * connected components (i.e., loops) of the Darcy + * flux upwind graph. Specifically, the \f$i\f$'th + * strongly connected components constitutes cells + * sequence[components[i] ... components[i + 1] + * - 1]. + * + * In the ideal case of a perfectly reordered upwind + * graph, this array will hold + * grid->number_of_cells + 1 elements, + * and the relation components[i + 1] - + * components[i] == 1 holds for all \f$i\f$. + * Thus, the components parameter must + * point to an array of grid->number_of_cells + + * 1 elements. + * + * \param[out] ncomponents + * Number of strongly connected components. Pointer + * to a single integer. The components + * output are valid for all i = 0 + * ... *ncomponents. Furhtermore, the number of + * components must be in the interval [1 + * .. grid->number_of_cells]. + * + * \param[out] ia Indirection pointers into ja that + * define the "upwind" cells that influence a + * particular grid cell. + * + * \param[out] ja Compressed-sparse representation of the upwind + * graph. Specifically, the upwind cells that + * influence cell \f$i\f$ are ja[ia[i] + * .. ia[i+1]-1]. Array of size at least equal + * to the number of internal faces of + * grid. The number + * grid->number_of_faces is an upper + * bound of the array size. + */ void compute_sequence_graph(const struct UnstructuredGrid *grid , const double *flux , @@ -24,7 +136,6 @@ compute_sequence_graph(const struct UnstructuredGrid *grid , int *ia , int *ja ); - #ifdef __cplusplus } #endif /* __cplusplus */