Loading...
Searching...
No Matches
schwarz.hh
Go to the documentation of this file.
// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_ISTL_SCHWARZ_HH
#define DUNE_ISTL_SCHWARZ_HH
#include <iostream> // for input/output to shell
#include <fstream> // for input/output to files
#include <vector> // STL vector class
#include <sstream>
#include <cmath> // Yes, we do some math here
#include <dune/common/timer.hh>
#include "io.hh"
#include "bvector.hh"
#include "vbvector.hh"
#include "bcrsmatrix.hh"
#include "io.hh"
#include "gsetc.hh"
#include "ilu.hh"
#include "operators.hh"
#include "solvers.hh"
#include "preconditioners.hh"
#include "scalarproducts.hh"
#include "owneroverlapcopy.hh"
namespace Dune {
template<class M, class X, class Y, class C>
class OverlappingSchwarzOperator : public AssembledLinearOperator<M,X,Y>
{
public:
typedef M matrix_type;
typedef X domain_type;
typedef Y range_type;
typedef typename X::field_type field_type;
typedef C communication_type;
OverlappingSchwarzOperator (const matrix_type& A, const communication_type& com)
: _A_(stackobject_to_shared_ptr(A)), communication(com)
{}
OverlappingSchwarzOperator (const std::shared_ptr<matrix_type> A, const communication_type& com)
: _A_(A), communication(com)
{}
void apply (const X& x, Y& y) const override
{
y = 0;
_A_->umv(x,y); // result is consistent on interior+border
communication.project(y); // we want this here to avoid it before the preconditioner
// since there d is const!
}
void applyscaleadd (field_type alpha, const X& x, Y& y) const override
{
_A_->usmv(alpha,x,y); // result is consistent on interior+border
communication.project(y); // we want this here to avoid it before the preconditioner
// since there d is const!
}
const matrix_type& getmat () const override
{
return *_A_;
}
SolverCategory::Category category() const override
{
return SolverCategory::overlapping;
}
const communication_type& getCommunication() const
{
return communication;
}
private:
const std::shared_ptr<const matrix_type>_A_;
const communication_type& communication;
};
template<class M, class X, class Y, class C>
class ParSSOR : public Preconditioner<X,Y> {
public:
typedef M matrix_type;
typedef X domain_type;
typedef Y range_type;
typedef typename X::field_type field_type;
typedef C communication_type;
ParSSOR (const matrix_type& A, int n, field_type w, const communication_type& c)
: _A_(A), _n(n), _w(w), communication(c)
{ }
void pre (X& x, [[maybe_unused]] Y& b) override
{
communication.copyOwnerToAll(x,x); // make dirichlet values consistent
}
void apply (X& v, const Y& d) override
{
for (int i=0; i<_n; i++) {
bsorf(_A_,v,d,_w);
bsorb(_A_,v,d,_w);
}
communication.copyOwnerToAll(v,v);
}
void post ([[maybe_unused]] X& x) override {}
SolverCategory::Category category() const override
{
return SolverCategory::overlapping;
}
private:
const matrix_type& _A_;
int _n;
field_type _w;
const communication_type& communication;
};
namespace Amg
{
template<class T> struct ConstructionTraits;
}
template<class X, class Y, class C, class P=Preconditioner<X,Y> >
class BlockPreconditioner : public Preconditioner<X,Y> {
friend struct Amg::ConstructionTraits<BlockPreconditioner<X,Y,C,P> >;
public:
typedef X domain_type;
typedef Y range_type;
typedef typename X::field_type field_type;
typedef C communication_type;
BlockPreconditioner (P& p, const communication_type& c)
: _preconditioner(stackobject_to_shared_ptr(p)), _communication(c)
{ }
BlockPreconditioner (const std::shared_ptr<P>& p, const communication_type& c)
: _preconditioner(p), _communication(c)
{ }
void pre (X& x, Y& b) override
{
_communication.copyOwnerToAll(x,x); // make dirichlet values consistent
_preconditioner->pre(x,b);
}
void apply (X& v, const Y& d) override
{
_preconditioner->apply(v,d);
_communication.copyOwnerToAll(v,v);
}
template<bool forward>
void apply (X& v, const Y& d)
{
_preconditioner->template apply<forward>(v,d);
_communication.copyOwnerToAll(v,v);
}
void post (X& x) override
{
_preconditioner->post(x);
}
SolverCategory::Category category() const override
{
return SolverCategory::overlapping;
}
private:
std::shared_ptr<P> _preconditioner;
const communication_type& _communication;
};
} // end namespace
#endif
bcrsmatrix.hh
Implementation of the BCRSMatrix class.
gsetc.hh
Simple iterative methods like Jacobi, Gauss-Seidel, SOR, SSOR, etc. in a generic way.
owneroverlapcopy.hh
Classes providing communication interfaces for overlapping Schwarz methods.
preconditioners.hh
Define general preconditioner interface.
solvers.hh
Implementations of the inverse operator interface.
io.hh
Some generic functions for pretty printing vectors and matrices.
operators.hh
Define general, extensible interface for operators. The available implementation wraps a matrix.
bvector.hh
This file implements a vector space as a tensor product of a given vector space. The number of compon...
scalarproducts.hh
Define base class for scalar product and norm.
ilu.hh
The incomplete LU factorization kernels.
vbvector.hh
???
Dune::bsorb
void bsorb(const M &A, X &x, const Y &b, const K &w)
SSOR step.
Definition gsetc.hh:646
Dune::bsorf
void bsorf(const M &A, X &x, const Y &b, const K &w)
SOR step.
Definition gsetc.hh:634
Dune
Definition allocator.hh:11
Dune::Amg
Definition novlpschwarz.hh:256
Dune::Amg::ConstructionTraits
Traits class for generically constructing non default constructable types.
Definition construction.hh:39
Dune::AssembledLinearOperator
A linear operator exporting itself in matrix form.
Definition operators.hh:110
Dune::OverlappingSchwarzOperator::getmat
const matrix_type & getmat() const override
get the sequential assembled linear operator.
Definition schwarz.hh:133
Dune::OverlappingSchwarzOperator::getCommunication
const communication_type & getCommunication() const
Get the object responsible for communication.
Definition schwarz.hh:146
Dune::OverlappingSchwarzOperator::apply
void apply(const X &x, Y &y) const override
apply operator to x:
Definition schwarz.hh:116
Dune::OverlappingSchwarzOperator::applyscaleadd
void applyscaleadd(field_type alpha, const X &x, Y &y) const override
apply operator to x, scale and add:
Definition schwarz.hh:125
Dune::OverlappingSchwarzOperator::communication_type
C communication_type
The type of the communication object.
Definition schwarz.hh:98
Dune::OverlappingSchwarzOperator::category
SolverCategory::Category category() const override
Category of the linear operator (see SolverCategory::Category).
Definition schwarz.hh:139
Dune::OverlappingSchwarzOperator::domain_type
X domain_type
The type of the domain.
Definition schwarz.hh:86
Dune::OverlappingSchwarzOperator::matrix_type
M matrix_type
The type of the matrix we operate on.
Definition schwarz.hh:81
Dune::OverlappingSchwarzOperator::range_type
Y range_type
The type of the range.
Definition schwarz.hh:91
Dune::OverlappingSchwarzOperator::field_type
X::field_type field_type
The field type of the range.
Definition schwarz.hh:93
Dune::OverlappingSchwarzOperator::OverlappingSchwarzOperator
OverlappingSchwarzOperator(const matrix_type &A, const communication_type &com)
constructor: just store a reference to a matrix.
Definition schwarz.hh:107
Dune::OverlappingSchwarzOperator::OverlappingSchwarzOperator
OverlappingSchwarzOperator(const std::shared_ptr< matrix_type > A, const communication_type &com)
Definition schwarz.hh:111
Dune::Preconditioner
Base class for matrix free definition of preconditioners.
Definition preconditioner.hh:33
Dune::ParSSOR::field_type
X::field_type field_type
The field type of the preconditioner.
Definition schwarz.hh:184
Dune::ParSSOR::communication_type
C communication_type
The type of the communication object.
Definition schwarz.hh:186
Dune::ParSSOR::pre
void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition schwarz.hh:206
Dune::ParSSOR::ParSSOR
ParSSOR(const matrix_type &A, int n, field_type w, const communication_type &c)
Constructor.
Definition schwarz.hh:197
Dune::ParSSOR::domain_type
X domain_type
The domain type of the preconditioner.
Definition schwarz.hh:180
Dune::ParSSOR::range_type
Y range_type
The range type of the preconditioner.
Definition schwarz.hh:182
Dune::ParSSOR::matrix_type
M matrix_type
The matrix type the preconditioner is for.
Definition schwarz.hh:178
Dune::ParSSOR::category
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category).
Definition schwarz.hh:233
Dune::ParSSOR::apply
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition schwarz.hh:216
Dune::ParSSOR::post
void post(X &x) override
Clean up.
Definition schwarz.hh:230
Dune::BlockPreconditioner::category
SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category).
Definition schwarz.hh:361
Dune::BlockPreconditioner::pre
void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition schwarz.hh:326
Dune::BlockPreconditioner::apply
void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition schwarz.hh:337
Dune::BlockPreconditioner< X, Y, C, SeqSOR< M, X, Y, l > >::domain_type
X domain_type
Definition schwarz.hh:285
Dune::BlockPreconditioner::BlockPreconditioner
BlockPreconditioner(const std::shared_ptr< P > &p, const communication_type &c)
Constructor.
Definition schwarz.hh:317
Dune::BlockPreconditioner::BlockPreconditioner
BlockPreconditioner(P &p, const communication_type &c)
Constructor.
Definition schwarz.hh:306
Dune::BlockPreconditioner::apply
void apply(X &v, const Y &d)
Apply one step of the preconditioner to the system A(v)=d.
Definition schwarz.hh:344
Dune::BlockPreconditioner::post
void post(X &x) override
Clean up.
Definition schwarz.hh:355
Dune::BlockPreconditioner< X, Y, C, SeqSOR< M, X, Y, l > >::communication_type
C communication_type
Definition schwarz.hh:297
Dune::BlockPreconditioner< X, Y, C, SeqSOR< M, X, Y, l > >::field_type
X::field_type field_type
Definition schwarz.hh:292
Dune::BlockPreconditioner< X, Y, C, SeqSOR< M, X, Y, l > >::range_type
Y range_type
Definition schwarz.hh:290
Dune::SolverCategory::Category
Category
Definition solvercategory.hh:23
Dune::SolverCategory::overlapping
@ overlapping
Category for overlapping solvers.
Definition solvercategory.hh:29