From 27226eaacbd6af180c576c1f1132e22c200c8c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 15 Mar 2012 14:26:40 +0100 Subject: [PATCH 1/2] Encapsulate ifs_tpfa pressure solution in ad-hoc structure. This is to limit the number of explicit interface changes when we produce solution variables for wells too. Update callers accordingly. --- opm/core/pressure/IncompTpfa.cpp | 8 +++++--- opm/core/pressure/tpfa/ifs_tpfa.c | 12 ++++++++++-- opm/core/pressure/tpfa/ifs_tpfa.h | 7 +++++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/opm/core/pressure/IncompTpfa.cpp b/opm/core/pressure/IncompTpfa.cpp index 5d835eea7..68e0e8e3b 100644 --- a/opm/core/pressure/IncompTpfa.cpp +++ b/opm/core/pressure/IncompTpfa.cpp @@ -118,9 +118,11 @@ namespace Opm pressure.resize(grid_.number_of_cells); faceflux.resize(grid_.number_of_faces); - ifs_tpfa_press_flux(gg, &F, &trans_[0], h_, - &pressure[0], - &faceflux[0]); + ifs_tpfa_solution soln; + soln.cell_press = &pressure[0]; + soln.face_flux = &faceflux[0]; + + ifs_tpfa_press_flux(gg, &F, &trans_[0], h_, &soln); } diff --git a/opm/core/pressure/tpfa/ifs_tpfa.c b/opm/core/pressure/tpfa/ifs_tpfa.c index 30a78ecd9..1cf2564e7 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.c +++ b/opm/core/pressure/tpfa/ifs_tpfa.c @@ -355,14 +355,22 @@ ifs_tpfa_press_flux(struct UnstructuredGrid *G, const struct ifs_tpfa_forces *F, const double *trans, struct ifs_tpfa_data *h, - double *cpress, - double *fflux) + struct ifs_tpfa_solution *soln) /* ---------------------------------------------------------------------- */ { int c1, c2, f; size_t i, j; double dh, s; + double *cpress, *fflux; + + assert (soln != NULL); + assert (soln->cell_press != NULL); + assert (soln->face_flux != NULL); + + cpress = soln->cell_press; + fflux = soln->face_flux ; + /* Assign cell pressure directly from solution vector */ memcpy(cpress, h->x, G->number_of_cells * sizeof *cpress); diff --git a/opm/core/pressure/tpfa/ifs_tpfa.h b/opm/core/pressure/tpfa/ifs_tpfa.h index 53383044f..045688ece 100644 --- a/opm/core/pressure/tpfa/ifs_tpfa.h +++ b/opm/core/pressure/tpfa/ifs_tpfa.h @@ -39,6 +39,10 @@ struct ifs_tpfa_data { struct ifs_tpfa_impl *pimpl; }; +struct ifs_tpfa_solution { + double *cell_press; + double *face_flux ; +}; struct ifs_tpfa_forces { const double *src; @@ -62,8 +66,7 @@ ifs_tpfa_press_flux(struct UnstructuredGrid *G, const struct ifs_tpfa_forces *F, const double *trans, struct ifs_tpfa_data *h, - double *cpress, - double *fflux); + struct ifs_tpfa_solution *soln); void ifs_tpfa_destroy(struct ifs_tpfa_data *h); From 4378bf71922ce93a387d73eb767847b72b05847f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Thu, 15 Mar 2012 15:13:03 +0100 Subject: [PATCH 2/2] Initialise all tpfa_solution members to zero (i.e., NULL). This is in anticipation of introducing additional structure members to represent solution variables associated with wells whilst having the compiler generate the appropriate null pointers to aid debugging. Unfortunately, GCC warns about the standard "structure = { 0 }" idiom under -Wmissing-field-initializers which is enabled by default under "-Wextra". --- opm/core/pressure/IncompTpfa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/pressure/IncompTpfa.cpp b/opm/core/pressure/IncompTpfa.cpp index 68e0e8e3b..a66ab4cbb 100644 --- a/opm/core/pressure/IncompTpfa.cpp +++ b/opm/core/pressure/IncompTpfa.cpp @@ -118,7 +118,7 @@ namespace Opm pressure.resize(grid_.number_of_cells); faceflux.resize(grid_.number_of_faces); - ifs_tpfa_solution soln; + ifs_tpfa_solution soln = { 0 }; soln.cell_press = &pressure[0]; soln.face_flux = &faceflux[0];