Remove disabled code.
This commit is contained in:
parent
1982240882
commit
900041729b
198
hybsys.c
198
hybsys.c
@ -676,201 +676,3 @@ hybsys_compute_press_flux_well(int nc, const int *pgconn, int nf,
|
|||||||
/* Assign well BHP from linsolve output */
|
/* Assign well BHP from linsolve output */
|
||||||
memcpy(wpress, pi + nf, nw * sizeof *wpress);
|
memcpy(wpress, pi + nf, nw * sizeof *wpress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/*
|
|
||||||
* Routines to assemble global matrix
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
static MAT_SIZE_T *
|
|
||||||
hybsys_build_ia(int nc, int nf,
|
|
||||||
const int *pconn, const int *conn)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
MAT_SIZE_T *ia = malloc((nf+1) * sizeof *ia);
|
|
||||||
|
|
||||||
int i;
|
|
||||||
for(i=0; i<nf+1; ++i)
|
|
||||||
{
|
|
||||||
ia[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Compute rowsizes
|
|
||||||
*/
|
|
||||||
int c, pos = 0;
|
|
||||||
for(c=0; c<nc; ++c)
|
|
||||||
{
|
|
||||||
int n = pconn[c + 1] - pconn[c];
|
|
||||||
for (i=pos; i<pos+n; ++i)
|
|
||||||
{
|
|
||||||
mxAssert(conn[i]<nf, "conn out of bounds");
|
|
||||||
ia[1+conn[i]] += n - 1;
|
|
||||||
}
|
|
||||||
pos += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* cumulative sum...
|
|
||||||
*/
|
|
||||||
for(i=1; i<nf+1; ++i)
|
|
||||||
{
|
|
||||||
ia[i] = ia[i-1] + ia[i]+1;
|
|
||||||
}
|
|
||||||
return ia;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
static MAT_SIZE_T*
|
|
||||||
hybsys_build_ja(int nc, int nf,
|
|
||||||
const int *pconn, const int *conn,
|
|
||||||
MAT_SIZE_T *ia, int *work)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
MAT_SIZE_T *ja = malloc(ia[nf] * sizeof *ja);
|
|
||||||
int i,j;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* For each row, diagonal entries are positioned first.
|
|
||||||
*/
|
|
||||||
for(i=0; i<nf; ++i)
|
|
||||||
{
|
|
||||||
work[i] = 1;
|
|
||||||
ja[ia[i]] = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int c, pos = 0;
|
|
||||||
for(c=0; c<nc; ++c)
|
|
||||||
{
|
|
||||||
int n = pconn[c + 1] - pconn[c];
|
|
||||||
for (i=pos; i<pos+n; ++i)
|
|
||||||
{
|
|
||||||
int fi = conn[i];
|
|
||||||
/* mxAssert(fi<nf, "fi out of bounds"); */
|
|
||||||
|
|
||||||
for (j=pos; j<i; ++j)
|
|
||||||
{
|
|
||||||
int fj = conn[j];
|
|
||||||
/* mxAssert(fj<nf, "fj out of bounds"); */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* No conditionals since off-diagonals entries are
|
|
||||||
* visited only once.
|
|
||||||
*/
|
|
||||||
ja[ia[fi] + work[fi]++] = fj;
|
|
||||||
ja[ia[fj] + work[fj]++] = fi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pos += n;
|
|
||||||
}
|
|
||||||
return ja;
|
|
||||||
}
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
static void
|
|
||||||
hybsys_build_sa_and_b(int nc, int nf,
|
|
||||||
const int *pconn, const int *conn, MAT_SIZE_T *ia,
|
|
||||||
const double *S, const double *R,
|
|
||||||
int *work, double **sa, double **b)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
*sa = malloc(ia[nf] * sizeof **sa);
|
|
||||||
*b = malloc(nf * sizeof **b);
|
|
||||||
int i,j;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Clear diagonal and work array
|
|
||||||
*/
|
|
||||||
for(i=0; i<nf; ++i)
|
|
||||||
{
|
|
||||||
work[i] = 1;
|
|
||||||
(*sa)[ia[i]] = 0;
|
|
||||||
(*b) [i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const double *s = S;
|
|
||||||
const double *r = R;
|
|
||||||
|
|
||||||
int c, pos = 0;
|
|
||||||
for(c=0; c<nc; ++c)
|
|
||||||
{
|
|
||||||
int n = pconn[c + 1] - pconn[c];
|
|
||||||
for (i=pos; i<pos+n; ++i)
|
|
||||||
{
|
|
||||||
int fi = conn[i];
|
|
||||||
int ii = i-pos;
|
|
||||||
|
|
||||||
for (j=pos; j<i; ++j)
|
|
||||||
{
|
|
||||||
int fj = conn[j];
|
|
||||||
int jj = j-pos;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* We can use assignment since off-diagonal entries are
|
|
||||||
* visited only once.
|
|
||||||
*/
|
|
||||||
(*sa)[ia[fi] + work[fi]++] = s[ii + jj*n];
|
|
||||||
(*sa)[ia[fj] + work[fj]++] = s[jj + ii*n];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Diagonal entries are visited more than once.
|
|
||||||
*/
|
|
||||||
(*sa)[ia[fi]] += s[ii + ii*n];
|
|
||||||
(*b) [fi] += r[ii];
|
|
||||||
}
|
|
||||||
|
|
||||||
s += n*n;
|
|
||||||
r += n;
|
|
||||||
pos += n;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
static void
|
|
||||||
hybsys_build_matrix_structure(int nc, int nf,
|
|
||||||
const int *pconn, const int *conn,
|
|
||||||
MAT_SIZE_T **ia, MAT_SIZE_T **ja)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
int *work = malloc(nf * sizeof *work);
|
|
||||||
|
|
||||||
*ia = hybsys_build_ia(nc, nf, pconn, conn);
|
|
||||||
*ja = hybsys_build_ja(nc, nf, pconn, conn, *ia, work);
|
|
||||||
|
|
||||||
free(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
static void
|
|
||||||
hybsys_assemble_global_system(int nc, int nf,
|
|
||||||
const int *pconn, const int *conn,
|
|
||||||
const double *S, const double *R,
|
|
||||||
double **sa, double **b, MAT_SIZE_T *ia)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
int *work = malloc(nf * sizeof *work);
|
|
||||||
|
|
||||||
hybsys_build_sa_and_b(nc, nf, pconn, conn, ia, S, R, work, sa, b);
|
|
||||||
|
|
||||||
free(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
void
|
|
||||||
hybsys_assemble(int nc, int nf,
|
|
||||||
const int *pconn, const int *conn,
|
|
||||||
const double *S, const double *R,
|
|
||||||
struct Sparse*A, double **b)
|
|
||||||
/* ---------------------------------------------------------------------- */
|
|
||||||
{
|
|
||||||
A->m = A->n = nf;
|
|
||||||
hybsys_build_matrix_structure(nc, nf, pconn, conn, &A->ia, &A->ja);
|
|
||||||
hybsys_assemble_global_system(nc, nf, pconn, conn, S, R, &A->sa, b, A->ia);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
Loading…
Reference in New Issue
Block a user