Skip to content
Snippets Groups Projects
Commit aa6257bf authored by Markus Blatt's avatar Markus Blatt
Browse files

Added test for transfer.

[[Imported from SVN: r343]]
parent f45c973a
Branches
Tags
No related merge requests found
......@@ -6,4 +6,5 @@ semantic.cache
graphtest
galerkintest
hierarchytest
amgtest
\ No newline at end of file
amgtest
transfertest
\ No newline at end of file
......@@ -6,7 +6,8 @@
TESTRUNS = run-galerkin run-hierarchy run-amg
#endif
NORMALTESTS = $(MPITESTS)
NORMALTESTS = transfertest $(MPITESTS)
# which tests to run
TESTS = $(NORMALTESTS) $(TESTRUNS)
......@@ -17,6 +18,8 @@ check_PROGRAMS = $(TESTPROGS) $(NORMALTESTS)
graphtest_SOURCES = graphtest.cc
transfertest_SOURCES = transfertest.cc
galerkintest_SOURCES = galerkintest.cc anisotropic.hh
galerkintest_CXXFLAGS = $(MPI_CPPFLAGS)
galerkintest_LDFLAGS = $(MPI_LDFLAGS) $(MPI_LIBS)
......@@ -29,4 +32,5 @@ hierarchytest_LDFLAGS = $(MPI_LDFLAGS) $(MPI_LIBS)
amgtest_SOURCES = amgtest.cc
amgtest_CXXFLAGS = $(MPI_CPPFLAGS)
amgtest_LDFLAGS = $(MPI_LDFLAGS) $(MPI_LIBS)
include $(top_srcdir)/am/global-rules
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#include "config.h"
#include <dune/istl/bvector.hh>
#include <dune/common/fvector.hh>
#include <dune/istl/paamg/aggregates.hh>
#include <dune/istl/paamg/transfer.hh>
template<class Vertex>
int createAggregates(Dune::Amg::AggregatesMap<Vertex>& aggregates, int size)
{
int index=0;
int i=0;
for(i=1; index<size; ++i)
for(int j=0; j < i && index < size; ++j, ++index)
aggregates[index]=i-1;
return i-1;
}
int main()
{
const int BS=1;
typedef Dune::FieldVector<int,BS> VectorBlock;
typedef Dune::BlockVector<VectorBlock> Vector;
Vector b(20);
Dune::Amg::AggregatesMap<int> amap(20);
int aggregates = createAggregates(amap, 20);
Vector c(aggregates);
b=100;
Dune::Amg::Transfer<int,Vector>::restrict (amap, c, b);
Dune::Amg::Transfer<int,Vector>::prolongate(amap, c, b, 1);
return 0;
}
......@@ -28,20 +28,20 @@ namespace Dune
typedef V1 Vertex;
typedef V2 Vector;
static void prolongate(const AggregatesMap<Vertex>& aggregates, const Vector & coarse, Vector fine,
static void prolongate(const AggregatesMap<Vertex>& aggregates, const Vector & coarse, Vector& fine,
typename Vector::field_type damp);
static void restrict (const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector fine);
static void restrict (const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector & fine);
};
template<class V1, class V2>
void Transfer<V1,V2>::prolongate(const AggregatesMap<Vertex>& aggregates, const Vector& coarse,
Vector fine, typename Vector::field_type damp)
Vector& fine, typename Vector::field_type damp)
{
DUNE_THROW(NotImplemented, "There is no secialization available for this type of vector!");
}
template<class V1, class V2>
void Transfer<V1,V2>::restrict (const AggregatesMap<Vertex>& aggregates, Vector& coarse,
const Vector fine)
const Vector & fine)
{
DUNE_THROW(NotImplemented, "There is no secialization available for this type of vector!");
}
......@@ -52,15 +52,15 @@ namespace Dune
public:
typedef V Vertex;
typedef BlockVector<B> Vector;
static void prolongate(const AggregatesMap<Vertex>& aggregates, const Vector & coarse, Vector fine,
static void prolongate(const AggregatesMap<Vertex>& aggregates, const Vector & coarse, Vector& fine,
typename Vector::field_type damp);
static void restrict (const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector fine);
static void restrict (const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector & fine);
};
template<class V, class B>
inline void Transfer<V,BlockVector<B> >::prolongate(const AggregatesMap<Vertex>& aggregates,
const Vector& coarse, Vector fine,
const Vector& coarse, Vector& fine,
typename Vector::field_type damp)
{
typedef typename Vector::iterator Iterator;
......@@ -69,14 +69,14 @@ namespace Dune
for(Iterator block=fine.begin(); block != end; ++block) {
*block = coarse[aggregates[block.index()]];
*block *= damp;
//*block *= damp;
}
}
template<class V, class B>
inline void Transfer<V,BlockVector<B> >::restrict (const AggregatesMap<Vertex>& aggregates,
Vector& coarse,
const Vector fine)
const Vector & fine)
{
// Set coarse vector to zero
coarse=0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment