16#ifndef dealii_solver_idr_h
17#define dealii_solver_idr_h
46 namespace SolverIDRImplementation
52 template <
typename VectorType>
91 std::vector<typename VectorMemory<VectorType>::Pointer>
data;
118template <
class VectorType = Vector<
double>>
134 const unsigned int s;
159 template <
typename MatrixType,
typename PreconditionerType>
163 const VectorType & b,
164 const PreconditionerType &preconditioner);
174 const VectorType &
x,
175 const VectorType & r,
176 const VectorType & d)
const;
193 namespace SolverIDRImplementation
195 template <
class VectorType>
204 template <
class VectorType>
216 template <
class VectorType>
219 const VectorType &
temp)
222 if (data[i] ==
nullptr)
225 data[i]->reinit(
temp,
true);
232 template <
typename VectorType,
233 std::enable_if_t<!IsBlockVector<VectorType>::value, VectorType>
236 n_blocks(
const VectorType &)
243 template <
typename VectorType,
244 std::enable_if_t<IsBlockVector<VectorType>::value, VectorType> * =
247 n_blocks(
const VectorType &vector)
249 return vector.n_blocks();
254 template <
typename VectorType,
255 std::enable_if_t<!IsBlockVector<VectorType>::value, VectorType>
258 block(VectorType &vector,
const unsigned int b)
267 template <
typename VectorType,
268 std::enable_if_t<IsBlockVector<VectorType>::value, VectorType> * =
270 typename VectorType::BlockType &
271 block(VectorType &vector,
const unsigned int b)
273 return vector.block(b);
281template <
class VectorType>
284 const AdditionalData & data)
286 , additional_data(data)
291template <
class VectorType>
294 , additional_data(data)
299template <
class VectorType>
304 const VectorType &)
const
309template <
class VectorType>
310template <
typename MatrixType,
typename PreconditionerType>
314 const VectorType & b,
315 const PreconditionerType &preconditioner)
320 unsigned int step = 0;
322 const unsigned int s = additional_data.s;
339 r.sadd(-1.0, 1.0, b);
341 using value_type =
typename VectorType::value_type;
345 real_type
res = r.l2_norm();
360 for (
unsigned int i = 0; i < s; ++i)
374 for (
unsigned int b = 0;
375 b < internal::SolverIDRImplementation::n_blocks(
tmp_q);
378 .locally_owned_elements())
386 for (
unsigned int j = 0;
j < i; ++
j)
410 for (
unsigned int i = 0; i < s; ++i)
414 for (
unsigned int k = 0;
k < s; ++
k)
421 std::vector<unsigned int> indices;
423 for (
unsigned int i =
k; i < s; ++i, ++
j)
425 indices.push_back(i);
428 Mk.extract_submatrix_from(
M, indices, indices);
439 for (
unsigned int i =
k,
j = 0; i < s; ++i, ++
j)
443 preconditioner.vmult(
uhat, v);
448 for (
unsigned int i =
k + 1,
j = 1; i < s; ++i, ++
j)
461 for (
unsigned int i = 1; i <
k; ++i)
480 for (
unsigned int i =
k + 1; i < s; ++i)
481 M(i,
k) =
Q[i] * G[
k];
489 print_vectors(step,
x, r, U[
k]);
505 for (
unsigned int i = 0; i <
k + 1; ++i)
507 for (
unsigned int i =
k + 1; i < s; ++i)
516 preconditioner.vmult(
uhat, r);
519 omega = (v * r) / (v * v);
524 print_vectors(step,
x, r,
uhat);
void reinit(value_type *starting_element, const std::size_t n_elements)
@ iterate
Continue iteration.
@ success
Stop iteration, goal reached.
virtual void print_vectors(const unsigned int step, const VectorType &x, const VectorType &r, const VectorType &d) const
SolverIDR(SolverControl &cn, const AdditionalData &data=AdditionalData())
void solve(const MatrixType &A, VectorType &x, const VectorType &b, const PreconditionerType &preconditioner)
SolverIDR(SolverControl &cn, VectorMemory< VectorType > &mem, const AdditionalData &data=AdditionalData())
AdditionalData additional_data
virtual ~SolverIDR() override=default
TmpVectors(const unsigned int s_param, VectorMemory< VectorType > &vmem)
VectorType & operator()(const unsigned int i, const VectorType &temp)
VectorType & operator[](const unsigned int i) const
VectorMemory< VectorType > & mem
std::vector< typename VectorMemory< VectorType >::Pointer > data
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcNotInitialized()
#define AssertThrow(cond, exc)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
long double gamma(const unsigned int n)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
AdditionalData(const unsigned int s=2)