#ifndef OPM_FULLYIMPLICITTWOPHASEPOLYMERSOLVER_HEADER_INCLUDED #define OPM_FULLYIMPLICITTWOPHASEPOLYMERSOLVER_HEADER_INCLUDED #include #include #include #include #include #include struct UnstructuredGrid; struct Wells; namespace Opm { class LinearSolverInterface; class PolymerState; class WellState; class FullyImplicitTwophasePolymerSolver { public: FullyImplicitTwophasePolymerSolver(const UnstructuredGrid& grid, const IncompPropsAdInterface& fluid, const PolymerPropsAd& polymer_props_ad, const LinearSolverInterface& linsolver, const Wells& wells, const double* gravity); void step(const double dt, PolymerState& state, WellState& well_state, const std::vector& polymer_inflow); private: typedef AutoDiffBlock ADB; typedef ADB::V V; typedef ADB::M M; typedef Eigen::Array DataBlock; struct SolutionState { SolutionState(const int np); ADB pressure; std::vector saturation; ADB concentration; ADB qs; ADB bhp; }; struct WellOps { WellOps(const Wells& wells); M w2p; // well -> perf (scatter) M p2w; // perf -> well (gather) }; const UnstructuredGrid& grid_; const IncompPropsAdInterface& fluid_; const PolymerPropsAd& polymer_props_ad_; const LinearSolverInterface& linsolver_; const Wells& wells_; const double* gravity_; const std::vector cells_; HelperOps ops_; const WellOps wops_; std::vector mob_; struct { std::vector mass_balance; ADB well_eq; ADB well_flux_eq; } residual_; SolutionState constantState(const PolymerState& x, const WellState& xw); SolutionState variableState(const PolymerState& x, const WellState& xw); void assemble(const V& pvdt, const SolutionState& old_state, const PolymerState& x, const WellState& xw, const std::vector& polymer_inflow); V solveJacobianSystem() const; void updateState(const V& dx, PolymerState& x, WellState& xw) const; std::vector computeRelPerm(const SolutionState& state) const; V transmissibility() const; std::vector computeMassFlux(const V& trans, const ADB& mc, const ADB& kro, const ADB& krw_eff, const SolutionState& state ); std::vector accumSource(const ADB& kro, const ADB& krw_eff, const ADB& c, const std::vector& src, const std::vector& polymer_inflow_c) const; std::vector computeFracFlow(const ADB& kro, const ADB& krw_eff, const ADB& c) const; double residualNorm() const; ADB polymerSource(const std::vector& kr, const std::vector& src, const std::vector& polymer_inflow_c, const SolutionState& state) const; ADB computeCmax(const ADB& c) const; ADB computeMc(const SolutionState& state) const; ADB rockPorosity(const ADB& p) const; ADB rockPermeability(const ADB& p) const; const double fluidDensity(const int phase) const; ADB fluidDensity(const int phase, const ADB p) const; ADB transMult(const ADB& p) const; }; } // namespace Opm #endif// OPM_FULLYIMPLICITTWOPHASESOLVER_HEADER_INCLUDED