Assemble and solve the equation system.
64 std::vector<GlobalVector*> x_new{x};
69 bool error_norms_met =
false;
78 double time_dirichlet = 0.0;
81 time_iteration.
start();
83 timer_dirichlet.
start();
84 sys.computeKnownSolutions(*x_new[process_id], process_id);
85 sys.applyKnownSolutions(*x_new[process_id]);
86 time_dirichlet += timer_dirichlet.
elapsed();
88 sys.preIteration(iteration, *x_new[process_id]);
91 time_assembly.
start();
92 sys.assemble(x_new, x_prev, process_id);
94 sys.getRhs(*x_prev[process_id], rhs);
95 INFO(
"[time] Assembly took {:g} s.", time_assembly.
elapsed());
103 timer_dirichlet.
start();
104 sys.applyKnownSolutionsPicard(A, rhs, *x_new[process_id]);
105 time_dirichlet += timer_dirichlet.
elapsed();
106 INFO(
"[time] Applying Dirichlet BCs took {:g} s.", time_dirichlet);
116 time_linear_solver.
start();
117 bool iteration_succeeded =
119 INFO(
"[time] Linear solver took {:g} s.", time_linear_solver.
elapsed());
121 if (!iteration_succeeded)
123 ERR(
"Picard: The linear solver failed.");
127 if (postIterationCallback)
129 postIterationCallback(iteration, x_new);
132 switch (sys.postIteration(*x_new[process_id]))
139 ERR(
"Picard: The postIteration() hook reported a "
140 "non-recoverable error.");
141 iteration_succeeded =
false;
149 "Picard: The postIteration() hook decided that this "
150 "iteration has to be repeated.");
158 if (!iteration_succeeded)
161 error_norms_met =
false;
165 if (sys.isLinear()) {
166 error_norms_met =
true;
182 INFO(
"[time] Iteration #{:d} took {:g} s.", iteration,
200 ERR(
"Picard: Could not solve the given nonlinear system within {:d} "
209 return {error_norms_met, iteration};
void INFO(char const *fmt, Args const &... args)
void ERR(char const *fmt, Args const &... args)
double elapsed() const
Get the elapsed time in seconds.
void start()
Start the timer.
bool solve(EigenMatrix &A, EigenVector &b, EigenVector &x)
Global vector based on Eigen vector.
virtual void preFirstIteration()
virtual void checkResidual(GlobalVector const &residual)=0
Check if the residual satisfies the convergence criterion.
virtual bool hasResidualCheck() const =0
virtual bool isSatisfied() const
Tell if the convergence criterion is satisfied.
virtual void checkDeltaX(GlobalVector const &minus_delta_x, GlobalVector const &x)=0
virtual bool hasDeltaXCheck() const =0
virtual void releaseMatrix(GlobalMatrix const &A)=0
void copy(PETScVector const &x, PETScVector &y)