3#include <deal.II/base/exceptions.h>
4#include <deal.II/base/numbers.h>
6#include <deal.II/lac/full_matrix.h>
18 template <
typename VectorType,
typename number =
double>
23 const std::vector<VectorType> &solution_history,
24 const unsigned int n_old_solutions = dealii::numbers::invalid_unsigned_int)
26 solution_history.size() :
29 Assert(n_old_solutions <= solution_history.size(), dealii::ExcInternalError());
35 template <
typename MatrixType>
37 vmult(
const MatrixType &matrix, VectorType &solution,
const VectorType &rhs)
const
39 const unsigned int n_old_solutions =
old_solution.size();
41 dealii::FullMatrix<number> projection_matrix(n_old_solutions, n_old_solutions);
42 unsigned int step = 0;
43 for (; step < n_old_solutions; ++step)
49 for (
unsigned int j = 0; j < step; ++j)
52 -projection_matrix(j, step) /
53 projection_matrix(j, j),
58 if (projection_matrix(step, step) < 1e-16 * projection_matrix(0, 0))
63 std::vector<number> project_sol(step);
64 for (
unsigned int s = 0; s < step; ++s)
67 for (
int s = step - 1; s >= 0; --s)
69 number sum = project_sol[s];
70 for (
unsigned int j = s + 1; j < step; ++j)
71 sum -= project_sol[j] * projection_matrix(s, j);
72 project_sol[s] = sum / projection_matrix(s, s);
76 solution.reinit(rhs,
true);
78 for (
unsigned int s = 1; s < step; ++s)
88 template <
typename VectorType,
typename number =
double>
106 ,
lsp(solution_history_in.get_all_solutions(),
data.n_old_solution_vectors)
110 dealii::ExcInternalError());
113 AssertThrow(!dealii::internal::is_block_vector<VectorType> ||
114 data.type != PredictorType::least_squares_projection,
115 dealii::ExcNotImplemented());
118 template <
typename MatrixType>
120 vmult(
const MatrixType &matrix, VectorType &solution,
const VectorType &rhs)
const
124 case PredictorType::none: {
128 case PredictorType::zero: {
132 case PredictorType::linear_extrapolation: {
140 solution.update_ghost_values();
143 case PredictorType::least_squares_projection: {
146 lsp.vmult(matrix, solution, rhs);
153 DEAL_II_NOT_IMPLEMENTED();
Definition predictor.hpp:20
std::vector< VectorType > internal_vectors
Definition predictor.hpp:85
std::vector< const VectorType * > old_solution
Definition predictor.hpp:83
LeastSquaresProjection(const std::vector< VectorType > &solution_history, const unsigned int n_old_solutions=dealii::numbers::invalid_unsigned_int)
Definition predictor.hpp:22
void vmult(const MatrixType &matrix, VectorType &solution, const VectorType &rhs) const
Definition predictor.hpp:37
Definition predictor.hpp:90
void vmult(const MatrixType &matrix, VectorType &solution, const VectorType &rhs) const
Definition predictor.hpp:120
TimeIntegration::SolutionHistory< VectorType > & solution_history
Definition predictor.hpp:93
const TimeIntegration::TimeIterator< number > * time_iterator
Definition predictor.hpp:94
const LeastSquaresProjection< VectorType > lsp
Definition predictor.hpp:95
const PredictorData data
Definition predictor.hpp:92
Predictor(const PredictorData data, TimeIntegration::SolutionHistory< VectorType > &solution_history_in, const TimeIntegration::TimeIterator< number > *time_iterator=nullptr)
Definition predictor.hpp:100
unsigned int n_calls
Definition predictor.hpp:97
Definition solution_history.hpp:21
Definition time_iterator.hpp:15
Interface for a general preconditioner.
Definition boundary_condition_functions.hpp:17
void compute_linear_predictor(const VectorType &old_vec, const VectorType &old_old_vec, VectorType &predictor, const number current_time_increment, const number old_time_increment)
Definition predictor_linear.cpp:76
Definition dealii_tensor.hpp:10