Assemble and solve the equation system.
62 std::vector<GlobalVector*> x_new{x};
67 bool error_norms_met =
false;
75 double time_dirichlet = 0.0;
78 time_iteration.
start();
80 timer_dirichlet.
start();
81 sys.computeKnownSolutions(*x_new[process_id], process_id);
82 sys.applyKnownSolutions(*x_new[process_id]);
83 time_dirichlet += timer_dirichlet.
elapsed();
85 sys.preIteration(iteration, *x_new[process_id]);
88 time_assembly.
start();
89 sys.assemble(x_new, x_prev, process_id);
91 sys.getRhs(*x_prev[process_id], rhs);
92 INFO(
"[time] Assembly took {:g} s.", time_assembly.
elapsed());
100 timer_dirichlet.
start();
101 sys.applyKnownSolutionsPicard(A, rhs, *x_new[process_id]);
102 time_dirichlet += timer_dirichlet.
elapsed();
103 INFO(
"[time] Applying Dirichlet BCs took {:g} s.", time_dirichlet);
114 time_linear_solver.
start();
115 bool iteration_succeeded =
117 INFO(
"[time] Linear solver took {:g} s.", time_linear_solver.
elapsed());
119 if (!iteration_succeeded)
121 ERR(
"Picard: The linear solver failed.");
125 if (postIterationCallback)
127 postIterationCallback(iteration, x_new);
130 switch (sys.postIteration(*x_new[process_id]))
137 ERR(
"Picard: The postIteration() hook reported a "
138 "non-recoverable error.");
139 iteration_succeeded =
false;
147 "Picard: The postIteration() hook decided that this "
148 "iteration has to be repeated.");
156 if (!iteration_succeeded)
159 error_norms_met =
false;
165 error_norms_met =
true;
184 INFO(
"[time] Iteration #{:d} took {:g} s.", iteration,
202 ERR(
"Picard: Could not solve the given nonlinear system within {:d} "
211 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)