Loading...
Searching...
No Matches
transfer.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_AMGTRANSFER_HH
#define DUNE_AMGTRANSFER_HH
#include <dune/istl/bvector.hh>
#include <dune/istl/matrixredistribute.hh>
#include <dune/istl/paamg/pinfo.hh>
#include <dune/istl/owneroverlapcopy.hh>
#include <dune/istl/paamg/aggregates.hh>
#include <dune/common/exceptions.hh>
namespace Dune
{
namespace Amg
{
template<class V1, class V2, class T>
class Transfer
{
public:
typedef V1 Vertex;
typedef V2 Vector;
template<typename T1, typename R>
static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
Vector& fineRedist,T1 damp, R& redistributor=R());
template<typename T1, typename R>
static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
T1 damp);
static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
T& comm);
};
template<class V,class V1>
class Transfer<V,V1, SequentialInformation>
{
public:
typedef V Vertex;
typedef V1 Vector;
typedef RedistributeInformation<SequentialInformation> Redist;
template<typename T1>
static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
Vector& fineRedist, T1 damp,
const SequentialInformation& comm=SequentialInformation(),
const Redist& redist=Redist());
template<typename T1>
static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
T1 damp,
const SequentialInformation& comm=SequentialInformation());
static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
const SequentialInformation& comm);
};
#if HAVE_MPI
template<class V,class V1, class T1, class T2>
class Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >
{
public:
typedef V Vertex;
typedef V1 Vector;
typedef RedistributeInformation<OwnerOverlapCopyCommunication<T1,T2> > Redist;
template<typename T3>
static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
Vector& fineRedist, T3 damp, OwnerOverlapCopyCommunication<T1,T2>& comm,
const Redist& redist);
template<typename T3>
static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
T3 damp, OwnerOverlapCopyCommunication<T1,T2>& comm);
static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
OwnerOverlapCopyCommunication<T1,T2>& comm);
};
#endif
template<class V, class V1>
template<typename T>
inline void
Transfer<V,V1,SequentialInformation>::prolongateVector(const AggregatesMap<Vertex>& aggregates,
Vector& coarse, Vector& fine,
[[maybe_unused]] Vector& fineRedist,
T damp,
[[maybe_unused]] const SequentialInformation& comm,
[[maybe_unused]] const Redist& redist)
{
prolongateVector(aggregates, coarse, fine, damp);
}
template<class V, class V1>
template<typename T>
inline void
Transfer<V,V1,SequentialInformation>::prolongateVector(const AggregatesMap<Vertex>& aggregates,
Vector& coarse, Vector& fine,
T damp,
[[maybe_unused]] const SequentialInformation& comm)
{
typedef typename Vector::iterator Iterator;
Iterator end = coarse.end();
Iterator begin= coarse.begin();
for(; begin!=end; ++begin)
*begin*=damp;
end=fine.end();
begin=fine.begin();
for(Iterator block=begin; block != end; ++block) {
std::ptrdiff_t index=block-begin;
const Vertex& vertex = aggregates[index];
if(vertex != AggregatesMap<Vertex>::ISOLATED)
*block += coarse[aggregates[index]];
}
}
template<class V, class V1>
inline void
Transfer<V,V1,SequentialInformation>::restrictVector(const AggregatesMap<Vertex>& aggregates,
Vector& coarse,
const Vector& fine,
[[maybe_unused]] const SequentialInformation& comm)
{
// Set coarse vector to zero
coarse=0;
typedef typename Vector::const_iterator Iterator;
Iterator end = fine.end();
Iterator begin=fine.begin();
for(Iterator block=begin; block != end; ++block) {
const Vertex& vertex = aggregates[block-begin];
if(vertex != AggregatesMap<Vertex>::ISOLATED)
coarse[vertex] += *block;
}
}
#if HAVE_MPI
template<class V, class V1, class T1, class T2>
template<typename T3>
inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::prolongateVector(const AggregatesMap<Vertex>& aggregates,
Vector& coarse, Vector& fine,
Vector& fineRedist, T3 damp,
OwnerOverlapCopyCommunication<T1,T2>& comm,
const Redist& redist)
{
if(fineRedist.size()>0)
// we operated on the coarse level
Transfer<V,V1,SequentialInformation>::prolongateVector(aggregates, coarse, fineRedist, damp);
// TODO This could be accomplished with one communication, too!
redist.redistributeBackward(fine, fineRedist);
comm.copyOwnerToAll(fine,fine);
}
template<class V, class V1, class T1, class T2>
template<typename T3>
inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::prolongateVector(
const AggregatesMap<Vertex>& aggregates,
Vector& coarse, Vector& fine, T3 damp,
[[maybe_unused]] OwnerOverlapCopyCommunication<T1,T2>& comm)
{
Transfer<V,V1,SequentialInformation>::prolongateVector(aggregates, coarse, fine, damp);
}
template<class V, class V1, class T1, class T2>
inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::restrictVector(const AggregatesMap<Vertex>& aggregates,
Vector& coarse, const Vector& fine,
OwnerOverlapCopyCommunication<T1,T2>& comm)
{
Transfer<V,V1,SequentialInformation>::restrictVector(aggregates, coarse, fine, SequentialInformation());
// We need this here to avoid it in the smoothers on the coarse level.
// There (in the preconditioner d is const.
comm.project(coarse);
}
#endif
} // namspace Amg
} // namspace Dune
#endif
owneroverlapcopy.hh
Classes providing communication interfaces for overlapping Schwarz methods.
matrixredistribute.hh
Functionality for redistributing a sparse matrix.
pinfo.hh
aggregates.hh
Provides classes for the Coloring process of AMG.
bvector.hh
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Dune::Amg::Transfer< V, V1, OwnerOverlapCopyCommunication< T1, T2 > >::restrictVector
static void restrictVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, const Vector &fine, OwnerOverlapCopyCommunication< T1, T2 > &comm)
Definition transfer.hh:181
Dune::Amg::AggregatesMap::ISOLATED
static const V ISOLATED
Identifier of isolated vertices.
Definition aggregates.hh:577
Dune::Amg::Transfer< V, V1, OwnerOverlapCopyCommunication< T1, T2 > >::prolongateVector
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T3 damp, OwnerOverlapCopyCommunication< T1, T2 > &comm, const Redist &redist)
Definition transfer.hh:156
Dune
Definition allocator.hh:11
Dune::Amg
Definition novlpschwarz.hh:256
Dune::RedistributeInformation
Definition matrixredistribute.hh:22
Dune::RedistributeInformation::redistributeBackward
void redistributeBackward(D &from, const D &to) const
Definition matrixredistribute.hh:32
Dune::OwnerOverlapCopyCommunication
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition owneroverlapcopy.hh:174
Dune::OwnerOverlapCopyCommunication::project
void project(T1 &x) const
Set vector to zero at copy dofs.
Definition owneroverlapcopy.hh:538
Dune::OwnerOverlapCopyCommunication::copyOwnerToAll
void copyOwnerToAll(const T &source, T &dest) const
Communicate values from owner data points to all other data points.
Definition owneroverlapcopy.hh:311
Dune::Amg::AggregatesMap
Class providing information about the mapping of the vertices onto aggregates.
Definition aggregates.hh:566
Dune::Amg::SequentialInformation
Definition pinfo.hh:28
Dune::Amg::Transfer
Definition transfer.hh:32
Dune::Amg::Transfer::restrictVector
static void restrictVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, const Vector &fine, T &comm)
Dune::Amg::Transfer::prolongateVector
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, T1 damp)
Dune::Amg::Transfer::prolongateVector
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, R &redistributor=R())
Dune::Amg::Transfer::Vertex
V1 Vertex
Definition transfer.hh:35
Dune::Amg::Transfer::Vector
V2 Vector
Definition transfer.hh:36
Dune::Amg::Transfer< V, V1, SequentialInformation >::Redist
RedistributeInformation< SequentialInformation > Redist
Definition transfer.hh:56
Dune::Amg::Transfer< V, V1, SequentialInformation >::Vertex
V Vertex
Definition transfer.hh:54
Dune::Amg::Transfer< V, V1, SequentialInformation >::Vector
V1 Vector
Definition transfer.hh:55
Dune::Amg::Transfer< V, V1, SequentialInformation >::prolongateVector
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, const SequentialInformation &comm=SequentialInformation(), const Redist &redist=Redist())
Dune::Amg::Transfer< V, V1, SequentialInformation >::prolongateVector
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, T1 damp, const SequentialInformation &comm=SequentialInformation())
Dune::Amg::Transfer< V, V1, OwnerOverlapCopyCommunication< T1, T2 > >::Vertex
V Vertex
Definition transfer.hh:78
Dune::Amg::Transfer< V, V1, OwnerOverlapCopyCommunication< T1, T2 > >::Redist
RedistributeInformation< OwnerOverlapCopyCommunication< T1, T2 > > Redist
Definition transfer.hh:80
Dune::Amg::Transfer< V, V1, OwnerOverlapCopyCommunication< T1, T2 > >::Vector
V1 Vector
Definition transfer.hh:79