mirror of
https://github.com/OPM/opm-simulators.git
synced 2024-12-19 05:53:28 -06:00
Call malloc() once, at pimpl construction time, rather than in each *_increment().
It's slightly wasteful, however. Maybe we can just reuse h->x for the mult_csr_matrix() output?
This commit is contained in:
parent
00b1ce27f0
commit
97ed64f438
@ -33,6 +33,7 @@ mult_csr_matrix(const struct CSRMatrix *A,
|
|||||||
|
|
||||||
struct ifs_tpfa_impl {
|
struct ifs_tpfa_impl {
|
||||||
double *fgrav; /* Accumulated grav contrib/face */
|
double *fgrav; /* Accumulated grav contrib/face */
|
||||||
|
double *work;
|
||||||
|
|
||||||
/* Linear storage */
|
/* Linear storage */
|
||||||
double *ddata;
|
double *ddata;
|
||||||
@ -70,6 +71,7 @@ impl_allocate(struct UnstructuredGrid *G,
|
|||||||
|
|
||||||
ddata_sz = 2 * nnu; /* b, x */
|
ddata_sz = 2 * nnu; /* b, x */
|
||||||
ddata_sz += 1 * G->number_of_faces; /* fgrav */
|
ddata_sz += 1 * G->number_of_faces; /* fgrav */
|
||||||
|
ddata_sz += 1 * nnu; /* work */
|
||||||
|
|
||||||
new = malloc(1 * sizeof *new);
|
new = malloc(1 * sizeof *new);
|
||||||
|
|
||||||
@ -677,6 +679,7 @@ ifs_tpfa_construct(struct UnstructuredGrid *G,
|
|||||||
new->x = new->b + new->A->m;
|
new->x = new->b + new->A->m;
|
||||||
|
|
||||||
new->pimpl->fgrav = new->x + new->A->m;
|
new->pimpl->fgrav = new->x + new->A->m;
|
||||||
|
new->pimpl->work = new->pimpl->fgrav + G->number_of_faces;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
@ -766,8 +769,7 @@ ifs_tpfa_assemble_comprock_increment(struct UnstructuredGrid *G ,
|
|||||||
|
|
||||||
assemble_incompressible(G, F, trans, gpress, h, &system_singular, &ok);
|
assemble_incompressible(G, F, trans, gpress, h, &system_singular, &ok);
|
||||||
|
|
||||||
v = malloc(h->A->m * sizeof *v);
|
v = h->pimpl->work;
|
||||||
|
|
||||||
mult_csr_matrix(h->A, prev_pressure, v);
|
mult_csr_matrix(h->A, prev_pressure, v);
|
||||||
|
|
||||||
/* We want to solve a Newton step for the residual
|
/* We want to solve a Newton step for the residual
|
||||||
@ -783,8 +785,6 @@ ifs_tpfa_assemble_comprock_increment(struct UnstructuredGrid *G ,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
free(v);
|
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user