mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Added compressible polymer transport solver. Not yet done.
This commit is contained in:
parent
a9456704e1
commit
928513b561
@ -10,6 +10,7 @@ libopmpolymer_la_SOURCES = \
|
||||
opm/polymer/IncompTpfaPolymer.cpp \
|
||||
opm/polymer/SimulatorPolymer.cpp \
|
||||
opm/polymer/TransportModelPolymer.cpp \
|
||||
opm/polymer/TransportModelCompressiblePolymer.cpp \
|
||||
opm/polymer/PolymerProperties.cpp \
|
||||
opm/polymer/polymerUtilities.cpp
|
||||
|
||||
@ -23,4 +24,5 @@ opm/polymer/PolymerState.hpp \
|
||||
opm/polymer/SinglePointUpwindTwoPhasePolymer.hpp \
|
||||
opm/polymer/SimulatorPolymer.hpp \
|
||||
opm/polymer/TransportModelPolymer.hpp \
|
||||
opm/polymer/TransportModelCompressiblePolymer.hpp \
|
||||
opm/polymer/polymerUtilities.hpp
|
||||
|
@ -102,14 +102,8 @@ namespace Opm
|
||||
const int nc = grid_.number_of_cells;
|
||||
const int np = props_.numPhases();
|
||||
cell_relperm_.resize(nc*np);
|
||||
cell_eff_relperm_.resize(nc*np);
|
||||
const double* cell_s = &state.saturation()[0];
|
||||
props_.relperm(nc, cell_s, &allcells_[0], &cell_relperm_[0], 0);
|
||||
std::copy(cell_relperm_.begin(), cell_relperm_.end(), cell_eff_relperm_.begin());
|
||||
for (int cell; cell < grid_.number_of_cells; ++cell) {
|
||||
// only the water phase is modified by the presence og polymer.
|
||||
poly_props_.effectiveRelperm((*c_)[cell], (*cmax_)[cell], &cell_relperm_[nc + 0], cell_eff_relperm_[nc + 0]);
|
||||
}
|
||||
computeWellPotentials(state);
|
||||
if (rock_comp_props_ && rock_comp_props_->isActive()) {
|
||||
computePorevolume(grid_, props_.porosity(), *rock_comp_props_, state.pressure(), initial_porevol_);
|
||||
@ -143,14 +137,12 @@ namespace Opm
|
||||
cell_viscosity_.resize(nc*np);
|
||||
props_.viscosity(nc, cell_p, cell_z, &allcells_[0], &cell_viscosity_[0], 0);
|
||||
cell_phasemob_.resize(nc*np);
|
||||
poly_props_.effective
|
||||
for (int cell; cell < nc; ++cell) {
|
||||
// Only the water viscosity is modified by polymer.
|
||||
poly_props_.effectiveVisc((*c_)[cell], &cell_viscosity_[nc + 0], cell_eff_viscosity_[nc + 0]);
|
||||
poly_props_.effectiveMobilities((*c_)[cell], (*cmax_)[cell], &cell_viscosity_[nc + 0], &cell_relperm_[nc + 0], &cell_phasemob_[nc + 0]);
|
||||
}
|
||||
std::transform(cell_eff_relperm_.begin(), cell_eff_relperm_.end(),
|
||||
cell_eff_viscosity_.begin(),
|
||||
cell_phasemob_.begin(),
|
||||
std::divides<double>());
|
||||
|
||||
// Volume discrepancy: we have that
|
||||
// z = Au, voldiscr = sum(u) - 1,
|
||||
// but I am not sure it is actually needed.
|
||||
|
@ -106,7 +106,6 @@ namespace Opm
|
||||
const std::vector<double>* cmax_;
|
||||
std::vector<double> cell_eff_viscosity_;
|
||||
std::vector<double> cell_relperm_;
|
||||
std::vector<double> cell_eff_relperm_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
1643
opm/polymer/TransportModelCompressiblePolymer.cpp
Normal file
1643
opm/polymer/TransportModelCompressiblePolymer.cpp
Normal file
File diff suppressed because it is too large
Load Diff
206
opm/polymer/TransportModelCompressiblePolymer.hpp
Normal file
206
opm/polymer/TransportModelCompressiblePolymer.hpp
Normal file
@ -0,0 +1,206 @@
|
||||
/*
|
||||
Copyright 2012 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_TRANSPORTMODELPOLYMER_HEADER_INCLUDED
|
||||
#define OPM_TRANSPORTMODELPOLYMER_HEADER_INCLUDED
|
||||
|
||||
#include <opm/core/fluid/RockCompressibility.hpp>
|
||||
#include <opm/polymer/PolymerProperties.hpp>
|
||||
#include <opm/core/transport/reorder/TransportModelInterface.hpp>
|
||||
#include <opm/core/utility/linearInterpolation.hpp>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
class UnstructuredGrid;
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
|
||||
class BlackoilPropertiesInterface;
|
||||
|
||||
/// Implements a reordering transport solver for incompressible two-phase flow
|
||||
/// with polymer in the water phase.
|
||||
/// \TODO Include permeability reduction effect.
|
||||
class TransportModelCompressiblePolymer : public TransportModelInterface
|
||||
{
|
||||
public:
|
||||
|
||||
enum SingleCellMethod { Bracketing, Newton, Gradient, NewtonSimpleSC, NewtonSimpleC};
|
||||
enum GradientMethod { Analytic, FinDif }; // Analytic is chosen (hard-coded)
|
||||
|
||||
/// Construct solver.
|
||||
/// \param[in] grid A 2d or 3d grid.
|
||||
/// \param[in] props Rock and fluid properties.
|
||||
/// \param[in] polyprops Polymer properties.
|
||||
/// \param[in] rock_comp Rock compressibility properties
|
||||
/// \param[in] method Bracketing: solve for c in outer loop, s in inner loop,
|
||||
/// each solve being bracketed for robustness.
|
||||
/// Newton: solve simultaneously for c and s with Newton's method.
|
||||
/// (using gradient variant and bracketing as fallbacks).
|
||||
/// \param[in] tol Tolerance used in the solver.
|
||||
/// \param[in] maxit Maximum number of non-linear iterations used.
|
||||
TransportModelCompressiblePolymer(const UnstructuredGrid& grid,
|
||||
const BlackoilPropertiesInterface& props,
|
||||
const PolymerProperties& polyprops,
|
||||
const RockCompressibility& rock_comp,
|
||||
const SingleCellMethod method,
|
||||
const double tol,
|
||||
const int maxit);
|
||||
|
||||
/// Set the preferred method, Bracketing or Newton.
|
||||
void setPreferredMethod(SingleCellMethod method);
|
||||
|
||||
/// Solve for saturation, concentration and cmax at next timestep.
|
||||
/// Using implicit Euler scheme, reordered.
|
||||
/// \param[in] darcyflux Array of signed face fluxes.
|
||||
/// \param[in] pressure0 Array with pressure at start of timestep.
|
||||
/// \param[in] pressure Array with pressure.
|
||||
/// \param[in] source Transport source term.
|
||||
/// \param[in] dt Time step.
|
||||
/// \param[in] inflow_c Inflow polymer.
|
||||
/// \param[in, out] saturation Phase saturations.
|
||||
/// \param[in, out] concentration Polymer concentration.
|
||||
/// \param[in, out] cmax Highest concentration that has occured in a given cell.
|
||||
void solve(const double* darcyflux,
|
||||
const std::vector<double>& pressure0,
|
||||
const std::vector<double>& pressure,
|
||||
const double* source,
|
||||
const double dt,
|
||||
const double inflow_c,
|
||||
std::vector<double>& saturation,
|
||||
std::vector<double>& concentration,
|
||||
std::vector<double>& cmax);
|
||||
|
||||
/// Solve for gravity segregation.
|
||||
/// This uses a column-wise nonlinear Gauss-Seidel approach.
|
||||
/// It assumes that the input columns contain cells in a single
|
||||
/// vertical stack, that do not interact with other columns (for
|
||||
/// gravity segregation.
|
||||
/// \param[in] columns Vector of cell-columns.
|
||||
/// \param[in] porevolume Array of pore volumes.
|
||||
/// \param[in] dt Time step.
|
||||
/// \param[in, out] saturation Phase saturations.
|
||||
/// \param[in, out] concentration Polymer concentration.
|
||||
/// \param[in, out] cmax Highest concentration that has occured in a given cell.
|
||||
void solveGravity(const std::vector<std::vector<int> >& columns,
|
||||
const double* porevolume,
|
||||
const double dt,
|
||||
std::vector<double>& saturation,
|
||||
std::vector<double>& concentration,
|
||||
std::vector<double>& cmax);
|
||||
|
||||
public: // But should be made private...
|
||||
virtual void solveSingleCell(const int cell);
|
||||
virtual void solveMultiCell(const int num_cells, const int* cells);
|
||||
void solveSingleCellBracketing(int cell);
|
||||
void solveSingleCellNewton(int cell);
|
||||
void solveSingleCellGradient(int cell);
|
||||
void solveSingleCellNewtonSimple(int cell,bool use_sc);
|
||||
class ResidualEquation;
|
||||
|
||||
void initGravity(const double* grav);
|
||||
void solveSingleCellGravity(const std::vector<int>& cells,
|
||||
const int pos,
|
||||
const double* gravflux);
|
||||
int solveGravityColumn(const std::vector<int>& cells);
|
||||
void scToc(const double* x, double* x_c) const;
|
||||
|
||||
#ifdef PROFILING
|
||||
class Newton_Iter {
|
||||
public:
|
||||
bool res_s;
|
||||
int cell;
|
||||
double s;
|
||||
double c;
|
||||
|
||||
Newton_Iter(bool res_s_val, int cell_val, double s_val, double c_val) {
|
||||
res_s = res_s_val;
|
||||
cell = cell_val;
|
||||
s = s_val;
|
||||
c = c_val;
|
||||
}
|
||||
};
|
||||
|
||||
std::list<Newton_Iter> res_counts;
|
||||
#endif
|
||||
|
||||
|
||||
private:
|
||||
const UnstructuredGrid& grid_;
|
||||
const double* porosity_standard_;
|
||||
const BlackoilPropertiesInterface& props_;
|
||||
const PolymerProperties& polyprops_;
|
||||
const RockCompressibility& rock_comp_;
|
||||
const double* darcyflux_; // one flux per grid face
|
||||
const double* source_; // one source per cell
|
||||
double dt_;
|
||||
double inflow_c_;
|
||||
double tol_;
|
||||
double maxit_;
|
||||
SingleCellMethod method_;
|
||||
double adhoc_safety_;
|
||||
|
||||
std::vector<double> saturation_; // one per cell, only water saturation!
|
||||
std::vector<int> allcells_;
|
||||
double* concentration_;
|
||||
double* cmax_;
|
||||
std::vector<double> fractionalflow_; // one per cell
|
||||
std::vector<double> mc_; // one per cell
|
||||
std::vector<double> visc_;
|
||||
std::vector<double> A_;
|
||||
std::vector<double> A0_;
|
||||
std::vector<double> porosity0_;
|
||||
std::vector<double> porosity_;
|
||||
std::vector<double> smin_;
|
||||
std::vector<double> smax_;
|
||||
|
||||
// For gravity segregation.
|
||||
std::vector<double> gravflux_;
|
||||
std::vector<double> mob_;
|
||||
std::vector<double> cmax0_;
|
||||
// For gravity segregation, column variables
|
||||
std::vector<double> s0_;
|
||||
std::vector<double> c0_;
|
||||
|
||||
// Storing the upwind and downwind graphs for experiments.
|
||||
std::vector<int> ia_upw_;
|
||||
std::vector<int> ja_upw_;
|
||||
std::vector<int> ia_downw_;
|
||||
std::vector<int> ja_downw_;
|
||||
|
||||
struct ResidualC;
|
||||
struct ResidualS;
|
||||
|
||||
class ResidualCGrav;
|
||||
class ResidualSGrav;
|
||||
|
||||
|
||||
void fracFlow(double s, double c, double cmax, int cell, double& ff) const;
|
||||
void fracFlowWithDer(double s, double c, double cmax, int cell, double& ff,
|
||||
double* dff_dsdc) const;
|
||||
void fracFlowBoth(double s, double c, double cmax, int cell, double& ff,
|
||||
double* dff_dsdc, bool if_with_der) const;
|
||||
void computeMc(double c, double& mc) const;
|
||||
void computeMcWithDer(double c, double& mc, double& dmc_dc) const;
|
||||
void mobility(double s, double c, int cell, double* mob) const;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_TRANSPORTMODELPOLYMER_HEADER_INCLUDED
|
Loading…
Reference in New Issue
Block a user