From: guido Date: Mon, 3 Jul 2006 07:57:23 +0000 (+0000) Subject: new functions for multigrid boundaries X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8af9d0e135f461d431f3236b14af343b545c819a;p=dealii-svn.git new functions for multigrid boundaries git-svn-id: https://svn.dealii.org/trunk@13324 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/multigrid/mg_tools.all_dimensions.cc b/deal.II/deal.II/source/multigrid/mg_tools.all_dimensions.cc new file mode 100644 index 0000000000..d11b7bd1c5 --- /dev/null +++ b/deal.II/deal.II/source/multigrid/mg_tools.all_dimensions.cc @@ -0,0 +1,445 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// +// This file is subject to QPL and may not be distributed +// without copyright and license information. Please refer +// to the file deal.II/doc/license.html for the text and +// further information on this license. +// +//--------------------------------------------------------------------------- + + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + + +template +void +MGTools::apply_boundary_values ( + const std::vector &boundary_values, + SparseMatrix& matrix, + const bool preserve_symmetry) +{ + // if no boundary values are to be applied + // simply return + if (boundary_values.size() == 0) + return; + + + const unsigned int n_dofs = matrix.m(); + + // if a diagonal entry is zero + // later, then we use another + // number instead. take it to be + // the first nonzero diagonal + // element of the matrix, or 1 if + // there is no such thing + number first_nonzero_diagonal_entry = 1; + for (unsigned int i=0; i::const_iterator dof = boundary_values.begin(), + endd = boundary_values.end(); + const SparsityPattern &sparsity = matrix.get_sparsity_pattern(); + const unsigned int *sparsity_rowstart = sparsity.get_rowstart_indices(); + const unsigned int *sparsity_colnums = sparsity.get_column_numbers(); + for (; dof != endd; ++dof) + { + Assert (*dof < n_dofs, ExcInternalError()); + + const unsigned int dof_number = *dof; + // for each boundary dof: + + // set entries of this line + // to zero except for the diagonal + // entry. Note that the diagonal + // entry is always the first one + // for square matrices, i.e. + // we shall not set + // matrix.global_entry( + // sparsity_rowstart[dof.first]) + const unsigned int last = sparsity_rowstart[dof_number+1]; + for (unsigned int j=sparsity_rowstart[dof_number]+1; j +void +MGTools::apply_boundary_values ( + const std::vector& boundary_values, + BlockSparseMatrix& matrix, + const bool preserve_symmetry) +{ + const unsigned int blocks = matrix.n_block_rows(); + + Assert (matrix.n_block_rows() == matrix.n_block_cols(), + ExcNotQuadratic()); + Assert (matrix.get_sparsity_pattern().get_row_indices() == + matrix.get_sparsity_pattern().get_column_indices(), + ExcNotQuadratic()); + + for (unsigned int i=0; i::const_iterator dof = boundary_values.begin(), + endd = boundary_values.end(); + const BlockSparsityPattern & + sparsity_pattern = matrix.get_sparsity_pattern(); + + // pointer to the mapping between + // global and block indices. since + // the row and column mappings are + // equal, store a pointer on only + // one of them + const BlockIndices & + index_mapping = sparsity_pattern.get_column_indices(); + + // now loop over all boundary dofs + for (; dof != endd; ++dof) + { + Assert (*dof < n_dofs, ExcInternalError()); + + // get global index and index + // in the block in which this + // dof is located + const unsigned int dof_number = *dof; + const std::pair + block_index = index_mapping.global_to_local (dof_number); + + // for each boundary dof: + + // set entries of this line + // to zero except for the diagonal + // entry. Note that the diagonal + // entry is always the first one + // for square matrices, i.e. + // we shall not set + // matrix.global_entry( + // sparsity_rowstart[dof.first]) + // of the diagonal block + for (unsigned int block_col=0; block_col& boundary_values, + SparseMatrix& matrix, + const bool preserve_symmetry); +template void MGTools::apply_boundary_values ( + const std::vector& boundary_values, + SparseMatrix& matrix, + const bool preserve_symmetry); +template void MGTools::apply_boundary_values ( + const std::vector& boundary_values, + BlockSparseMatrix& matrix, + const bool preserve_symmetry); +template void MGTools::apply_boundary_values ( + const std::vector& boundary_values, + BlockSparseMatrix& matrix, + const bool preserve_symmetry);