mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
more efficient polymer code (replaced std::vector by double*).
This commit is contained in:
parent
6eb68c9652
commit
ab961dda94
@ -219,22 +219,22 @@ namespace Opm
|
|||||||
const double cmax,
|
const double cmax,
|
||||||
const double* visc,
|
const double* visc,
|
||||||
const double* relperm,
|
const double* relperm,
|
||||||
std::vector<double>& mob) const
|
double* mob) const
|
||||||
{
|
{
|
||||||
double dummy1;
|
double dummy;
|
||||||
double dummy2[2];
|
double dummy_pointer[4];
|
||||||
std::vector<double> dummy3;
|
|
||||||
effectiveMobilitiesBoth(c, cmax, visc, relperm,
|
effectiveMobilitiesBoth(c, cmax, visc, relperm,
|
||||||
dummy2, mob, dummy3, dummy1, false);
|
dummy_pointer, mob, dummy_pointer, dummy, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PolymerProperties::effectiveMobilitiesWithDer(const double c,
|
void PolymerProperties::effectiveMobilitiesWithDer(const double c,
|
||||||
const double cmax,
|
const double cmax,
|
||||||
const double* visc,
|
const double* visc,
|
||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelpermds,
|
const double* drelpermds,
|
||||||
std::vector<double>& mob,
|
double* mob,
|
||||||
std::vector<double>& dmobds,
|
double* dmobds,
|
||||||
double& dmobwatdc) const
|
double& dmobwatdc) const
|
||||||
{
|
{
|
||||||
effectiveMobilitiesBoth(c, cmax, visc,
|
effectiveMobilitiesBoth(c, cmax, visc,
|
||||||
@ -247,8 +247,8 @@ namespace Opm
|
|||||||
const double* visc,
|
const double* visc,
|
||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelperm_ds,
|
const double* drelperm_ds,
|
||||||
std::vector<double>& mob,
|
double* mob,
|
||||||
std::vector<double>& dmob_ds,
|
double* dmob_ds,
|
||||||
double& dmobwat_dc,
|
double& dmobwat_dc,
|
||||||
bool if_with_der) const
|
bool if_with_der) const
|
||||||
{
|
{
|
||||||
@ -260,10 +260,12 @@ namespace Opm
|
|||||||
double eff_relperm_wat;
|
double eff_relperm_wat;
|
||||||
double deff_relperm_wat_ds;
|
double deff_relperm_wat_ds;
|
||||||
double deff_relperm_wat_dc;
|
double deff_relperm_wat_dc;
|
||||||
|
|
||||||
effectiveRelpermBoth(c, cmax, relperm,
|
effectiveRelpermBoth(c, cmax, relperm,
|
||||||
drelperm_ds, eff_relperm_wat,
|
drelperm_ds, eff_relperm_wat,
|
||||||
deff_relperm_wat_ds, deff_relperm_wat_dc,
|
deff_relperm_wat_ds, deff_relperm_wat_dc,
|
||||||
if_with_der);
|
if_with_der);
|
||||||
|
|
||||||
mob[0] = eff_relperm_wat/visc_eff[0];
|
mob[0] = eff_relperm_wat/visc_eff[0];
|
||||||
mob[1] = relperm[1]/visc_eff[1];
|
mob[1] = relperm[1]/visc_eff[1];
|
||||||
|
|
||||||
@ -274,8 +276,6 @@ namespace Opm
|
|||||||
dmob_ds[0*2 + 1] = drelperm_ds[0*2 + 1]/visc_eff[1];
|
dmob_ds[0*2 + 1] = drelperm_ds[0*2 + 1]/visc_eff[1];
|
||||||
dmob_ds[1*2 + 0] = drelperm_ds[1*2 + 0]/visc_eff[0];
|
dmob_ds[1*2 + 0] = drelperm_ds[1*2 + 0]/visc_eff[0];
|
||||||
dmob_ds[1*2 + 1] = drelperm_ds[1*2 + 1]/visc_eff[1];
|
dmob_ds[1*2 + 1] = drelperm_ds[1*2 + 1]/visc_eff[1];
|
||||||
} else {
|
|
||||||
dmob_ds.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,10 +285,10 @@ namespace Opm
|
|||||||
const double* relperm,
|
const double* relperm,
|
||||||
double& totmob) const
|
double& totmob) const
|
||||||
{
|
{
|
||||||
std::vector<double> dummy(2);
|
double dummy1[4];
|
||||||
double dummy2[4];
|
double dummy2[2];
|
||||||
effectiveTotalMobilityBoth(c, cmax, visc, relperm, dummy2,
|
effectiveTotalMobilityBoth(c, cmax, visc, relperm, dummy1,
|
||||||
totmob, dummy, false);
|
totmob, dummy2, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PolymerProperties::effectiveTotalMobilityWithDer(const double c,
|
void PolymerProperties::effectiveTotalMobilityWithDer(const double c,
|
||||||
@ -297,7 +297,7 @@ namespace Opm
|
|||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelperm_ds,
|
const double* drelperm_ds,
|
||||||
double& totmob,
|
double& totmob,
|
||||||
std::vector<double>& dtotmob_dsdc) const
|
double* dtotmob_dsdc) const
|
||||||
{
|
{
|
||||||
effectiveTotalMobilityBoth(c, cmax, visc, relperm, drelperm_ds,
|
effectiveTotalMobilityBoth(c, cmax, visc, relperm, drelperm_ds,
|
||||||
totmob, dtotmob_dsdc, true);
|
totmob, dtotmob_dsdc, true);
|
||||||
@ -309,11 +309,11 @@ namespace Opm
|
|||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelperm_ds,
|
const double* drelperm_ds,
|
||||||
double& totmob,
|
double& totmob,
|
||||||
std::vector<double>& dtotmob_dsdc,
|
double* dtotmob_dsdc,
|
||||||
bool if_with_der) const
|
bool if_with_der) const
|
||||||
{
|
{
|
||||||
std::vector<double> mob(2);
|
double mob[2];
|
||||||
std::vector<double> dmob_ds(2);
|
double dmob_ds[2];
|
||||||
double dmobwat_dc;
|
double dmobwat_dc;
|
||||||
effectiveMobilitiesBoth(c, cmax, visc, relperm, drelperm_ds,
|
effectiveMobilitiesBoth(c, cmax, visc, relperm, drelperm_ds,
|
||||||
mob, dmob_ds, dmobwat_dc, if_with_der);
|
mob, dmob_ds, dmobwat_dc, if_with_der);
|
||||||
@ -321,8 +321,6 @@ namespace Opm
|
|||||||
if (if_with_der) {
|
if (if_with_der) {
|
||||||
dtotmob_dsdc[0] = dmob_ds[0] + dmob_ds[2]; //derivative with respect to s
|
dtotmob_dsdc[0] = dmob_ds[0] + dmob_ds[2]; //derivative with respect to s
|
||||||
dtotmob_dsdc[1] = dmobwat_dc; //derivative with respect to c
|
dtotmob_dsdc[1] = dmobwat_dc; //derivative with respect to c
|
||||||
} else {
|
|
||||||
dtotmob_dsdc.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,15 +178,15 @@ namespace Opm
|
|||||||
const double cmax,
|
const double cmax,
|
||||||
const double* visc,
|
const double* visc,
|
||||||
const double* relperm,
|
const double* relperm,
|
||||||
std::vector<double>& mob) const;
|
double* mob) const;
|
||||||
|
|
||||||
void effectiveMobilitiesWithDer(const double c,
|
void effectiveMobilitiesWithDer(const double c,
|
||||||
const double cmax,
|
const double cmax,
|
||||||
const double* visc,
|
const double* visc,
|
||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelpermds,
|
const double* drelpermds,
|
||||||
std::vector<double>& mob,
|
double* mob,
|
||||||
std::vector<double>& dmob_ds,
|
double* dmob_ds,
|
||||||
double& dmobwatdc) const;
|
double& dmobwatdc) const;
|
||||||
|
|
||||||
void effectiveMobilitiesBoth(const double c,
|
void effectiveMobilitiesBoth(const double c,
|
||||||
@ -194,8 +194,8 @@ namespace Opm
|
|||||||
const double* visc,
|
const double* visc,
|
||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelperm_ds,
|
const double* drelperm_ds,
|
||||||
std::vector<double>& mob,
|
double* mob,
|
||||||
std::vector<double>& dmob_ds,
|
double* dmob_ds,
|
||||||
double& dmobwat_dc,
|
double& dmobwat_dc,
|
||||||
bool if_with_der) const;
|
bool if_with_der) const;
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ namespace Opm
|
|||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelpermds,
|
const double* drelpermds,
|
||||||
double& totmob,
|
double& totmob,
|
||||||
std::vector<double>& dtotmob_dsdc) const;
|
double* dtotmob_dsdc) const;
|
||||||
|
|
||||||
void effectiveTotalMobilityBoth(const double c,
|
void effectiveTotalMobilityBoth(const double c,
|
||||||
const double cmax,
|
const double cmax,
|
||||||
@ -219,7 +219,7 @@ namespace Opm
|
|||||||
const double* relperm,
|
const double* relperm,
|
||||||
const double* drelperm_ds,
|
const double* drelperm_ds,
|
||||||
double& totmob,
|
double& totmob,
|
||||||
std::vector<double>& dtotmob_dsdc,
|
double* dtotmob_dsdc,
|
||||||
bool if_with_der) const;
|
bool if_with_der) const;
|
||||||
|
|
||||||
void computeMc(const double& c, double& mc) const;
|
void computeMc(const double& c, double& mc) const;
|
||||||
|
@ -499,9 +499,9 @@ namespace Opm {
|
|||||||
const Grid& g ,
|
const Grid& g ,
|
||||||
JacobianSystem& sys) {
|
JacobianSystem& sys) {
|
||||||
|
|
||||||
std::vector<double> s(2, 0.);
|
double s[2];
|
||||||
std::vector<double> mob(2, 0.);
|
double mob[2];
|
||||||
std::vector<double> dmobds(4, 0.);
|
double dmobds[4];
|
||||||
double dmobwatdc;
|
double dmobwatdc;
|
||||||
double c, cmax;
|
double c, cmax;
|
||||||
double mc, dmcdc;
|
double mc, dmcdc;
|
||||||
|
@ -468,7 +468,7 @@ namespace Opm
|
|||||||
if ((if_dres_s_dsdc || if_dres_c_dsdc) && gradient_method == Analytic) {
|
if ((if_dres_s_dsdc || if_dres_c_dsdc) && gradient_method == Analytic) {
|
||||||
double s = x[0];
|
double s = x[0];
|
||||||
double c = x[1];
|
double c = x[1];
|
||||||
std::vector<double> dff_dsdc(2);
|
double dff_dsdc[2];
|
||||||
double mc_dc;
|
double mc_dc;
|
||||||
double ads_dc;
|
double ads_dc;
|
||||||
double ads;
|
double ads;
|
||||||
@ -825,43 +825,44 @@ namespace Opm
|
|||||||
<< num_iters << " iterations." << std::endl;
|
<< num_iters << " iterations." << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TransportModelPolymer::fracFlow(double s, double c, double cmax,
|
void TransportModelPolymer::fracFlow(double s, double c, double cmax,
|
||||||
int cell, double& ff) const
|
int cell, double& ff) const
|
||||||
{
|
{
|
||||||
std::vector<double> dummy;
|
double* dummy;
|
||||||
fracFlowBoth(s, c, cmax, cell, ff, dummy, false);
|
fracFlowBoth(s, c, cmax, cell, ff, dummy, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportModelPolymer::fracFlowWithDer(double s, double c, double cmax,
|
void TransportModelPolymer::fracFlowWithDer(double s, double c, double cmax,
|
||||||
int cell, double& ff,
|
int cell, double& ff,
|
||||||
std::vector<double>& dff_dsdc) const
|
double* dff_dsdc) const
|
||||||
{
|
{
|
||||||
fracFlowBoth(s, c, cmax, cell, ff, dff_dsdc, true);
|
fracFlowBoth(s, c, cmax, cell, ff, dff_dsdc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransportModelPolymer::fracFlowBoth(double s, double c, double cmax, int cell,
|
void TransportModelPolymer::fracFlowBoth(double s, double c, double cmax, int cell,
|
||||||
double& ff, std::vector<double>& dff_dsdc,
|
double& ff, double* dff_dsdc,
|
||||||
bool if_with_der) const
|
bool if_with_der) const
|
||||||
{
|
{
|
||||||
double relperm[2];
|
double relperm[2];
|
||||||
double drelperm_ds[4];
|
double drelperm_ds[4];
|
||||||
double sat[2] = {s, 1 - s};
|
double sat[2] = {s, 1 - s};
|
||||||
|
if (if_with_der) {
|
||||||
props_.relperm(1, sat, &cell, relperm, drelperm_ds);
|
props_.relperm(1, sat, &cell, relperm, drelperm_ds);
|
||||||
std::vector<double> mob(2);
|
} else {
|
||||||
std::vector<double> dmob_ds(2);
|
props_.relperm(1, sat, &cell, relperm, 0);
|
||||||
std::vector<double> dmob_dc(2);
|
}
|
||||||
|
double mob[2];
|
||||||
|
double dmob_ds[2];
|
||||||
|
double dmob_dc[2];
|
||||||
double dmobwat_dc;
|
double dmobwat_dc;
|
||||||
polyprops_.effectiveMobilitiesBoth(c, cmax, visc_, relperm, drelperm_ds,
|
polyprops_.effectiveMobilitiesBoth(c, cmax, visc_, relperm, drelperm_ds,
|
||||||
mob, dmob_ds, dmobwat_dc, if_with_der);
|
mob, dmob_ds, dmobwat_dc, if_with_der);
|
||||||
dmob_dc[0] = dmobwat_dc;
|
|
||||||
dmob_dc[1] = 0.;
|
|
||||||
ff = mob[0]/(mob[0] + mob[1]);
|
ff = mob[0]/(mob[0] + mob[1]);
|
||||||
if (if_with_der) {
|
if (if_with_der) {
|
||||||
|
dmob_dc[0] = dmobwat_dc;
|
||||||
|
dmob_dc[1] = 0.;
|
||||||
dff_dsdc[0] = (dmob_ds[0]*mob[1] - dmob_ds[1]*mob[0])/((mob[0] + mob[1])*(mob[0] + mob[1])); // derivative with respect to s
|
dff_dsdc[0] = (dmob_ds[0]*mob[1] - dmob_ds[1]*mob[0])/((mob[0] + mob[1])*(mob[0] + mob[1])); // derivative with respect to s
|
||||||
dff_dsdc[1] = (dmob_dc[0]*mob[1] - dmob_dc[1]*mob[0])/((mob[0] + mob[1])*(mob[0] + mob[1])); // derivative with respect to c
|
dff_dsdc[1] = (dmob_dc[0]*mob[1] - dmob_dc[1]*mob[0])/((mob[0] + mob[1])*(mob[0] + mob[1])); // derivative with respect to c
|
||||||
} else {
|
|
||||||
dff_dsdc.clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,10 +98,10 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
void fracFlow(double s, double c, double cmax, int cell, double& ff) const;
|
void fracFlow(double s, double c, double cmax, int cell, double& ff) const;
|
||||||
void fracFlowWithDer(double s, double cmax, double c, int cell, double& ff,
|
void fracFlowWithDer(double s, double c, double cmax, int cell, double& ff,
|
||||||
std::vector<double>& dff_dsdc) const;
|
double* dff_dsdc) const;
|
||||||
void fracFlowBoth(double s, double c, double cmax, int cell, double& ff,
|
void fracFlowBoth(double s, double c, double cmax, int cell, double& ff,
|
||||||
std::vector<double>& dff_dsdc, bool if_with_der) const;
|
double* dff_dsdc, bool if_with_der) const;
|
||||||
void computeMc(double c, double& mc) const;
|
void computeMc(double c, double& mc) const;
|
||||||
void computeMcWithDer(double c, double& mc, double& dmc_dc) const;
|
void computeMcWithDer(double c, double& mc, double& dmc_dc) const;
|
||||||
};
|
};
|
||||||
|
@ -79,7 +79,7 @@ namespace Opm
|
|||||||
props.relperm(num_cells, &s[0], &cells[0], &kr[0], 0);
|
props.relperm(num_cells, &s[0], &cells[0], &kr[0], 0);
|
||||||
const double* visc = props.viscosity();
|
const double* visc = props.viscosity();
|
||||||
const double* rho = props.density();
|
const double* rho = props.density();
|
||||||
std::vector<double> mob(num_phases); // here we assume num_phases=2
|
double mob[num_phases]; // here we assume num_phases=2
|
||||||
for (int cell = 0; cell < num_cells; ++cell) {
|
for (int cell = 0; cell < num_cells; ++cell) {
|
||||||
double* kr_cell = &kr[2*cell];
|
double* kr_cell = &kr[2*cell];
|
||||||
polyprops.effectiveMobilities(c[cell], cmax[cell], visc, kr_cell,
|
polyprops.effectiveMobilities(c[cell], cmax[cell], visc, kr_cell,
|
||||||
@ -132,7 +132,7 @@ namespace Opm
|
|||||||
polyprod = 0.0;
|
polyprod = 0.0;
|
||||||
const double* visc = props.viscosity();
|
const double* visc = props.viscosity();
|
||||||
std::vector<double> kr_cell(np);
|
std::vector<double> kr_cell(np);
|
||||||
std::vector<double> mob(np);
|
double mob[np];
|
||||||
for (int cell = 0; cell < num_cells; ++cell) {
|
for (int cell = 0; cell < num_cells; ++cell) {
|
||||||
if (src[cell] > 0.0) {
|
if (src[cell] > 0.0) {
|
||||||
injected[0] += src[cell]*dt;
|
injected[0] += src[cell]*dt;
|
||||||
|
Loading…
Reference in New Issue
Block a user