Add global assembly of (symmetric) well contributions for cells.

This commit is contained in:
Bård Skaflestad 2010-09-24 17:26:48 +00:00
parent 20b66033a0
commit a245c45c23
2 changed files with 59 additions and 0 deletions

View File

@ -350,3 +350,52 @@ hybsys_global_assemble_cell(int nconn, int *conn,
b[ig] += r[il];
}
}
/* ---------------------------------------------------------------------- */
void
hybsys_global_assemble_well_sym(int ngconn_tot,
int ngconn, const int *gconn,
int nwconn, const int *wconn,
const double *r2w,
const double *w2w,
const double *r,
struct CSRMatrix *A,
double *b)
/* ---------------------------------------------------------------------- */
{
int il, wl1, wl2;
size_t ig, wg1, wg2, jg, jw;
/* Global matrix contributions for this cell's wells */
for (wl1 = 0; wl1 < nwconn; wl1++) {
wg1 = ngconn_tot + wconn[2*wl1 + 0];
for (il = 0; il < ngconn; il++) {
ig = gconn[il];
jw = csrmatrix_elm_index(ig, wg1, A);
jg = csrmatrix_elm_index(wg1, ig, A);
A->sa[jw] += r2w[il + wl1*ngconn]; /* Row major per cell */
A->sa[jg] += r2w[il + wl1*ngconn]; /* Symmetry */
}
for (wl2 = 0; wl2 < nwconn; wl2++) {
wg2 = ngconn_tot + wconn[2*wl2 + 0];
jw = csrmatrix_elm_index(wg1, wg2, A);
A->sa[jw] += w2w[wl1 + wl2*nwconn]; /* Row major per well */
}
}
/* Global right-hand side contributions */
for (il = 0; il < ngconn; il++) {
b[gconn[il]] += r[il];
}
for (wl1 = 0; wl1 < nwconn; wl1++) {
b[ngconn_tot + wconn[2*wl1 + 0]] += r[ngconn + wl1];
}
}

View File

@ -16,4 +16,14 @@ hybsys_global_assemble_cell(int nconn, int *l2g,
struct CSRMatrix *A,
double *b);
void
hybsys_global_assemble_well_sym(int ngconn_tot,
int ngconn, const int *gconn,
int nwconn, const int *wconn,
const double *r2w,
const double *w2w,
const double *r,
struct CSRMatrix *A,
double *b);
#endif /* HYBSYS_GLOBAL_H_INCLUDED */