From: guido Date: Fri, 30 May 2003 20:33:43 +0000 (+0000) Subject: instantiations of MGTransfer functions X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=922991b2bcdb7801cea37ab9597f3ed28031139a;p=dealii-svn.git instantiations of MGTransfer functions git-svn-id: https://svn.dealii.org/trunk@7698 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_block.cc b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc new file mode 100644 index 0000000000..bd83460beb --- /dev/null +++ b/deal.II/deal.II/source/multigrid/mg_transfer_block.cc @@ -0,0 +1,423 @@ +//----------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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 +#include +#include +#include +#include + +template +void MGTransferBlockBase::build_matrices ( + const MGDoFHandler &mg_dof, + std::vector select) +{ + const FiniteElement& fe = mg_dof.get_fe(); + const unsigned int n_components = fe.n_components(); + const unsigned int dofs_per_cell = fe.dofs_per_cell; + const unsigned int n_levels = mg_dof.get_tria().n_levels(); + + selected = select; + + Assert (selected.size() == n_components, + ExcDimensionMismatch(selected.size(), n_components)) + + sizes.resize(n_levels); + MGTools::count_dofs_per_component(mg_dof, sizes); + + // reset the size of the array of + // matrices. call resize(0) first, + // in order to delete all elements + // and clear their memory. then + // repopulate these arrays + // + // note that on resize(0), the + // shared_ptr class takes care of + // deleting the object it points to + // by itself + prolongation_matrices.resize (0); +#ifndef DEAL_PREFER_MATRIX_EZ + prolongation_sparsities.resize (0); +#endif + + for (unsigned int i=0; i (new BlockSparsityPattern)); + prolongation_matrices + .push_back (boost::shared_ptr > (new BlockSparseMatrix)); +#else + prolongation_matrices + .push_back (boost::shared_ptr > (new BlockSparseMatrixEZ)); +#endif + } + + // two fields which will store the + // indices of the multigrid dofs + // for a cell and one of its children + std::vector dof_indices_parent (dofs_per_cell); + std::vector dof_indices_child (dofs_per_cell); + + // for each level: first build the + // sparsity pattern of the matrices + // and then build the matrices + // themselves. note that we only + // need to take care of cells on + // the coarser level which have + // children + for (unsigned int level=0; levelreinit (n_components, n_components); + for (unsigned int i=0;iblock(i,j) + .reinit(sizes[level+1][i], + sizes[level][j], dofs_per_cell, 0); + else + prolongation_matrices[level]->block(i,j) + .reinit(sizes[level+1][i], + sizes[level][j], 0); + prolongation_matrices[level]->collect_sizes(); +#else + prolongation_sparsities[level]->reinit (n_components, n_components); + for (unsigned int i=0; iblock(i,j) + .reinit(sizes[level+1][i], + sizes[level][j], +//TODO:[GK] Split this by component to save memory + dofs_per_cell+1); + else + prolongation_sparsities[level]->block(i,j) + .reinit(sizes[level+1][i], + sizes[level][j], + 0); + + prolongation_sparsities[level]->collect_sizes(); + + for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); + cell != mg_dof.end(level); ++cell) + if (cell->has_children()) + { + cell->get_mg_dof_indices (dof_indices_parent); + + for (unsigned int child=0; + child::children_per_cell; ++child) + { + // set an alias to the + // prolongation matrix for + // this child + const FullMatrix &prolongation + = mg_dof.get_fe().prolongate(child); + + cell->child(child)->get_mg_dof_indices (dof_indices_child); + + // now tag the entries in the + // matrix which will be used + // for this pair of parent/child + for (unsigned int i=0; iadd(dof_indices_child[i], + dof_indices_parent[j]); + }; + }; + }; + prolongation_sparsities[level]->compress (); + + prolongation_matrices[level]->reinit (*prolongation_sparsities[level]); +#endif + // now actually build the matrices + for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); + cell != mg_dof.end(level); ++cell) + if (cell->has_children()) + { + cell->get_mg_dof_indices (dof_indices_parent); + + for (unsigned int child=0; + child::children_per_cell; ++child) + { + // set an alias to the + // prolongation matrix for + // this child + const FullMatrix &prolongation + = mg_dof.get_fe().prolongate(child); + + cell->child(child)->get_mg_dof_indices (dof_indices_child); + + // now set the entries in the + // matrix + for (unsigned int i=0; iset(dof_indices_child[i], + dof_indices_parent[j], + prolongation(i,j)); + }; + }; + }; + }; + // Finally, fill some index vectors + // for later use. + mg_component_start = sizes; + // Compute start indices from sizes + for (unsigned int l=0;lblock(i,j).print_statistics(deallog,true); + } + deallog.pop(); +#endif +} + + +template +template +void MGTransferBlock::build_matrices ( + const MGDoFHandler &mg_dof, + std::vector select) +{ + if (select.size() == 0) + select = std::vector (mg_dof.get_fe().n_components(), true); + + MGTransferBlockBase::build_matrices (mg_dof, select); +} + + +template +template +void MGTransferSelect::build_matrices ( + const MGDoFHandler &mg_dof, + unsigned int select) +{ + selected = select; + std::vector s(mg_dof.get_fe().n_components(), false); + s[select] = true; + + MGTransferBlockBase::build_matrices (mg_dof, s); +} + + + +// explicit instantiations + +template +void MGTransferBlock::build_matrices +(const MGDoFHandler &mg_dof, + std::vector); + +template +void MGTransferSelect::build_matrices +(const MGDoFHandler &mg_dof, + unsigned int); + +template +void MGTransferBlock::build_matrices +(const MGDoFHandler &mg_dof, + std::vector); + +template +void MGTransferSelect::build_matrices +(const MGDoFHandler &mg_dof, + unsigned int); + + +template void +MGTransferBlock::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferBlock::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferBlock::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferBlock::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferBlock::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferBlock::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferBlock::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferSelect::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferSelect::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + + + diff --git a/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc new file mode 100644 index 0000000000..2ece6ce2d0 --- /dev/null +++ b/deal.II/deal.II/source/multigrid/mg_transfer_prebuilt.cc @@ -0,0 +1,230 @@ +//----------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 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 +#include +#include +#include + + +template +template +void MGTransferPrebuilt::build_matrices ( + const MGDoFHandler &mg_dof) +{ + const unsigned int n_levels = mg_dof.get_tria().n_levels(); + const unsigned int dofs_per_cell = mg_dof.get_fe().dofs_per_cell; + + sizes.resize(n_levels); + for (unsigned int l=0;l (new SparsityPattern)); + prolongation_matrices + .push_back (boost::shared_ptr > (new SparseMatrix)); +#else + prolongation_matrices + .push_back (boost::shared_ptr > (new SparseMatrixEZ)); +#endif + } + + // two fields which will store the + // indices of the multigrid dofs + // for a cell and one of its children + std::vector dof_indices_parent (dofs_per_cell); + std::vector dof_indices_child (dofs_per_cell); + + // for each level: first build the sparsity + // pattern of the matrices and then build the + // matrices themselves. note that we only + // need to take care of cells on the coarser + // level which have children + for (unsigned int level=0; levelreinit (sizes[level+1], + sizes[level], + dofs_per_cell); +#else + // increment dofs_per_cell + // since a useless diagonal + // element will be stored + prolongation_sparsities[level]->reinit (sizes[level+1], + sizes[level], + dofs_per_cell+1); + + for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); + cell != mg_dof.end(level); ++cell) + if (cell->has_children()) + { + cell->get_mg_dof_indices (dof_indices_parent); + + for (unsigned int child=0; + child::children_per_cell; ++child) + { + // set an alias to the + // prolongation matrix for + // this child + const FullMatrix &prolongation + = mg_dof.get_fe().prolongate(child); + + Assert (prolongation.n() != 0, ExcNoProlongation()); + + cell->child(child)->get_mg_dof_indices (dof_indices_child); + + // now tag the entries in the + // matrix which will be used + // for this pair of parent/child + for (unsigned int i=0; iadd (dof_indices_child[i], + dof_indices_parent[j]); + }; + }; + }; + prolongation_sparsities[level]->compress (); + + prolongation_matrices[level]->reinit (*prolongation_sparsities[level]); +#endif + + // now actually build the matrices + for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); + cell != mg_dof.end(level); ++cell) + if (cell->has_children()) + { + cell->get_mg_dof_indices (dof_indices_parent); + + for (unsigned int child=0; + child::children_per_cell; ++child) + { + // set an alias to the + // prolongation matrix for + // this child + const FullMatrix &prolongation + = mg_dof.get_fe().prolongate(child); + + cell->child(child)->get_mg_dof_indices (dof_indices_child); + + // now set the entries in the + // matrix + for (unsigned int i=0; iset (dof_indices_child[i], + dof_indices_parent[j], + prolongation(i,j)); + }; + }; + }; +} + + + +template +void MGTransferPrebuilt::build_matrices +(const MGDoFHandler &mg_dof); + +template +void MGTransferPrebuilt::build_matrices +(const MGDoFHandler &mg_dof); + +template void +MGTransferPrebuilt::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferPrebuilt::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const Vector&) const; +template void +MGTransferPrebuilt::copy_to_mg ( + const MGDoFHandler&, + MGLevelObject >&, + const BlockVector&) const; +template void +MGTransferPrebuilt::copy_from_mg ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt::copy_from_mg ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; + +template void +MGTransferPrebuilt::copy_from_mg_add ( + const MGDoFHandler&, + Vector&, + const MGLevelObject >&) const; +template void +MGTransferPrebuilt::copy_from_mg_add ( + const MGDoFHandler&, + BlockVector&, + const MGLevelObject >&) const; diff --git a/deal.II/deal.II/source/multigrid/multigrid.cc b/deal.II/deal.II/source/multigrid/multigrid.cc index 01fa606dab..168105e845 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.cc @@ -26,423 +26,6 @@ #include #include -/* ----------------------------- MGTransferPrebuilt ------------------------ */ - - -template -template -void MGTransferPrebuilt::build_matrices ( - const MGDoFHandler &mg_dof) -{ - const unsigned int n_levels = mg_dof.get_tria().n_levels(); - const unsigned int dofs_per_cell = mg_dof.get_fe().dofs_per_cell; - - sizes.resize(n_levels); - for (unsigned int l=0;l (new SparsityPattern)); - prolongation_matrices - .push_back (boost::shared_ptr > (new SparseMatrix)); -#else - prolongation_matrices - .push_back (boost::shared_ptr > (new SparseMatrixEZ)); -#endif - } - - // two fields which will store the - // indices of the multigrid dofs - // for a cell and one of its children - std::vector dof_indices_parent (dofs_per_cell); - std::vector dof_indices_child (dofs_per_cell); - - // for each level: first build the sparsity - // pattern of the matrices and then build the - // matrices themselves. note that we only - // need to take care of cells on the coarser - // level which have children - for (unsigned int level=0; levelreinit (sizes[level+1], - sizes[level], - dofs_per_cell); -#else - // increment dofs_per_cell - // since a useless diagonal - // element will be stored - prolongation_sparsities[level]->reinit (sizes[level+1], - sizes[level], - dofs_per_cell+1); - - for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); - cell != mg_dof.end(level); ++cell) - if (cell->has_children()) - { - cell->get_mg_dof_indices (dof_indices_parent); - - for (unsigned int child=0; - child::children_per_cell; ++child) - { - // set an alias to the - // prolongation matrix for - // this child - const FullMatrix &prolongation - = mg_dof.get_fe().prolongate(child); - - Assert (prolongation.n() != 0, ExcNoProlongation()); - - cell->child(child)->get_mg_dof_indices (dof_indices_child); - - // now tag the entries in the - // matrix which will be used - // for this pair of parent/child - for (unsigned int i=0; iadd (dof_indices_child[i], - dof_indices_parent[j]); - }; - }; - }; - prolongation_sparsities[level]->compress (); - - prolongation_matrices[level]->reinit (*prolongation_sparsities[level]); -#endif - - // now actually build the matrices - for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); - cell != mg_dof.end(level); ++cell) - if (cell->has_children()) - { - cell->get_mg_dof_indices (dof_indices_parent); - - for (unsigned int child=0; - child::children_per_cell; ++child) - { - // set an alias to the - // prolongation matrix for - // this child - const FullMatrix &prolongation - = mg_dof.get_fe().prolongate(child); - - cell->child(child)->get_mg_dof_indices (dof_indices_child); - - // now set the entries in the - // matrix - for (unsigned int i=0; iset (dof_indices_child[i], - dof_indices_parent[j], - prolongation(i,j)); - }; - }; - }; -} - - /* ----------------------------- MGTransferBlock ------------------------ */ -template -void MGTransferBlockBase::build_matrices ( - const MGDoFHandler &mg_dof, - std::vector select) -{ - const FiniteElement& fe = mg_dof.get_fe(); - const unsigned int n_components = fe.n_components(); - const unsigned int dofs_per_cell = fe.dofs_per_cell; - const unsigned int n_levels = mg_dof.get_tria().n_levels(); - - selected = select; - - Assert (selected.size() == n_components, - ExcDimensionMismatch(selected.size(), n_components)) - - sizes.resize(n_levels); - MGTools::count_dofs_per_component(mg_dof, sizes); - - // reset the size of the array of - // matrices. call resize(0) first, - // in order to delete all elements - // and clear their memory. then - // repopulate these arrays - // - // note that on resize(0), the - // shared_ptr class takes care of - // deleting the object it points to - // by itself - prolongation_matrices.resize (0); -#ifndef DEAL_PREFER_MATRIX_EZ - prolongation_sparsities.resize (0); -#endif - - for (unsigned int i=0; i (new BlockSparsityPattern)); - prolongation_matrices - .push_back (boost::shared_ptr > (new BlockSparseMatrix)); -#else - prolongation_matrices - .push_back (boost::shared_ptr > (new BlockSparseMatrixEZ)); -#endif - } - - // two fields which will store the - // indices of the multigrid dofs - // for a cell and one of its children - std::vector dof_indices_parent (dofs_per_cell); - std::vector dof_indices_child (dofs_per_cell); - - // for each level: first build the - // sparsity pattern of the matrices - // and then build the matrices - // themselves. note that we only - // need to take care of cells on - // the coarser level which have - // children - for (unsigned int level=0; levelreinit (n_components, n_components); - for (unsigned int i=0;iblock(i,j) - .reinit(sizes[level+1][i], - sizes[level][j], dofs_per_cell, 0); - else - prolongation_matrices[level]->block(i,j) - .reinit(sizes[level+1][i], - sizes[level][j], 0); - prolongation_matrices[level]->collect_sizes(); -#else - prolongation_sparsities[level]->reinit (n_components, n_components); - for (unsigned int i=0; iblock(i,j) - .reinit(sizes[level+1][i], - sizes[level][j], -//TODO:[GK] Split this by component to save memory - dofs_per_cell+1); - else - prolongation_sparsities[level]->block(i,j) - .reinit(sizes[level+1][i], - sizes[level][j], - 0); - - prolongation_sparsities[level]->collect_sizes(); - - for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); - cell != mg_dof.end(level); ++cell) - if (cell->has_children()) - { - cell->get_mg_dof_indices (dof_indices_parent); - - for (unsigned int child=0; - child::children_per_cell; ++child) - { - // set an alias to the - // prolongation matrix for - // this child - const FullMatrix &prolongation - = mg_dof.get_fe().prolongate(child); - - cell->child(child)->get_mg_dof_indices (dof_indices_child); - - // now tag the entries in the - // matrix which will be used - // for this pair of parent/child - for (unsigned int i=0; iadd(dof_indices_child[i], - dof_indices_parent[j]); - }; - }; - }; - prolongation_sparsities[level]->compress (); - - prolongation_matrices[level]->reinit (*prolongation_sparsities[level]); -#endif - // now actually build the matrices - for (typename MGDoFHandler::cell_iterator cell=mg_dof.begin(level); - cell != mg_dof.end(level); ++cell) - if (cell->has_children()) - { - cell->get_mg_dof_indices (dof_indices_parent); - - for (unsigned int child=0; - child::children_per_cell; ++child) - { - // set an alias to the - // prolongation matrix for - // this child - const FullMatrix &prolongation - = mg_dof.get_fe().prolongate(child); - - cell->child(child)->get_mg_dof_indices (dof_indices_child); - - // now set the entries in the - // matrix - for (unsigned int i=0; iset(dof_indices_child[i], - dof_indices_parent[j], - prolongation(i,j)); - }; - }; - }; - }; - // Finally, fill some index vectors - // for later use. - mg_component_start = sizes; - // Compute start indices from sizes - for (unsigned int l=0;lblock(i,j).print_statistics(deallog,true); - } - deallog.pop(); -#endif -} - - -template -template -void MGTransferBlock::build_matrices ( - const MGDoFHandler &mg_dof, - std::vector select) -{ - if (select.size() == 0) - select = std::vector (mg_dof.get_fe().n_components(), true); - - MGTransferBlockBase::build_matrices (mg_dof, select); -} - - -template -template -void MGTransferSelect::build_matrices ( - const MGDoFHandler &mg_dof, - unsigned int select) -{ - selected = select; - std::vector s(mg_dof.get_fe().n_components(), false); - s[select] = true; - - MGTransferBlockBase::build_matrices (mg_dof, s); -} - - - -// explicit instatations - -template -void MGTransferPrebuilt::build_matrices -(const MGDoFHandler &mg_dof); - -template -void MGTransferBlock::build_matrices -(const MGDoFHandler &mg_dof, - std::vector); - -template -void MGTransferSelect::build_matrices -(const MGDoFHandler &mg_dof, - unsigned int); - -template -void MGTransferPrebuilt::build_matrices -(const MGDoFHandler &mg_dof); - -template -void MGTransferBlock::build_matrices -(const MGDoFHandler &mg_dof, - std::vector); - -template -void MGTransferSelect::build_matrices -(const MGDoFHandler &mg_dof, - unsigned int);