36 #ifndef OPM_IMPLICITTRANSPORT_HPP_HEADER
37 #define OPM_IMPLICITTRANSPORT_HPP_HEADER
44 namespace ImplicitTransportDetails {
70 template <
class Ostream>
73 os <<
"Number of linear solves: " << rpt.
nit <<
'\n'
74 <<
"Process converged: " << (rpt.
flag > 0) <<
'\n'
75 <<
"Convergence flag: " << rpt.
flag;
78 os <<
" (absolute tolerance satisfied)\n";
81 os <<
" (relative tolerance satisfied)\n";
84 os <<
" (solution change tolerance satisfied)\n";
87 os <<
" (failed to converge)\n";
90 os <<
" (unknown convergence flag)\n";
92 os <<
"Final residual norm: " << rpt.
norm_res <<
'\n'
93 <<
"Final increment norm: " << rpt.
norm_dx <<
'\n';
98 template <
class Model ,
99 class JacobianSystem ,
100 template <
class>
class VNorm ,
101 template <
class>
class VNeg ,
102 template <
class>
class VZero ,
103 template <
class>
class MZero ,
104 template <
class>
class VAsgn >
112 template <
class Grid ,
114 class ReservoirState,
117 const SourceTerms* src ,
120 ReservoirState& state ,
121 LinearSolver& linsolve,
124 typedef typename JacobianSystem::vector_type vector_type;
125 typedef typename JacobianSystem::matrix_type matrix_type;
127 asm_.createSystem(g, sys_);
128 model_.initStep(state, g, sys_);
129 init = model_.initIteration(state, g, sys_);
131 MZero<matrix_type>::zero(sys_.writableMatrix());
132 VZero<vector_type>::zero(sys_.vector().writableResidual());
134 asm_.assemble(state, g, src, dt, sys_);
136 const double nrm_res0 =
137 VNorm<vector_type>::norm(sys_.vector().residual());
146 VZero<vector_type>::zero(sys_.vector().writableIncrement());
148 linsolve.solve(sys_.matrix(),
149 sys_.vector().residual(),
150 sys_.vector().writableIncrement());
152 VNeg<vector_type>::negate(sys_.vector().writableIncrement());
157 VNorm<vector_type>::norm(sys_.vector().increment());
160 double residual=VNorm<vector_type>::norm(sys_.vector().residual());
165 vector_type dx_old(sys_.vector().increment());
166 vector_type x_old(sys_.vector().solution());
170 sys_.vector().writableIncrement());
172 sys_.vector().writableSolution());
174 sys_.vector().addIncrement();
175 init = model_.initIteration(state, g, sys_);
177 MZero<matrix_type>::zero(sys_.writableMatrix());
178 VZero<vector_type>::zero(sys_.vector().writableResidual());
179 asm_.assemble(state, g, src, dt, sys_);
180 residual = VNorm<vector_type>::norm(sys_.vector().residual());
182 std::cout <<
"Line search iteration " << std::scientific << lin_it
183 <<
" norm :" << residual <<
" alpha " << alpha <<
'\n';
187 std::cout <<
"Line search iteration " << std::scientific << lin_it
188 <<
" Value out of range, continue search. alpha " << alpha <<
'\n';
196 VNorm<vector_type>::norm(sys_.vector().residual());
200 std::cout <<
"Iteration " << std::scientific << rpt.
nit
201 <<
" norm :" << rpt.
norm_res <<
" alpha " << alpha << std::endl;
210 model_.finishStep(g, sys_.vector().solution(), state);
215 else { rpt.
flag = -1; }
223 using Model::initStep;
224 using Model::initIteration;
225 using Model::finishIteration;
226 using Model::finishStep;
void solve(const Grid &g, const SourceTerms *src, const double dt, const ImplicitTransportDetails::NRControl &ctrl, ReservoirState &state, LinearSolver &linsolve, ImplicitTransportDetails::NRReport &rpt)
Definition: ImplicitTransport.hpp:116
Definition: AnisotropicEikonal.hpp:43
void assign(const Grid &G, const std::array< PressFunction, 2 > &f, const double split, const CellRange &cells, std::vector< double > &p)
Definition: initStateEquil_impl.hpp:310
int verbosity
Definition: ImplicitTransport.hpp:60
double norm_res
Definition: ImplicitTransport.hpp:66
double rtol
Definition: ImplicitTransport.hpp:57
ImplicitTransport(Model &model)
Definition: ImplicitTransport.hpp:107
int max_it
Definition: ImplicitTransport.hpp:55
double norm_dx
Definition: ImplicitTransport.hpp:67
Definition: ImplicitTransport.hpp:45
int max_it_ls
Definition: ImplicitTransport.hpp:59
Definition: ImplicitAssembly.hpp:45
int nit
Definition: ImplicitTransport.hpp:64
double dxtol
Definition: ImplicitTransport.hpp:58
Definition: ImplicitTransport.hpp:63
int flag
Definition: ImplicitTransport.hpp:65
NRControl()
Definition: ImplicitTransport.hpp:46
double atol
Definition: ImplicitTransport.hpp:56
Ostream & operator<<(Ostream &os, const NRReport &rpt)
Definition: ImplicitTransport.hpp:71
Definition: ImplicitTransport.hpp:105