From 43e087de23eb38baa30243fade1ca282e76485af Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 26 Apr 2006 20:56:57 +0000 Subject: [PATCH] Move distribute_local_to_global from arbitrary accessors to cell accessors. git-svn-id: https://svn.dealii.org/trunk@12913 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/include/dofs/dof_accessor.h | 173 ++------ .../include/dofs/dof_accessor.templates.h | 388 +++++------------- deal.II/doc/news/changes.html | 13 + 3 files changed, 144 insertions(+), 430 deletions(-) diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index 56915ac1b4..226cbe2f59 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -466,41 +466,6 @@ class DoFObjectAccessor : public DoFAccessor, * access to the DoF data. */ TriaIterator > child (const unsigned int) const; - - /** - * Distribute a local (cell - * based) vector to a global one - * by mapping the local numbering - * of the degrees of freedom to - * the global one and entering - * the local values into the - * global vector. - * - * The elements are - * added up to the - * elements in the global vector, - * rather than just set, since - * this is usually what one - * wants. - */ - template - void - distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const; - - /** - * This function does much the same as - * the - * distribute_local_to_global(Vector,Vector) - * function, but operates on matrices - * instead of vectors. The sparse matrix - * is supposed to have non-zero entry - * slots where required. - */ - template - void - distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const; /** * Implement the copy operator needed @@ -785,39 +750,6 @@ class DoFObjectAccessor<1, DH> : * access to the DoF data. */ TriaIterator > child (const unsigned int) const; - - /** - * Distribute a local (cell based) vector - * to a global one by mapping the local - * numbering of the degrees of freedom to - * the global one and entering the local - * values into the global vector. - * - * The elements are - * added up to the - * elements in the global vector, - * rather than just set, since - * this is usually what one - * wants. - */ - template - void - distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const; - - /** - * This function does much the same as - * the - * distribute_local_to_global(Vector,Vector) - * function, but operates on matrices - * instead of vectors. The sparse matrix - * is supposed to have non-zero entry - * slots where required. - */ - template - void - distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const; /** * Implement the copy operator needed @@ -1056,39 +988,6 @@ class DoFObjectAccessor<2, DH> : */ TriaIterator > child (const unsigned int) const; - - /** - * Distribute a local (cell based) vector - * to a global one by mapping the local - * numbering of the degrees of freedom to - * the global one and entering the local - * values into the global vector. - * - * The elements are - * added up to the - * elements in the global vector, - * rather than just set, since - * this is usually what one - * wants. - */ - template - void - distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const; - - /** - * This function does much the same as - * the - * distribute_local_to_global(Vector,Vector) - * function, but operates on matrices - * instead of vectors. The sparse matrix - * is supposed to have non-zero entry - * slots where required. - */ - template - void - distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const; /** * Implement the copy operator needed @@ -1333,41 +1232,6 @@ class DoFObjectAccessor<3, DH> : * access to the DoF data. */ TriaIterator > child (const unsigned int) const; - - /** - * Distribute a local (cell - * based) vector to a global one - * by mapping the local numbering - * of the degrees of freedom to - * the global one and entering - * the local values into the - * global vector. - * - * The elements are - * added up to the - * elements in the global vector, - * rather than just set, since - * this is usually what one - * wants. - */ - template - void - distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const; - - /** - * This function does much the same as - * the - * distribute_local_to_global(Vector,Vector) - * function, but operates on matrices - * instead of vectors. The sparse matrix - * is supposed to have non-zero entry - * slots where required. - */ - template - void - distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const; /** * Implement the copy operator needed @@ -1694,6 +1558,43 @@ class DoFCellAccessor : public DoFObjectAccessor * with them at all. */ void get_dof_indices (std::vector &dof_indices) const; + + /** + * Distribute a local (cell + * based) vector to a global one + * by mapping the local numbering + * of the degrees of freedom to + * the global one and entering + * the local values into the + * global vector. + * + * The elements are + * added up to the + * elements in the global vector, + * rather than just set, since + * this is usually what one + * wants. + */ + template + void + distribute_local_to_global (const Vector &local_source, + OutputVector &global_destination) const; + + /** + * This function does much the + * same as the + * distribute_local_to_global(Vector,Vector) + * function, but operates on + * matrices instead of + * vectors. If the matrix type is + * a sparse matrix then it is + * supposed to have non-zero + * entry slots where required. + */ + template + void + distribute_local_to_global (const FullMatrix &local_source, + OutputMatrix &global_destination) const; private: /** diff --git a/deal.II/deal.II/include/dofs/dof_accessor.templates.h b/deal.II/deal.II/include/dofs/dof_accessor.templates.h index 6801935750..c1fd53f834 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.templates.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.templates.h @@ -297,99 +297,6 @@ DoFObjectAccessor<1,DH>::set_active_fe_index (const unsigned int i) -template -template -inline -void -DoFObjectAccessor<1,DH>:: -distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const -{ - // since the exception classes are - // from a template dependent base - // class, we have to fully qualify - // them. to work around more - // trouble, typedef the template - // dependent base class to a - // non-template dependent name and - // use that to specify the - // qualified exception names - typedef DoFAccessor BaseClass; - - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (local_source.size() == (2*this->get_fe().dofs_per_vertex + - this->get_fe().dofs_per_line), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (this->dof_handler->n_dofs() == global_destination.size(), - typename BaseClass::ExcVectorDoesNotMatch()); - - const unsigned int n_dofs = local_source.size(); - -//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually - - // get indices of dofs - std::vector dofs (n_dofs); - get_dof_indices (dofs); - - // distribute cell vector - for (unsigned int j=0; j -template -inline -void -DoFObjectAccessor<1,DH>:: -distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const -{ - // since the exception classes are - // from a template dependent base - // class, we have to fully qualify - // them. to work around more - // trouble, typedef the template - // dependent base class to a - // non-template dependent name and - // use that to specify the - // qualified exception names - typedef DoFAccessor BaseClass; - - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (local_source.m() == (2*this->get_fe().dofs_per_vertex + - this->get_fe().dofs_per_line), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (local_source.m() == local_source.n(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (this->dof_handler->n_dofs() == global_destination.m(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (global_destination.m() == global_destination.n(), - typename BaseClass::ExcMatrixDoesNotMatch()); - - const unsigned int n_dofs = local_source.m(); - -//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually - - // get indices of dofs - std::vector dofs (n_dofs); - get_dof_indices (dofs); - - // distribute cell matrix - for (unsigned int i=0; i inline void @@ -611,106 +518,6 @@ DoFObjectAccessor<2,DH>::set_active_fe_index (const unsigned int i) -template -template -inline -void -DoFObjectAccessor<2,DH>:: -distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const -{ - // since the exception classes are - // from a template dependent base - // class, we have to fully qualify - // them. to work around more - // trouble, typedef the template - // dependent base class to a - // non-template dependent name and - // use that to specify the - // qualified exception names - typedef DoFAccessor BaseClass; - - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (local_source.size() == (4*this->dof_handler->get_fe().dofs_per_vertex + - 4*this->dof_handler->get_fe().dofs_per_line + - this->dof_handler->get_fe().dofs_per_quad), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (this->dof_handler->n_dofs() == global_destination.size(), - typename BaseClass::ExcVectorDoesNotMatch()); - - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - const unsigned int n_dofs = local_source.size(); - -//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually - - // get indices of dofs - std::vector dofs (n_dofs); - get_dof_indices (dofs); - - // distribute cell vector - for (unsigned int j=0; j -template -inline -void -DoFObjectAccessor<2,DH>:: -distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const -{ - // since the exception classes are - // from a template dependent base - // class, we have to fully qualify - // them. to work around more - // trouble, typedef the template - // dependent base class to a - // non-template dependent name and - // use that to specify the - // qualified exception names - typedef DoFAccessor BaseClass; - - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (local_source.m() == (4*this->dof_handler->get_fe().dofs_per_vertex + - 4*this->dof_handler->get_fe().dofs_per_line + - this->dof_handler->get_fe().dofs_per_quad), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (local_source.m() == local_source.n(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (this->dof_handler->n_dofs() == global_destination.m(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (global_destination.m() == global_destination.n(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - const unsigned int n_dofs = local_source.m(); - -//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually - - // get indices of dofs - std::vector dofs (n_dofs); - get_dof_indices (dofs); - - // distribute cell matrix - for (unsigned int i=0; i inline void @@ -949,107 +756,6 @@ DoFObjectAccessor<3,DH>::set_active_fe_index (const unsigned int i) -template -template -inline -void -DoFObjectAccessor<3,DH>:: -distribute_local_to_global (const Vector &local_source, - OutputVector &global_destination) const -{ - // since the exception classes are - // from a template dependent base - // class, we have to fully qualify - // them. to work around more - // trouble, typedef the template - // dependent base class to a - // non-template dependent name and - // use that to specify the - // qualified exception names - typedef DoFAccessor BaseClass; - - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (local_source.size() == (8*this->get_fe().dofs_per_vertex + - 12*this->get_fe().dofs_per_line + - 6*this->get_fe().dofs_per_quad + - this->get_fe().dofs_per_hex), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (this->dof_handler->n_dofs() == global_destination.size(), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - const unsigned int n_dofs = local_source.size(); - -//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually - - // get indices of dofs - std::vector dofs (n_dofs); - get_dof_indices (dofs); - - // distribute cell vector - for (unsigned int j=0; j -template -inline -void -DoFObjectAccessor<3,DH>:: -distribute_local_to_global (const FullMatrix &local_source, - OutputMatrix &global_destination) const -{ - // since the exception classes are - // from a template dependent base - // class, we have to fully qualify - // them. to work around more - // trouble, typedef the template - // dependent base class to a - // non-template dependent name and - // use that to specify the - // qualified exception names - typedef DoFAccessor BaseClass; - - Assert (this->dof_handler != 0, - typename BaseClass::ExcInvalidObject()); - Assert (&this->get_fe() != 0, - typename BaseClass::ExcInvalidObject()); - Assert (local_source.m() == (8*this->get_fe().dofs_per_vertex + - 12*this->get_fe().dofs_per_line + - 6*this->get_fe().dofs_per_quad + - this->get_fe().dofs_per_hex), - typename BaseClass::ExcVectorDoesNotMatch()); - Assert (local_source.m() == local_source.n(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (this->dof_handler->n_dofs() == global_destination.m(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (global_destination.m() == global_destination.n(), - typename BaseClass::ExcMatrixDoesNotMatch()); - Assert (static_cast(this->present_level) < this->dof_handler->levels.size(), - ExcMessage ("DoFHandler not initialized")); - - const unsigned int n_dofs = local_source.m(); - -//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually - - // get indices of dofs - std::vector dofs (n_dofs); - get_dof_indices (dofs); - - // distribute cell matrix - for (unsigned int i=0; i void DoFObjectAccessor<3,DH>::copy_from (const DoFObjectAccessor<3,DH> &a) { @@ -1968,4 +1674,98 @@ get_dof_indices (std::vector &dof_indices) const } + +template +template +inline +void +DoFCellAccessor:: +distribute_local_to_global (const Vector &local_source, + OutputVector &global_destination) const +{ + // since the exception classes are + // from a template dependent base + // class, we have to fully qualify + // them. to work around more + // trouble, typedef the template + // dependent base class to a + // non-template dependent name and + // use that to specify the + // qualified exception names + typedef DoFAccessor BaseClass; + + Assert (this->dof_handler != 0, + typename BaseClass::ExcInvalidObject()); + Assert (&this->get_fe() != 0, + typename BaseClass::ExcInvalidObject()); + Assert (local_source.size() == (2*this->get_fe().dofs_per_vertex + + this->get_fe().dofs_per_line), + typename BaseClass::ExcVectorDoesNotMatch()); + Assert (this->dof_handler->n_dofs() == global_destination.size(), + typename BaseClass::ExcVectorDoesNotMatch()); + + const unsigned int n_dofs = local_source.size(); + +//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually + + // get indices of dofs + std::vector dofs (n_dofs); + this->get_dof_indices (dofs); + + // distribute cell vector + for (unsigned int j=0; j +template +inline +void +DoFCellAccessor:: +distribute_local_to_global (const FullMatrix &local_source, + OutputMatrix &global_destination) const +{ + // since the exception classes are + // from a template dependent base + // class, we have to fully qualify + // them. to work around more + // trouble, typedef the template + // dependent base class to a + // non-template dependent name and + // use that to specify the + // qualified exception names + typedef DoFAccessor BaseClass; + + Assert (this->dof_handler != 0, + typename BaseClass::ExcInvalidObject()); + Assert (&this->get_fe() != 0, + typename BaseClass::ExcInvalidObject()); + Assert (local_source.m() == (2*this->get_fe().dofs_per_vertex + + this->get_fe().dofs_per_line), + typename BaseClass::ExcVectorDoesNotMatch()); + Assert (local_source.m() == local_source.n(), + typename BaseClass::ExcMatrixDoesNotMatch()); + Assert (this->dof_handler->n_dofs() == global_destination.m(), + typename BaseClass::ExcMatrixDoesNotMatch()); + Assert (global_destination.m() == global_destination.n(), + typename BaseClass::ExcMatrixDoesNotMatch()); + + const unsigned int n_dofs = local_source.m(); + +//TODO[WB]: This function could me made more efficient. First, it allocates memory, which could be avoided by passing in another argument as a scratch array. second, the elementwise access is really slow if we use PETSc vectors/matrices. This should be fixed eventually + + // get indices of dofs + std::vector dofs (n_dofs); + this->get_dof_indices (dofs); + + // distribute cell matrix + for (unsigned int i=0; i +
  • + Changed: The distribute_local_to_global functions have + been moved from the classes implementing accessors to arbitrary + objects in the triangulation to the cell accessors, to + facilitate the implementation of hp methods. That means + that you can't call these functions for face or edge iterators + any more, but only cells. Since this is what is usually + desired, this should not be too severe a restriction. +
    + (WB 2006/04/26) +

    +
  • Changed: The template argument of the InterGridMap class has been changed. Code -- 2.39.5