mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Added PROFILING preprocessor flag.
This commit is contained in:
parent
10267620f9
commit
52a19192cb
@ -120,6 +120,7 @@ static void outputState(const UnstructuredGrid& grid,
|
|||||||
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
|
std::copy(d.begin(), d.end(), std::ostream_iterator<double>(file, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if PROFILING
|
||||||
std::ostringstream fname;
|
std::ostringstream fname;
|
||||||
fname << output_dir << "/" << "residualcounts" << "-" << std::setw(3) << std::setfill('0') << step << ".dat";
|
fname << output_dir << "/" << "residualcounts" << "-" << std::setw(3) << std::setfill('0') << step << ".dat";
|
||||||
std::ofstream file(fname.str().c_str());
|
std::ofstream file(fname.str().c_str());
|
||||||
@ -134,6 +135,7 @@ static void outputState(const UnstructuredGrid& grid,
|
|||||||
file << it->res_s << "," << it->cell << "," << std::setprecision(15) << it->s << "," << std::setprecision(15) << it->c << "\n";
|
file << it->res_s << "," << it->cell << "," << std::setprecision(15) << it->s << "," << std::setprecision(15) << it->c << "\n";
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -229,6 +229,7 @@ main(int argc, char** argv)
|
|||||||
state.concentration(),
|
state.concentration(),
|
||||||
state.maxconcentration());
|
state.maxconcentration());
|
||||||
|
|
||||||
|
#if PROFILING
|
||||||
// Extract residual counts.
|
// Extract residual counts.
|
||||||
typedef std::list<Opm::TransportModelPolymer::Newton_Iter> ListRes;
|
typedef std::list<Opm::TransportModelPolymer::Newton_Iter> ListRes;
|
||||||
const ListRes& res_counts = reorder_model.res_counts;
|
const ListRes& res_counts = reorder_model.res_counts;
|
||||||
@ -241,6 +242,7 @@ main(int argc, char** argv)
|
|||||||
// std::cout << "c residual count: " << counts[0] << '\n';
|
// std::cout << "c residual count: " << counts[0] << '\n';
|
||||||
// std::cout << "s residual count: " << counts[1] << '\n';
|
// std::cout << "s residual count: " << counts[1] << '\n';
|
||||||
std::cout << counts[0] << ' ' << counts[1] << ' ' << s << ' ' << c << '\n';
|
std::cout << counts[0] << ' ' << counts[1] << ' ' << s << ' ' << c << '\n';
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -204,7 +204,9 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
visc_ = props.viscosity();
|
visc_ = props.viscosity();
|
||||||
|
|
||||||
|
#if PROFILING
|
||||||
res_counts.clear();
|
res_counts.clear();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Set up smin_ and smax_
|
// Set up smin_ and smax_
|
||||||
int num_cells = props.numCells();
|
int num_cells = props.numCells();
|
||||||
@ -245,7 +247,9 @@ namespace Opm
|
|||||||
toWaterSat(saturation, saturation_);
|
toWaterSat(saturation, saturation_);
|
||||||
concentration_ = &concentration[0];
|
concentration_ = &concentration[0];
|
||||||
cmax_ = &cmax[0];
|
cmax_ = &cmax[0];
|
||||||
|
#if PROFILING
|
||||||
res_counts.clear();
|
res_counts.clear();
|
||||||
|
#endif
|
||||||
reorderAndTransport(grid_, darcyflux);
|
reorderAndTransport(grid_, darcyflux);
|
||||||
toBothSat(saturation_, saturation);
|
toBothSat(saturation_, saturation);
|
||||||
}
|
}
|
||||||
@ -292,7 +296,9 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
double operator()(double s) const
|
double operator()(double s) const
|
||||||
{
|
{
|
||||||
|
#if PROFILING
|
||||||
tm_.res_counts.push_back(Newton_Iter(true, cell_, s, c_));
|
tm_.res_counts.push_back(Newton_Iter(true, cell_, s, c_));
|
||||||
|
#endif
|
||||||
double ff;
|
double ff;
|
||||||
tm_.fracFlow(s, c_, cmax0_, cell_, ff);
|
tm_.fracFlow(s, c_, cmax0_, cell_, ff);
|
||||||
return s - s0_ + dtpv_*(outflux_*ff + influx_ + s*comp_term_);
|
return s - s0_ + dtpv_*(outflux_*ff + influx_ + s*comp_term_);
|
||||||
@ -379,8 +385,10 @@ namespace Opm
|
|||||||
+ rhor*((1.0 - porosity)/porosity)*(c_ads - c_ads0)
|
+ rhor*((1.0 - porosity)/porosity)*(c_ads - c_ads0)
|
||||||
+ dtpv*(outflux*ff*mc + influx_polymer)
|
+ dtpv*(outflux*ff*mc + influx_polymer)
|
||||||
+ dtpv*(s_arg*c_arg*(1.0 - dps) - rhor*c_ads)*comp_term;
|
+ dtpv*(s_arg*c_arg*(1.0 - dps) - rhor*c_ads)*comp_term;
|
||||||
|
#if PROFILING
|
||||||
tm.res_counts.push_back(Newton_Iter(true, cell, s_arg, c_arg));
|
tm.res_counts.push_back(Newton_Iter(true, cell, s_arg, c_arg));
|
||||||
tm.res_counts.push_back(Newton_Iter(false, cell, s_arg, c_arg));
|
tm.res_counts.push_back(Newton_Iter(false, cell, s_arg, c_arg));
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -403,7 +411,9 @@ namespace Opm
|
|||||||
tm.polyprops_.adsorption(c0, cmax0, c_ads0);
|
tm.polyprops_.adsorption(c0, cmax0, c_ads0);
|
||||||
double c_ads;
|
double c_ads;
|
||||||
tm.polyprops_.adsorption(c, cmax0, c_ads);
|
tm.polyprops_.adsorption(c, cmax0, c_ads);
|
||||||
|
#if PROFILING
|
||||||
tm.res_counts.push_back(Newton_Iter(false, cell, s, c));
|
tm.res_counts.push_back(Newton_Iter(false, cell, s, c));
|
||||||
|
#endif
|
||||||
double res = (1 - dps)*s*c - (1 - dps)*s0*c0
|
double res = (1 - dps)*s*c - (1 - dps)*s0*c0
|
||||||
+ rhor*((1.0 - porosity)/porosity)*(c_ads - c_ads0)
|
+ rhor*((1.0 - porosity)/porosity)*(c_ads - c_ads0)
|
||||||
+ dtpv*(outflux*ff*mc + influx_polymer)
|
+ dtpv*(outflux*ff*mc + influx_polymer)
|
||||||
@ -563,14 +573,18 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
if (if_res_s) {
|
if (if_res_s) {
|
||||||
res[0] = s - s0 + dtpv*(outflux*ff + influx + s*comp_term);
|
res[0] = s - s0 + dtpv*(outflux*ff + influx + s*comp_term);
|
||||||
|
#if PROFILING
|
||||||
tm.res_counts.push_back(Newton_Iter(true, cell, x[0], x[1]));
|
tm.res_counts.push_back(Newton_Iter(true, cell, x[0], x[1]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (if_res_c) {
|
if (if_res_c) {
|
||||||
res[1] = (1 - dps)*s*c - (1 - dps)*s0*c0
|
res[1] = (1 - dps)*s*c - (1 - dps)*s0*c0
|
||||||
+ rhor*((1.0 - porosity)/porosity)*(ads - ads0)
|
+ rhor*((1.0 - porosity)/porosity)*(ads - ads0)
|
||||||
+ dtpv*(outflux*ff*mc + influx_polymer)
|
+ dtpv*(outflux*ff*mc + influx_polymer)
|
||||||
+ dtpv*(s*c*(1.0 - dps) - rhor*ads)*comp_term;
|
+ dtpv*(s*c*(1.0 - dps) - rhor*ads)*comp_term;
|
||||||
|
#if PROFILING
|
||||||
tm.res_counts.push_back(Newton_Iter(false, cell, x[0], x[1]));
|
tm.res_counts.push_back(Newton_Iter(false, cell, x[0], x[1]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (if_dres_s_dsdc) {
|
if (if_dres_s_dsdc) {
|
||||||
dres_s_dsdc[0] = 1 + dtpv*(outflux*dff_dsdc[0] + comp_term);
|
dres_s_dsdc[0] = 1 + dtpv*(outflux*dff_dsdc[0] + comp_term);
|
||||||
@ -590,7 +604,9 @@ namespace Opm
|
|||||||
tm.fracFlow(s, c, cmax0, cell, ff);
|
tm.fracFlow(s, c, cmax0, cell, ff);
|
||||||
if (if_res_s) {
|
if (if_res_s) {
|
||||||
res[0] = s - s0 + dtpv*(outflux*ff + influx + s*comp_term);
|
res[0] = s - s0 + dtpv*(outflux*ff + influx + s*comp_term);
|
||||||
|
#if PROFILING
|
||||||
tm.res_counts.push_back(Newton_Iter(true, cell, x[0], x[1]));
|
tm.res_counts.push_back(Newton_Iter(true, cell, x[0], x[1]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (if_res_c) {
|
if (if_res_c) {
|
||||||
tm.computeMc(c, mc);
|
tm.computeMc(c, mc);
|
||||||
@ -600,7 +616,9 @@ namespace Opm
|
|||||||
+ rhor*((1.0 - porosity)/porosity)*(ads - ads0)
|
+ rhor*((1.0 - porosity)/porosity)*(ads - ads0)
|
||||||
+ dtpv*(outflux*ff*mc + influx_polymer)
|
+ dtpv*(outflux*ff*mc + influx_polymer)
|
||||||
+ dtpv*(s*c*(1.0 - dps) - rhor*ads)*comp_term;
|
+ dtpv*(s*c*(1.0 - dps) - rhor*ads)*comp_term;
|
||||||
|
#if PROFILING
|
||||||
tm.res_counts.push_back(Newton_Iter(false, cell, x[0], x[1]));
|
tm.res_counts.push_back(Newton_Iter(false, cell, x[0], x[1]));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,8 +114,9 @@ namespace Opm
|
|||||||
const int pos,
|
const int pos,
|
||||||
const double* gravflux);
|
const double* gravflux);
|
||||||
int solveGravityColumn(const std::vector<int>& cells);
|
int solveGravityColumn(const std::vector<int>& cells);
|
||||||
|
void scToc(const double* x, double* x_c) const;
|
||||||
|
|
||||||
// for testing
|
#if PROFILING
|
||||||
class Newton_Iter {
|
class Newton_Iter {
|
||||||
public:
|
public:
|
||||||
bool res_s;
|
bool res_s;
|
||||||
@ -132,8 +133,8 @@ namespace Opm
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::list<Newton_Iter> res_counts;
|
std::list<Newton_Iter> res_counts;
|
||||||
|
#endif
|
||||||
|
|
||||||
void scToc(const double* x, double* x_c) const;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const UnstructuredGrid& grid_;
|
const UnstructuredGrid& grid_;
|
||||||
|
Loading…
Reference in New Issue
Block a user