#include <dofs/dof_handler.h>
#include <grid/tria.h>
#include <grid/grid_generator.h>
-#include <fe/fe_lib.lagrange.h>
+#include <fe/continuous.h>
#include <grid/tria_boundary.h>
#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
#include <lac/sparse_matrix.h>
#include <dofs/dof_constraints.h>
+#include <dofs/dof_accessor.h>
#include <numerics/dof_renumbering.h>
#include <dofs/dof_tools.h>
#include <base/logstream.h>
deallog << " Distributing degrees of freedom..." << endl;
- FEQ1<dim> fe;
+ FE_Q<dim> fe(1);
dof->distribute_dofs (fe);
deallog << " Renumbering degrees of freedom..." << endl;
#include "testmatrix.h"
#include <lac/sparse_matrix.h>
+#include <lac/vector.h>
FDMatrix::FDMatrix(unsigned int nx, unsigned int ny)
:
s << endl;
}
-FDMGTransfer::FDMGTransfer(unsigned int nx, unsigned int ny,
- unsigned int nlevels)
- :
- structures(nlevels), matrices(nlevels)
-{
- unsigned int power = 1 << nlevels;
-
- Assert ((nx%power)==0, ExcDivide(nx,power));
- Assert ((ny%power)==0, ExcDivide(ny,power));
-
- nx /= power;
- ny /= power;
-
- for (unsigned int level = 0; level < nlevels; ++ level)
- {
- build_matrix(nx,ny,structures[level],matrices[level]);
- nx *= 2;
- ny *= 2;
- }
-}
-
-void
-FDMGTransfer::build_matrix(unsigned int nx, unsigned int ny,
- SparsityPattern& structure, SparseMatrix<double>& matrix)
-{
- structure.reinit((nx-1)*(ny-1),(2*nx-1)*(2*ny-1),9);
-
- // Traverse all points of coarse grid
- for (unsigned int i=1 ; i<ny; ++i)
- for (unsigned int j=1 ; j<nx; ++j)
- {
- // coarse grid point number
- unsigned int ncoarse =j+(nx-1)*i -(nx-1) -1;
- // same point on fine grid
- unsigned int nfine = 2*j+(4*nx-2)*i -(2*nx-1) -1;
-
- structure.add(ncoarse,nfine);
- // left
- if (j>0)
- {
- structure.add(ncoarse,nfine-1);
- // lower left
- if (i>0)
- structure.add(ncoarse,nfine-(2*nx-1)-1);
- // upper left
- if (i<ny)
- structure.add(ncoarse,nfine+(2*nx-1)-1);
- }
- // right
- if (j<nx)
- {
- structure.add(ncoarse, nfine+1);
- // lower right
- if (i>0)
- structure.add(ncoarse,nfine-(2*nx-1)+1);
- // upper right
- if (i<ny)
- structure.add(ncoarse,nfine+(2*nx-1)+1);
- }
-
- // lower
- if (i>0)
- structure.add(ncoarse,nfine-(2*nx-1));
- // upper
- if (i<ny)
- structure.add(ncoarse,nfine+(2*nx-1));
- }
-
- structure.compress();
- matrix.reinit(structure);
-
- for (unsigned int i=1 ; i<ny; ++i)
- for (unsigned int j=1 ; j<nx; ++j)
- {
- // coarse grid point number
- unsigned int ncoarse =j+(nx-1)*i -(nx-1) -1;
- // same point on fine grid
- unsigned int nfine =2*j+(4*nx-2)*i -(2*nx-1) -1;
-
- matrix.set(ncoarse,nfine,1.);
- // left
- if (j>0)
- {
- matrix.set(ncoarse,nfine-1,.5);
- // lower left
- if (i>0)
- matrix.set(ncoarse,nfine-(2*nx-1)-1,.25);
- // upper left
- if (i<ny)
- matrix.set(ncoarse,nfine+(2*nx-1)-1,.25);
- }
- // right
- if (j<nx)
- {
- matrix.set(ncoarse,nfine+1,.5);
- // lower right
- if (i>0)
- matrix.set(ncoarse,nfine-(2*nx-1)+1,.25);
- // upper right
- if (i<ny)
- matrix.set(ncoarse,nfine+(2*nx-1)+1,.25);
- }
-
- // lower
- if (i>0)
- matrix.set(ncoarse,nfine-(2*nx-1),.5);
- // upper
- if (i<ny)
- matrix.set(ncoarse,nfine+(2*nx-1),.5);
- }
-
-}
-
-void
-FDMGTransfer::prolongate (const unsigned int to_level,
- Vector<double> &dst,
- const Vector<double> &src) const
-{
- Assert((to_level>0) && (to_level<=matrices.size()),
- ExcIndexRange(to_level, 0, matrices.size()+1));
-
- matrices[to_level-1].Tvmult(dst,src);
-}
-
-
-void
-FDMGTransfer::restrict_and_add (const unsigned int from_level,
- Vector<double> &dst,
- const Vector<double> &src) const
-{
- Assert((from_level>0) && (from_level<=matrices.size()),
- ExcIndexRange(from_level, 0, matrices.size()+1));
-
- matrices[from_level-1].vmult(dst,src);
-}
template void FDMatrix::laplacian(SparseMatrix<long double>&) const;
// $Id$
#include <base/exceptions.h>
-#include <multigrid/mg_base.h>
#include <lac/forward_declarations.h>
/**
unsigned int ny;
};
-/**
- * Grid transfer for finite differences on uniform grid.
- */
-
-class FDMGTransfer
- :
- public MGTransferBase
-{
- public:
- /**
- * Constructor. Prepares grid
- * transfer matrices for #nlevels#
- * levels on an #nx# times #ny#
- * grid.
- */
- FDMGTransfer(unsigned int nx, unsigned int ny,
- unsigned int nlevels);
-
- /**
- * Implementation of abstract
- * function in #MGTranferBase#.
- */
- virtual void prolongate (const unsigned int to_level,
- Vector<double> &dst,
- const Vector<double> &src) const;
-
- /**
- * Implementation of abstract
- * function in #MGTranferBase#.
- */
- virtual void restrict_and_add (const unsigned int from_level,
- Vector<double> &dst,
- const Vector<double> &src) const;
-
- /**
- * Exception.
- */
- DeclException2(ExcDivide, unsigned int, unsigned int,
- << "Cannot divide " << arg1 << " by " << arg2);
-
- private:
- /**
- * Prolongation matrix structures.
- */
- vector<SparsityPattern> structures;
- /**
- * Prolongation matrices.
- */
- vector<SparseMatrix<double> > matrices;
-
- /**
- * Matrix generator.
- * The arguments #nx# and #ny#
- * are the numbers on the COARSE level.
- * Builds a transfer matrix from
- * fine to coarse (#vmult#).
- */
- void build_matrix(unsigned int nx, unsigned int ny,
- SparsityPattern&, SparseMatrix<double>&);
-};