"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "dune/istl/paamg/test/anisotropic.hh" between
dune-istl-2.6.0.tar.gz and dune-istl-2.7.0.tar.gz

About: dune-istl - DUNE (Distributed and Unified Numerics Environment) is a modular toolbox for solving partial differential equations (PDEs) with grid-based methods: DUNE Iterative Solver Template Library.

anisotropic.hh  (dune-istl-2.6.0):anisotropic.hh  (dune-istl-2.7.0)
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2: // vi: set et ts=4 sw=2 sts=2:
#ifndef ANISOTROPIC_HH #ifndef ANISOTROPIC_HH
#define ANISOTROPIC_HH #define ANISOTROPIC_HH
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
#include <dune/common/unused.hh> #include <dune/common/unused.hh>
#include <dune/common/parallel/indexset.hh> #include <dune/common/parallel/indexset.hh>
#include <dune/common/parallel/plocalindex.hh> #include <dune/common/parallel/plocalindex.hh>
#include <dune/common/parallel/collectivecommunication.hh> #include <dune/common/parallel/communication.hh>
#include <dune/common/scalarmatrixview.hh>
#include <dune/istl/bcrsmatrix.hh> #include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/owneroverlapcopy.hh> #include <dune/istl/owneroverlapcopy.hh>
typedef Dune::OwnerOverlapCopyAttributeSet GridAttributes; typedef Dune::OwnerOverlapCopyAttributeSet GridAttributes;
typedef GridAttributes::AttributeSet GridFlag; typedef GridAttributes::AttributeSet GridFlag;
typedef Dune::ParallelLocalIndex<GridFlag> LocalIndex; typedef Dune::ParallelLocalIndex<GridFlag> LocalIndex;
template<class M, class G, class L, int n> template<class M, class G, class L, int n>
void setupPattern(int N, M& mat, Dune::ParallelIndexSet<G,L,n>& indices, int ove rlapStart, int overlapEnd, void setupPattern(int N, M& mat, Dune::ParallelIndexSet<G,L,n>& indices, int ove rlapStart, int overlapEnd,
int start, int end); int start, int end);
template<class M> template<class M>
void fillValues(int N, M& mat, int overlapStart, int overlapEnd, int start, int end); void fillValues(int N, M& mat, int overlapStart, int overlapEnd, int start, int end);
template<class M, class G, class L, class C, int n>
M setupAnisotropic2d(int N, Dune::ParallelIndexSet<G,L,n>& indices,
const Dune::CollectiveCommunication<C>& p, int *nout, typen
ame M::block_type::value_type eps=1.0);
template<class M, class G, class L, int s> template<class M, class G, class L, int s>
void setupPattern(int N, M& mat, Dune::ParallelIndexSet<G,L,s>& indices, int ove rlapStart, int overlapEnd, void setupPattern(int N, M& mat, Dune::ParallelIndexSet<G,L,s>& indices, int ove rlapStart, int overlapEnd,
int start, int end) int start, int end)
{ {
int n = overlapEnd - overlapStart; int n = overlapEnd - overlapStart;
typename M::CreateIterator iter = mat.createbegin(); typename M::CreateIterator iter = mat.createbegin();
indices.beginResize(); indices.beginResize();
for(int j=0; j < N; j++) for(int j=0; j < N; j++)
skipping to change at line 83 skipping to change at line 80
indices.endResize(); indices.endResize();
} }
template<class M, class T> template<class M, class T>
void fillValues(int N, M& mat, int overlapStart, int overlapEnd, int start, int end, T eps) void fillValues(int N, M& mat, int overlapStart, int overlapEnd, int start, int end, T eps)
{ {
DUNE_UNUSED_PARAMETER(N); DUNE_UNUSED_PARAMETER(N);
typedef typename M::block_type Block; typedef typename M::block_type Block;
Block dval(0), bone(0), bmone(0), beps(0); Block dval(0), bone(0), bmone(0), beps(0);
for(typename Block::RowIterator b = dval.begin(); b != dval.end(); ++b) auto setDiagonal = [](auto&& scalarOrMatrix, const auto& value) {
b->operator[](b.index())=2.0+2.0*eps; auto&& matrix = Dune::Impl::asMatrix(scalarOrMatrix);
for (auto rowIt = matrix.begin(); rowIt != matrix.end(); ++rowIt)
for(typename Block::RowIterator b=bone.begin(); b != bone.end(); ++b) (*rowIt)[rowIt.index()] = value;
b->operator[](b.index())=1.0; };
for(typename Block::RowIterator b=bmone.begin(); b != bmone.end(); ++b) setDiagonal(dval, 2.0+2.0*eps);
b->operator[](b.index())=-1.0; setDiagonal(bone, 1.0);
setDiagonal(bmone, -1.0);
for(typename Block::RowIterator b=beps.begin(); b != beps.end(); ++b) setDiagonal(beps, -eps);
b->operator[](b.index())=-eps;
int n = overlapEnd-overlapStart; int n = overlapEnd-overlapStart;
typedef typename M::ColIterator ColIterator; typedef typename M::ColIterator ColIterator;
typedef typename M::RowIterator RowIterator; typedef typename M::RowIterator RowIterator;
for (RowIterator i = mat.begin(); i != mat.end(); ++i) { for (RowIterator i = mat.begin(); i != mat.end(); ++i) {
// calculate coordinate // calculate coordinate
int y = i.index() / n; int y = i.index() / n;
int x = overlapStart + i.index() - y * n; int x = overlapStart + i.index() - y * n;
skipping to change at line 153 skipping to change at line 149
template<class V, class G> template<class V, class G>
void setBoundary(V& lhs, V& rhs, const G& N) void setBoundary(V& lhs, V& rhs, const G& N)
{ {
for(int j=0; j < N; ++j) for(int j=0; j < N; ++j)
for(int i=0; i < N; i++) for(int i=0; i < N; i++)
if(i==0 || j ==0 || i==N-1 || j==N-1) if(i==0 || j ==0 || i==N-1 || j==N-1)
lhs[j*N+i]=rhs[j*N+i]=0; lhs[j*N+i]=rhs[j*N+i]=0;
} }
template<class M, class G, class L, class C, int s> /**
M setupAnisotropic2d(int N, Dune::ParallelIndexSet<G,L,s>& indices, const Dune:: * \tparam M A matrix type
CollectiveCommunication<C>& p, int *nout, typename M::block_type::value_type eps */
) template<class MatrixEntry, class G, class L, class C, int s>
Dune::BCRSMatrix<MatrixEntry> setupAnisotropic2d(int N, Dune::ParallelIndexSet<G
,L,s>& indices, const Dune::CollectiveCommunication<C>& p, int *nout, typename D
une::BCRSMatrix<MatrixEntry>::field_type eps=1.0)
{ {
int procs=p.size(), rank=p.rank(); int procs=p.size(), rank=p.rank();
typedef M BCRSMat; using BCRSMat = Dune::BCRSMatrix<MatrixEntry>;
// calculate size of local matrix in the distributed direction // calculate size of local matrix in the distributed direction
int start, end, overlapStart, overlapEnd; int start, end, overlapStart, overlapEnd;
int n = N/procs; // number of unknowns per process int n = N/procs; // number of unknowns per process
int bigger = N%procs; // number of process with n+1 unknows int bigger = N%procs; // number of process with n+1 unknows
// Compute owner region // Compute owner region
if(rank<bigger) { if(rank<bigger) {
start = rank*(n+1); start = rank*(n+1);
 End of changes. 5 change blocks. 
22 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)