From 0c151fb53799990f1a70786fb2e9c65c2db50cf1 Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 9 Apr 1999 16:00:19 +0000 Subject: [PATCH] Initial version of the implementation of the smoother base class. git-svn-id: https://svn.dealii.org/trunk@1118 0785d39b-7218-0410-832d-ea1e28bc413d --- .../deal.II/source/multigrid/mg_smoother.cc | 102 ++++++++++++++++++ .../deal.II/source/numerics/mg_smoother.cc | 102 ++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 deal.II/deal.II/source/multigrid/mg_smoother.cc create mode 100644 deal.II/deal.II/source/numerics/mg_smoother.cc diff --git a/deal.II/deal.II/source/multigrid/mg_smoother.cc b/deal.II/deal.II/source/multigrid/mg_smoother.cc new file mode 100644 index 0000000000..de8813d523 --- /dev/null +++ b/deal.II/deal.II/source/multigrid/mg_smoother.cc @@ -0,0 +1,102 @@ +/* $Id$ */ + +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +MGSmoother::MGSmoother (const MGDoFHandler &mg_dof) +{ + const unsigned int n_levels = mg_dof.get_tria().n_levels(); + + // allocate the right number of + // elements + interior_boundary_dofs.resize (n_levels-1); + + // use a temporary to store the + // indices. this allows to not allocate + // to much memory by later copying the + // content of this vector to its final + // destination + vector boundary_dofs; + + // temporary to hold the dof indices + // on a face between to levels + vector dofs_on_face (mg_dof.get_fe().dofs_per_face); + + for (unsigned int level=1; level::cell_iterator cell=mg_dof.begin(level); + cell != mg_dof.end(level); ++cell) + for (unsigned int face=0; face::faces_per_cell; ++face) + if ((cell->neighbor(face).state() == valid) && + (static_cast(cell->neighbor(face)->level()) + == level-1)) + { + // get indices of this face + cell->face(face)->get_mg_dof_indices (dofs_on_face); + // append them to the levelwise + // list + boundary_dofs.insert (boundary_dofs.end(), + dofs_on_face.begin(), + dofs_on_face.end()); + }; + + // now sort the list of interior boundary + // dofs and eliminate duplicates + sort (boundary_dofs.begin(), boundary_dofs.end()); + boundary_dofs.erase (unique (boundary_dofs.begin(), + boundary_dofs.end()), + boundary_dofs.end()); + + // now finally copy the result + // for this level its destination + interior_boundary_dofs[level-1] = boundary_dofs; + }; +}; + + + +void +MGSmoother::set_zero_interior_boundary (const unsigned int level, + Vector &u) const +{ + if (level==0) + return; + else + for (vector::const_iterator p=interior_boundary_dofs[level-1].begin(); + p!=interior_boundary_dofs[level-1].end(); ++p) + u(*p) = 0; +}; + + + + +void +MGSmoother::post_smooth (const unsigned int level, + Vector &u) const +{ + pre_smooth (level, u); +}; + + + + +// explicit instantiations +template MGSmoother::MGSmoother (const MGDoFHandler&); diff --git a/deal.II/deal.II/source/numerics/mg_smoother.cc b/deal.II/deal.II/source/numerics/mg_smoother.cc new file mode 100644 index 0000000000..de8813d523 --- /dev/null +++ b/deal.II/deal.II/source/numerics/mg_smoother.cc @@ -0,0 +1,102 @@ +/* $Id$ */ + +#include +#include +#include +#include +#include +#include +#include + +#include + + + + +template +MGSmoother::MGSmoother (const MGDoFHandler &mg_dof) +{ + const unsigned int n_levels = mg_dof.get_tria().n_levels(); + + // allocate the right number of + // elements + interior_boundary_dofs.resize (n_levels-1); + + // use a temporary to store the + // indices. this allows to not allocate + // to much memory by later copying the + // content of this vector to its final + // destination + vector boundary_dofs; + + // temporary to hold the dof indices + // on a face between to levels + vector dofs_on_face (mg_dof.get_fe().dofs_per_face); + + for (unsigned int level=1; level::cell_iterator cell=mg_dof.begin(level); + cell != mg_dof.end(level); ++cell) + for (unsigned int face=0; face::faces_per_cell; ++face) + if ((cell->neighbor(face).state() == valid) && + (static_cast(cell->neighbor(face)->level()) + == level-1)) + { + // get indices of this face + cell->face(face)->get_mg_dof_indices (dofs_on_face); + // append them to the levelwise + // list + boundary_dofs.insert (boundary_dofs.end(), + dofs_on_face.begin(), + dofs_on_face.end()); + }; + + // now sort the list of interior boundary + // dofs and eliminate duplicates + sort (boundary_dofs.begin(), boundary_dofs.end()); + boundary_dofs.erase (unique (boundary_dofs.begin(), + boundary_dofs.end()), + boundary_dofs.end()); + + // now finally copy the result + // for this level its destination + interior_boundary_dofs[level-1] = boundary_dofs; + }; +}; + + + +void +MGSmoother::set_zero_interior_boundary (const unsigned int level, + Vector &u) const +{ + if (level==0) + return; + else + for (vector::const_iterator p=interior_boundary_dofs[level-1].begin(); + p!=interior_boundary_dofs[level-1].end(); ++p) + u(*p) = 0; +}; + + + + +void +MGSmoother::post_smooth (const unsigned int level, + Vector &u) const +{ + pre_smooth (level, u); +}; + + + + +// explicit instantiations +template MGSmoother::MGSmoother (const MGDoFHandler&); -- 2.39.5