From adbf27f0187709b514f75ff16cf6e82dcc0f33f9 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 18 Jan 2000 09:15:43 +0000 Subject: [PATCH] Move the get/set_dof_values functions from the cell accessors to the object accessors, as seems more reasonable. This enables us to remove the pseudo template things here and there. git-svn-id: https://svn.dealii.org/trunk@2245 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/deal.II/Todo | 29 +- deal.II/deal.II/include/dofs/dof_accessor.h | 201 ++++-- .../deal.II/include/dofs/mg_dof_accessor.h | 86 ++- .../include/multigrid/mg_dof_accessor.h | 86 ++- deal.II/deal.II/source/dofs/dof_accessor.cc | 588 +++++++++--------- .../deal.II/source/dofs/mg_dof_accessor.cc | 294 ++++++--- .../source/multigrid/mg_dof_accessor.cc | 294 ++++++--- 7 files changed, 1001 insertions(+), 577 deletions(-) diff --git a/deal.II/deal.II/Todo b/deal.II/deal.II/Todo index 31f5b0042d..830b0ea27b 100644 --- a/deal.II/deal.II/Todo +++ b/deal.II/deal.II/Todo @@ -31,10 +31,6 @@ Look at the fill_fe_values functions for possible optimizations since this is one of the most often called functions. -Use a correct strategy to output the reduction rate for adaptively - refined grids in examples/error-estimation - - In VectorTools::project_boundary_values, no condensation of sparsity structures, matrices and right hand sides or distribution of solution vectors is performed. This is ok for dim<3 because then @@ -51,11 +47,6 @@ Check all places where condensation of matrices/vectors and of the 3D library. -I suppose the [mg_]get_dof_values really belongs to the - [MG]Line/QuadAccessor classes, but now it is in the - [MG]CellAccessor. Correct this some time. - - No support points for non-Lagrangian elements? Check for Langrange in interpolation? @@ -103,15 +94,6 @@ Change the vector in 'void DoFQuadAccessor::get_dof_indices( catch the Error dof_index==-1 inside of this function -Remove that pseudo-template clutter in the lower parts of - dof_accessor.[templates.]cc marked by comments. - - -Add support for MGTransferPrebuilt and MGSmoother if a user wants - to solve exactly on another than the coarsest grid. In this case, - some matrices and other arrays need not be computed. - - Unify lots of code of the two Cuthill-McKee dof renumbering functions in numerics/dof_renumbering.cc. This should be rather straightforward, since all the unified code needs to get is a @@ -122,6 +104,11 @@ Unify lots of code of the two Cuthill-McKee dof renumbering functions Update documentation on Boundaries in Triangulation (Guido!) +Add support for MGTransferPrebuilt and MGSmoother if a user wants + to solve exactly on another than the coarsest grid. In this case, + some matrices and other arrays need not be computed. + + Fix MGTransferPrebuilt::build_matrices, think about diagonals in square sparse matrices. @@ -149,3 +136,9 @@ Remove the hack in Make_forward_declarations when using gcc2.95. See Move the TriaNumberCache into the Triangulation class once the compiler supports this (gcc2.95 does not allow this at present) + + +Use a correct strategy to output the reduction rate for adaptively + refined grids in examples/error-estimation + + diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index 85f8d8b488..52da7ff0ec 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -44,7 +44,8 @@ * @author Wolfgang Bangerth, 1998 */ template -class DoFAccessor { +class DoFAccessor +{ public: /** * Constructor @@ -98,6 +99,10 @@ class DoFAccessor { * Exception */ DeclException0 (ExcMatrixDoesNotMatch); + /** + * Exception + */ + DeclException0 (ExcNotActive); protected: /** @@ -310,6 +315,49 @@ class DoFObjectAccessor<1, dim> : public DoFAccessor, */ void get_dof_indices (vector &dof_indices) const; + /** + * Return the values of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. This + * function is only callable for active + * cells. + */ + template + void get_dof_values (const Vector &values, + Vector &local_values) const; + + /** + * This function is the counterpart to + * #get_dof_values#: it takes a vector + * of values for the degrees of freedom + * of the cell pointed to by this iterator + * and writes these values into the global + * data vector #values#. This function + * is only callable for active cells. + * + * Note that for continuous finite + * elements, calling this function affects + * the dof values on neighboring cells as + * well. It may also violate continuity + * requirements for hanging nodes, if + * neighboring cells are less refined than + * the present one. These requirements + * are not taken care of and must be + * enforced by the user afterwards. + * + * It is assumed that both vectors already + * have the right size beforehand. + */ + template + void set_dof_values (const Vector &local_values, + Vector &values) const; + /** * Return the #i#th child as a DoF line * iterator. This function is needed since @@ -434,6 +482,49 @@ class DoFObjectAccessor<2, dim> : public DoFAccessor, */ void get_dof_indices (vector &dof_indices) const; + /** + * Return the values of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. This + * function is only callable for active + * cells. + */ + template + void get_dof_values (const Vector &values, + Vector &local_values) const; + + /** + * This function is the counterpart to + * #get_dof_values#: it takes a vector + * of values for the degrees of freedom + * of the cell pointed to by this iterator + * and writes these values into the global + * data vector #values#. This function + * is only callable for active cells. + * + * Note that for continuous finite + * elements, calling this function affects + * the dof values on neighboring cells as + * well. It may also violate continuity + * requirements for hanging nodes, if + * neighboring cells are less refined than + * the present one. These requirements + * are not taken care of and must be + * enforced by the user afterwards. + * + * It is assumed that both vectors already + * have the right size beforehand. + */ + template + void set_dof_values (const Vector &local_values, + Vector &values) const; + /** * Return a pointer to the #i#th line * bounding this #Quad#. @@ -568,6 +659,49 @@ class DoFObjectAccessor<3, dim> : public DoFAccessor, */ void get_dof_indices (vector &dof_indices) const; + /** + * Return the values of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. This + * function is only callable for active + * cells. + */ + template + void get_dof_values (const Vector &values, + Vector &local_values) const; + + /** + * This function is the counterpart to + * #get_dof_values#: it takes a vector + * of values for the degrees of freedom + * of the cell pointed to by this iterator + * and writes these values into the global + * data vector #values#. This function + * is only callable for active cells. + * + * Note that for continuous finite + * elements, calling this function affects + * the dof values on neighboring cells as + * well. It may also violate continuity + * requirements for hanging nodes, if + * neighboring cells are less refined than + * the present one. These requirements + * are not taken care of and must be + * enforced by the user afterwards. + * + * It is assumed that both vectors already + * have the right size beforehand. + */ + template + void set_dof_values (const Vector &local_values, + Vector &values) const; + /** * Return a pointer to the #i#th line * bounding this #Hex#. @@ -693,23 +827,6 @@ class DoFCellAccessor : public DoFObjectAccessor { TriaIterator > face (const unsigned int i) const; - /** - * Return the values of the given vector - * restricted to the dofs of this - * cell in the standard ordering: dofs - * on vertex 0, dofs on vertex 1, etc, - * dofs on line 0, dofs on line 1, etc, - * dofs on quad 0, etc. - * - * It is assumed that the vector already - * has the right size beforehand. This - * function is only callable for active - * cells. - */ - template - void get_dof_values (const Vector &values, - Vector &local_values) const; - /** * Return the interpolation of the given * finite element function to the present @@ -748,37 +865,20 @@ class DoFCellAccessor : public DoFObjectAccessor { * of each child. It is not yet decided * what the this function does in these * cases. + * + * Unlike the #get_dof_values# + * function, this function is + * associated to cells rather + * than to lines, quads, and + * hexes, since interpolation is + * presently only provided for + * cells by the finite element + * objects. */ template void get_interpolated_dof_values (const Vector &values, Vector &interpolated_values) const; - /** - * This function is the counterpart to - * #get_dof_values#: it takes a vector - * of values for the degrees of freedom - * of the cell pointed to by this iterator - * and writes these values into the global - * data vector #values#. This function - * is only callable for active cells. - * - * Note that for continuous finite - * elements, calling this function affects - * the dof values on neighboring cells as - * well. It may also violate continuity - * requirements for hanging nodes, if - * neighboring cells are less refined than - * the present one. These requirements - * are not taken care of and must be - * enforced by the user afterwards. - * - * It is assumed that both vectors already - * have the right size beforehand. - */ - template - void set_dof_values (const Vector &local_values, - Vector &values) const; - /** * This, again, is the counterpart to * #get_interpolated_dof_values#: you @@ -831,6 +931,15 @@ class DoFCellAccessor : public DoFObjectAccessor { * element class for a description of what * the prolongation matrices represent in * this case. + * + * Unlike the #set_dof_values# + * function, this function is + * associated to cells rather + * than to lines, quads, and + * hexes, since interpolation is + * presently only provided for + * cells by the finite element + * objects. */ template void set_dof_values_by_interpolation (const Vector &local_values, @@ -840,10 +949,6 @@ class DoFCellAccessor : public DoFObjectAccessor { * Exception */ DeclException0 (ExcNotUsefulForThisDimension); - /** - * Exception - */ - DeclException0 (ExcNotActive); }; diff --git a/deal.II/deal.II/include/dofs/mg_dof_accessor.h b/deal.II/deal.II/include/dofs/mg_dof_accessor.h index 7e94014b42..4b30be0c8a 100644 --- a/deal.II/deal.II/include/dofs/mg_dof_accessor.h +++ b/deal.II/deal.II/include/dofs/mg_dof_accessor.h @@ -287,6 +287,27 @@ class MGDoFObjectAccessor<1, dim> : public MGDoFAccessor, */ void get_mg_dof_indices (vector &dof_indices) const; + /** + * Return the value of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the multilevel + * numbering local to the present + * level of this cell. The vector shall + * therefore have the same number of + * entries as there are degrees of + * freedom on this level. + */ + template + void get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + /** * Return the #i#th child as a MGDoF line * iterator. This function is needed since @@ -385,8 +406,29 @@ class MGDoFObjectAccessor<2, dim> : public MGDoFAccessor, * for the level this quad lives on. */ void get_mg_dof_indices (vector &dof_indices) const; - + /** + * Return the value of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the multilevel + * numbering local to the present + * level of this cell. The vector shall + * therefore have the same number of + * entries as there are degrees of + * freedom on this level. + */ + template + void get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + + /** * Return a pointer to the #i#th line * bounding this #Quad#. */ @@ -491,6 +533,27 @@ class MGDoFObjectAccessor<3, dim> : public MGDoFAccessor, */ void get_mg_dof_indices (vector &dof_indices) const; + /** + * Return the value of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the multilevel + * numbering local to the present + * level of this cell. The vector shall + * therefore have the same number of + * entries as there are degrees of + * freedom on this level. + */ + template + void get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + /** * Return a pointer to the #i#th line * bounding this #Hex#. @@ -589,27 +652,6 @@ class MGDoFCellAccessor : public MGDoFObjectAccessor { face_iterator face (const unsigned int i) const; - /** - * Return the value of the given vector - * restricted to the dofs of this - * cell in the standard ordering: dofs - * on vertex 0, dofs on vertex 1, etc, - * dofs on line 0, dofs on line 1, etc, - * dofs on quad 0, etc. - * - * It is assumed that the vector already - * has the right size beforehand. The - * indices refer to the multilevel - * numbering local to the present - * level of this cell. The vector shall - * therefore have the same number of - * entries as there are degrees of - * freedom on this level. - */ - void get_mg_dof_values (const Vector &values, - Vector &dof_values) const; - - /** * Exception */ diff --git a/deal.II/deal.II/include/multigrid/mg_dof_accessor.h b/deal.II/deal.II/include/multigrid/mg_dof_accessor.h index 7e94014b42..4b30be0c8a 100644 --- a/deal.II/deal.II/include/multigrid/mg_dof_accessor.h +++ b/deal.II/deal.II/include/multigrid/mg_dof_accessor.h @@ -287,6 +287,27 @@ class MGDoFObjectAccessor<1, dim> : public MGDoFAccessor, */ void get_mg_dof_indices (vector &dof_indices) const; + /** + * Return the value of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the multilevel + * numbering local to the present + * level of this cell. The vector shall + * therefore have the same number of + * entries as there are degrees of + * freedom on this level. + */ + template + void get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + /** * Return the #i#th child as a MGDoF line * iterator. This function is needed since @@ -385,8 +406,29 @@ class MGDoFObjectAccessor<2, dim> : public MGDoFAccessor, * for the level this quad lives on. */ void get_mg_dof_indices (vector &dof_indices) const; - + /** + * Return the value of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the multilevel + * numbering local to the present + * level of this cell. The vector shall + * therefore have the same number of + * entries as there are degrees of + * freedom on this level. + */ + template + void get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + + /** * Return a pointer to the #i#th line * bounding this #Quad#. */ @@ -491,6 +533,27 @@ class MGDoFObjectAccessor<3, dim> : public MGDoFAccessor, */ void get_mg_dof_indices (vector &dof_indices) const; + /** + * Return the value of the given vector + * restricted to the dofs of this + * cell in the standard ordering: dofs + * on vertex 0, dofs on vertex 1, etc, + * dofs on line 0, dofs on line 1, etc, + * dofs on quad 0, etc. + * + * It is assumed that the vector already + * has the right size beforehand. The + * indices refer to the multilevel + * numbering local to the present + * level of this cell. The vector shall + * therefore have the same number of + * entries as there are degrees of + * freedom on this level. + */ + template + void get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + /** * Return a pointer to the #i#th line * bounding this #Hex#. @@ -589,27 +652,6 @@ class MGDoFCellAccessor : public MGDoFObjectAccessor { face_iterator face (const unsigned int i) const; - /** - * Return the value of the given vector - * restricted to the dofs of this - * cell in the standard ordering: dofs - * on vertex 0, dofs on vertex 1, etc, - * dofs on line 0, dofs on line 1, etc, - * dofs on quad 0, etc. - * - * It is assumed that the vector already - * has the right size beforehand. The - * indices refer to the multilevel - * numbering local to the present - * level of this cell. The vector shall - * therefore have the same number of - * entries as there are degrees of - * freedom on this level. - */ - void get_mg_dof_values (const Vector &values, - Vector &dof_values) const; - - /** * Exception */ diff --git a/deal.II/deal.II/source/dofs/dof_accessor.cc b/deal.II/deal.II/source/dofs/dof_accessor.cc index b69afa068c..674bbdacb8 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -115,6 +115,68 @@ distribute_local_to_global (const FullMatrix &local_source, +template +template +void +DoFObjectAccessor<1,dim>::get_dof_values (const Vector &values, + Vector &local_values) const +{ + Assert (dim==1, ExcInternalError()); + + Assert (dof_handler != 0, DoFAccessor<1>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::ExcInvalidObject()); + Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<1>::ExcVectorDoesNotMatch()); + Assert (values.size() == dof_handler->n_dofs(), + DoFAccessor<1>::ExcVectorDoesNotMatch()); + Assert (has_children() == false, ExcNotActive()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line; + typename vector::iterator next_local_value=local_values.begin(); + for (unsigned int vertex=0; vertex<2; ++vertex) + for (unsigned int d=0; d +template +void +DoFObjectAccessor<1,dim>::set_dof_values (const Vector &local_values, + Vector &values) const { + Assert (dim==1, ExcInternalError()); + + Assert (dof_handler != 0, DoFAccessor<1>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::ExcInvalidObject()); + Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<1>::ExcVectorDoesNotMatch()); + Assert (values.size() == dof_handler->n_dofs(), + DoFAccessor<1>::ExcVectorDoesNotMatch()); + Assert (has_children() == false, ExcNotActive()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line; + typename vector::const_iterator next_local_value=local_values.begin(); + for (unsigned int vertex=0; vertex<2; ++vertex) + for (unsigned int d=0; d &local_source, +template +template +void +DoFObjectAccessor<2,dim>::get_dof_values (const Vector &values, + Vector &local_values) const +{ + Assert (dim==2, ExcInternalError()); + + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); + Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor::ExcVectorDoesNotMatch()); + Assert (values.size() == dof_handler->n_dofs(), + DoFAccessor::ExcVectorDoesNotMatch()); + Assert (has_children() == false, ExcNotActive()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line, + dofs_per_quad = dof_handler->get_fe().dofs_per_quad; + typename vector::iterator next_local_value=local_values.begin(); + for (unsigned int vertex=0; vertex<4; ++vertex) + for (unsigned int d=0; dline(line)->dof_index(d)); + for (unsigned int d=0; d +template +void +DoFObjectAccessor<2,dim>::set_dof_values (const Vector &local_values, + Vector &values) const +{ + Assert (dim==2, ExcInternalError()); + + Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); + Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor::ExcVectorDoesNotMatch()); + Assert (values.size() == dof_handler->n_dofs(), + DoFAccessor::ExcVectorDoesNotMatch()); + Assert (has_children() == false, ExcNotActive()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line, + dofs_per_quad = dof_handler->get_fe().dofs_per_quad; + typename vector::const_iterator next_local_value=local_values.begin(); + for (unsigned int vertex=0; vertex<4; ++vertex) + for (unsigned int d=0; dline(line)->dof_index(d)) = *next_local_value++; + for (unsigned int d=0; d @@ -277,7 +411,8 @@ distribute_local_to_global (const Vector &local_source, template void DoFObjectAccessor<3, dim>:: distribute_local_to_global (const FullMatrix &local_source, - SparseMatrix &global_destination) const { + SparseMatrix &global_destination) const +{ Assert (dof_handler != 0, ExcInvalidObject()); Assert (dof_handler->selected_fe != 0, ExcInvalidObject()); Assert (local_source.m() == (8*dof_handler->get_fe().dofs_per_vertex + @@ -306,265 +441,12 @@ distribute_local_to_global (const FullMatrix &local_source, - - - -/*------------------------- Functions: DoFCellAccessor -----------------------*/ - - - -#if deal_II_dimension == 1 - -template <> -TriaIterator<1, DoFObjectAccessor<0,1> > -DoFCellAccessor<1>::face (const unsigned int) const -{ - Assert (false, ExcNotUsefulForThisDimension()); - return TriaIterator<1, DoFObjectAccessor<0,1> >(); -}; - - - -/* this function looks like a template, but actually isn't one, it - will only work for the dimension selected by the preprocessor - guard above. - - the correct thing to do would be - - template <> - template - void - DoFCellAccessor<1>::get... (vector...) - - but this does not work, at least not at present using egcs1.1.1. we therefore - separate the different implementations for the different dimensions using - the preprocessor and double check using an assertion in the function body. - -//TODO: correct the pseudo-template thing -*/ -template -template -void -DoFCellAccessor::get_dof_values (const Vector &values, - Vector &local_values) const { - Assert (dim==1, ExcInternalError()); - - Assert (dof_handler != 0, DoFAccessor<1>::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::ExcInvalidObject()); - Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, - DoFAccessor<1>::ExcVectorDoesNotMatch()); - Assert (values.size() == dof_handler->n_dofs(), - DoFAccessor<1>::ExcVectorDoesNotMatch()); - Assert (active(), ExcNotActive()); - - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line; - typename vector::iterator next_local_value=local_values.begin(); - for (unsigned int vertex=0; vertex<2; ++vertex) - for (unsigned int d=0; d - template - void - DoFCellAccessor<1>::get... (vector...) - - but this does not work, at least not at present using egcs1.1.1. we therefore - separate the different implementations for the different dimensions using - the preprocecssor and double check using an assertion in the function body. -*/ template template void -DoFCellAccessor::set_dof_values (const Vector &local_values, - Vector &values) const { - Assert (dim==1, ExcInternalError()); - - Assert (dof_handler != 0, DoFAccessor<1>::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::ExcInvalidObject()); - Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, - DoFAccessor<1>::ExcVectorDoesNotMatch()); - Assert (values.size() == dof_handler->n_dofs(), - DoFAccessor<1>::ExcVectorDoesNotMatch()); - Assert (active(), ExcNotActive()); - - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line; - typename vector::const_iterator next_local_value=local_values.begin(); - for (unsigned int vertex=0; vertex<2; ++vertex) - for (unsigned int d=0; d -TriaIterator<2, DoFObjectAccessor<1,2> > -DoFCellAccessor<2>::face (const unsigned int i) const -{ - return line(i); -}; - - - -/* this function looks like a template, but actually isn't one, it - will only work for the dimension selected by the preprocessor - guard above. - - the correct thing to do would be - - template <> - template - void - DoFCellAccessor<1>::get... (vector...) - - but this does not work, at least not at present using egcs1.1.1. we therefore - separate the different implementations for the different dimensions using - the preprocecssor and double check using an assertion in the function body. -*/ -template -template -void -DoFCellAccessor::get_dof_values (const Vector &values, - Vector &local_values) const -{ - Assert (dim==2, ExcInternalError()); - - Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); - Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, - DoFAccessor::ExcVectorDoesNotMatch()); - Assert (values.size() == dof_handler->n_dofs(), - DoFAccessor::ExcVectorDoesNotMatch()); - Assert (active(), ExcNotActive()); - - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line, - dofs_per_quad = dof_handler->get_fe().dofs_per_quad; - typename vector::iterator next_local_value=local_values.begin(); - for (unsigned int vertex=0; vertex<4; ++vertex) - for (unsigned int d=0; dline(line)->dof_index(d)); - for (unsigned int d=0; d - template - void - DoFCellAccessor<1>::get... (vector...) - - but this does not work, at least not at present using egcs1.1.1. we therefore - separate the different implementations for the different dimensions using - the preprocecssor and double check using an assertion in the function body. -*/ -template -template -void -DoFCellAccessor::set_dof_values (const Vector &local_values, - Vector &values) const { - Assert (dim==2, ExcInternalError()); - - Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); - Assert (local_values.size() == dof_handler->get_fe().dofs_per_cell, - DoFAccessor::ExcVectorDoesNotMatch()); - Assert (values.size() == dof_handler->n_dofs(), - DoFAccessor::ExcVectorDoesNotMatch()); - Assert (active(), ExcNotActive()); - - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line, - dofs_per_quad = dof_handler->get_fe().dofs_per_quad; - typename vector::const_iterator next_local_value=local_values.begin(); - for (unsigned int vertex=0; vertex<4; ++vertex) - for (unsigned int d=0; dline(line)->dof_index(d)) = *next_local_value++; - for (unsigned int d=0; d -TriaIterator<3, DoFObjectAccessor<2, 3> > -DoFCellAccessor<3>::face (const unsigned int i) const +DoFObjectAccessor<3,dim>::get_dof_values (const Vector &values, + Vector &local_values) const { - return quad(i); -}; - - - -/* this function looks like a template, but actually isn't one, it - will only work for the dimension selected by the preprocessor - guard above. - - the correct thing to do would be - - template <> - template - void - DoFCellAccessor<1>::get... (vector...) - - but this does not work, at least not at present using egcs1.1.1. we therefore - separate the different implementations for the different dimensions using - the preprocecssor and double check using an assertion in the function body. -*/ -template -template -void -DoFCellAccessor::get_dof_values (const Vector &values, - Vector &local_values) const { Assert (dim==3, ExcInternalError()); Assert (dof_handler != 0, DoFAccessor<3>::ExcInvalidObject()); @@ -573,51 +455,37 @@ DoFCellAccessor::get_dof_values (const Vector &values, DoFAccessor<3>::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), DoFAccessor<3>::ExcVectorDoesNotMatch()); - Assert (active(), ExcNotActive()); + Assert (has_children() == false, ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, dofs_per_line = dof_handler->get_fe().dofs_per_line, dofs_per_quad = dof_handler->get_fe().dofs_per_quad, dofs_per_hex = dof_handler->get_fe().dofs_per_hex; typename vector::iterator next_local_value = local_values.begin(); - for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) + for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) for (unsigned int d=0; d::lines_per_cell; ++line) + for (unsigned int line=0; line::lines_per_cell; ++line) for (unsigned int d=0; dline(line)->dof_index(d)); - for (unsigned int quad=0; quad::quads_per_cell; ++quad) + for (unsigned int quad=0; quad::quads_per_cell; ++quad) for (unsigned int d=0; dquad(quad)->dof_index(d)); for (unsigned int d=0; d - template - void - DoFCellAccessor<1>::get... (vector...) - - but this does not work, at least not at present using egcs1.1.1. we therefore - separate the different implementations for the different dimensions using - the preprocecssor and double check using an assertion in the function body. -*/ template template void -DoFCellAccessor::set_dof_values (const Vector &local_values, - Vector &values) const { +DoFObjectAccessor<3,dim>::set_dof_values (const Vector &local_values, + Vector &values) const +{ Assert (dim==3, ExcInternalError()); Assert (dof_handler != 0, DoFAccessor<3>::ExcInvalidObject()); @@ -626,7 +494,7 @@ DoFCellAccessor::set_dof_values (const Vector &local_values, DoFAccessor<3>::ExcVectorDoesNotMatch()); Assert (values.size() == dof_handler->n_dofs(), DoFAccessor<3>::ExcVectorDoesNotMatch()); - Assert (active(), ExcNotActive()); + Assert (has_children() == false, ExcNotActive()); const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, dofs_per_line = dof_handler->get_fe().dofs_per_line, @@ -646,10 +514,52 @@ DoFCellAccessor::set_dof_values (const Vector &local_values, values(dof_index(d)) = *next_local_value++; Assert (next_local_value == local_values.end(), - ::ExcInternalError()); + ExcInternalError()); +}; + + + + + +/*------------------------- Functions: DoFCellAccessor -----------------------*/ + + + +#if deal_II_dimension == 1 + +template <> +TriaIterator<1, DoFObjectAccessor<0,1> > +DoFCellAccessor<1>::face (const unsigned int) const +{ + Assert (false, ExcNotUsefulForThisDimension()); + return TriaIterator<1, DoFObjectAccessor<0,1> >(); +}; + +#endif + + + +#if deal_II_dimension == 2 + +template <> +TriaIterator<2, DoFObjectAccessor<1,2> > +DoFCellAccessor<2>::face (const unsigned int i) const +{ + return line(i); }; +#endif + + +#if deal_II_dimension == 3 + +template <> +TriaIterator<3, DoFObjectAccessor<2, 3> > +DoFCellAccessor<3>::face (const unsigned int i) const +{ + return quad(i); +}; #endif @@ -660,7 +570,8 @@ template template void DoFCellAccessor::get_interpolated_dof_values (const Vector &values, - Vector &interpolated_values) const { + Vector &interpolated_values) const +{ const unsigned int dofs_per_cell = dof_handler->get_fe().dofs_per_cell; Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); @@ -722,7 +633,8 @@ template template void DoFCellAccessor::set_dof_values_by_interpolation (const Vector &local_values, - Vector &values) const { + Vector &values) const +{ const unsigned int dofs_per_cell = dof_handler->get_fe().dofs_per_cell; Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); @@ -764,37 +676,115 @@ DoFCellAccessor::set_dof_values_by_interpolation (const Vector &loc // for double template void -DoFCellAccessor::get_dof_values (const Vector &, - Vector &) const; +DoFObjectAccessor<1,deal_II_dimension>:: +get_dof_values (const Vector &, + Vector &) const; + +template +void +DoFObjectAccessor<1,deal_II_dimension>:: +set_dof_values (const Vector &, + Vector &) const; + + +// for float +template +void +DoFObjectAccessor<1,deal_II_dimension>:: +get_dof_values (const Vector &, + Vector &) const; + +template +void +DoFObjectAccessor<1,deal_II_dimension>:: +set_dof_values (const Vector &, + Vector &) const; + + +#if deal_II_dimension >= 2 +// for double +template +void +DoFObjectAccessor<2,deal_II_dimension>:: +get_dof_values (const Vector &, + Vector &) const; + +template +void +DoFObjectAccessor<2,deal_II_dimension>:: +set_dof_values (const Vector &, + Vector &) const; + +// for float +template +void +DoFObjectAccessor<2,deal_II_dimension>:: +get_dof_values (const Vector &, + Vector &) const; + template void -DoFCellAccessor::get_interpolated_dof_values (const Vector &, - Vector &) const; +DoFObjectAccessor<2,deal_II_dimension>:: +set_dof_values (const Vector &, + Vector &) const; + +#endif + + +#if deal_II_dimension >= 3 +// for double template void -DoFCellAccessor::set_dof_values (const Vector &, - Vector &) const; +DoFObjectAccessor<3,deal_II_dimension>:: +get_dof_values (const Vector &, + Vector &) const; + template void -DoFCellAccessor::set_dof_values_by_interpolation(const Vector &, - Vector &) const; +DoFObjectAccessor<3,deal_II_dimension>:: +set_dof_values (const Vector &, + Vector &) const; + // for float template void -DoFCellAccessor::get_dof_values (const Vector &, - Vector &) const; +DoFObjectAccessor<3,deal_II_dimension>:: +get_dof_values (const Vector &, + Vector &) const; + +template +void +DoFObjectAccessor<3,deal_II_dimension>:: +set_dof_values (const Vector &, + Vector &) const; + +#endif + + +template +void +DoFCellAccessor:: +get_interpolated_dof_values (const Vector &, + Vector &) const; + template void -DoFCellAccessor::get_interpolated_dof_values (const Vector &, - Vector &) const; +DoFCellAccessor:: +set_dof_values_by_interpolation(const Vector &, + Vector &) const; + + template void -DoFCellAccessor::set_dof_values (const Vector &, - Vector &) const; +DoFCellAccessor:: +get_interpolated_dof_values (const Vector &, + Vector &) const; + template void -DoFCellAccessor::set_dof_values_by_interpolation(const Vector &, - Vector &) const; +DoFCellAccessor:: +set_dof_values_by_interpolation(const Vector &, + Vector &) const; diff --git a/deal.II/deal.II/source/dofs/mg_dof_accessor.cc b/deal.II/deal.II/source/dofs/mg_dof_accessor.cc index 96dab7eaa8..27cc111a4d 100644 --- a/deal.II/deal.II/source/dofs/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/mg_dof_accessor.cc @@ -23,16 +23,18 @@ template MGDoFObjectAccessor<1, dim>::MGDoFObjectAccessor (Triangulation *tria, - const int level, - const int index, - const AccessorData *local_data) : + const int level, + const int index, + const AccessorData *local_data) : MGDoFAccessor (local_data), - MGDoFObjectAccessor_Inheritance<1,dim>::BaseClass(tria,level,index,local_data) {}; + MGDoFObjectAccessor_Inheritance<1,dim>::BaseClass(tria,level,index,local_data) +{}; template -int MGDoFObjectAccessor<1, dim>::mg_dof_index (const unsigned int i) const { +int MGDoFObjectAccessor<1, dim>::mg_dof_index (const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -51,7 +53,8 @@ int MGDoFObjectAccessor<1, dim>::mg_dof_index (const unsigned int i) const { template void MGDoFObjectAccessor<1, dim>::set_mg_dof_index (const unsigned int i, - const int index) const { + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -69,7 +72,8 @@ void MGDoFObjectAccessor<1, dim>::set_mg_dof_index (const unsigned int i, template int MGDoFObjectAccessor<1, dim>::mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i) const { + const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -85,8 +89,9 @@ int MGDoFObjectAccessor<1, dim>::mg_vertex_dof_index (const unsigned int vertex, template void MGDoFObjectAccessor<1, dim>::set_mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const int index) const { + const unsigned int i, + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -102,7 +107,8 @@ void MGDoFObjectAccessor<1, dim>::set_mg_vertex_dof_index (const unsigned int ve template void -MGDoFObjectAccessor<1, dim>::get_mg_dof_indices (vector &dof_indices) const { +MGDoFObjectAccessor<1, dim>::get_mg_dof_indices (vector &dof_indices) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -118,17 +124,50 @@ MGDoFObjectAccessor<1, dim>::get_mg_dof_indices (vector &dof_indices) const *next++ = mg_vertex_dof_index(vertex,d); for (unsigned int d=0; d +template +void +MGDoFObjectAccessor<1,dim>::get_mg_dof_values (const Vector &values, + Vector &dof_values) const +{ + Assert (dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); + Assert (mg_dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); + Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<1>::ExcVectorDoesNotMatch()); + Assert (values.size() == dof_handler->n_dofs(), + DoFAccessor<1>::ExcVectorDoesNotMatch()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line; + vector::iterator next_dof_value=dof_values.begin(); + for (unsigned int vertex=0; vertex<2; ++vertex) + for (unsigned int d=0; d TriaIterator > -MGDoFObjectAccessor<1, dim>::child (const unsigned int i) const { +MGDoFObjectAccessor<1, dim>::child (const unsigned int i) const +{ TriaIterator > q (tria, - present_level+1, - child_index (i), - mg_dof_handler); + present_level+1, + child_index (i), + mg_dof_handler); #ifdef DEBUG if (q.state() != past_the_end) @@ -165,7 +204,8 @@ MGDoFObjectAccessor<2, dim>::MGDoFObjectAccessor (Triangulation *tria, template inline -int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const { +int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -182,7 +222,8 @@ int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const { template void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i, - const int index) const { + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -200,7 +241,8 @@ void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i, template inline int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i) const { + const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -216,8 +258,9 @@ int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned int vertex, template void MGDoFObjectAccessor<2, dim>::set_mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const int index) const { + const unsigned int i, + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -233,7 +276,8 @@ void MGDoFObjectAccessor<2, dim>::set_mg_vertex_dof_index (const unsigned int ve template void -MGDoFObjectAccessor<2, dim>::get_mg_dof_indices (vector &dof_indices) const { +MGDoFObjectAccessor<2, dim>::get_mg_dof_indices (vector &dof_indices) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -254,13 +298,50 @@ MGDoFObjectAccessor<2, dim>::get_mg_dof_indices (vector &dof_indices) const *next++ = this->line(line)->mg_dof_index(d); for (unsigned int d=0; d +template +void +MGDoFObjectAccessor<2,dim>::get_mg_dof_values (const Vector &values, + Vector &dof_values) const +{ + Assert (dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (mg_dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<2>::ExcVectorDoesNotMatch()); + Assert (values.size() == mg_dof_handler->n_dofs(present_level), + DoFAccessor<2>::ExcVectorDoesNotMatch()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line, + dofs_per_quad = dof_handler->get_fe().dofs_per_quad; + vector::iterator next_dof_value=dof_values.begin(); + for (unsigned int vertex=0; vertex<4; ++vertex) + for (unsigned int d=0; dline(line)->mg_dof_index(d)); + for (unsigned int d=0; d TriaIterator > -MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const { +MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const +{ Assert (i<4, ExcIndexRange (i, 0, 4)); return TriaIterator > @@ -276,11 +357,12 @@ MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const { template TriaIterator > -MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const { +MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const +{ TriaIterator > q (tria, - present_level+1, - child_index (i), - mg_dof_handler); + present_level+1, + child_index (i), + mg_dof_handler); #ifdef DEBUG if (q.state() != past_the_end) @@ -293,7 +375,8 @@ MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const { template void -MGDoFObjectAccessor<2, dim>::copy_from (const MGDoFObjectAccessor<2, dim> &a) { +MGDoFObjectAccessor<2, dim>::copy_from (const MGDoFObjectAccessor<2, dim> &a) +{ DoFObjectAccessor<2, dim>::copy_from (a); set_mg_dof_handler (a.mg_dof_handler); }; @@ -305,17 +388,19 @@ MGDoFObjectAccessor<2, dim>::copy_from (const MGDoFObjectAccessor<2, dim> &a) { template MGDoFObjectAccessor<3, dim>::MGDoFObjectAccessor (Triangulation *tria, - const int level, - const int index, - const AccessorData *local_data) : + const int level, + const int index, + const AccessorData *local_data) : MGDoFAccessor (local_data), - MGDoFObjectAccessor_Inheritance<3,dim>::BaseClass(tria,level,index,local_data) {}; + MGDoFObjectAccessor_Inheritance<3,dim>::BaseClass(tria,level,index,local_data) +{}; template inline -int MGDoFObjectAccessor<3, dim>::mg_dof_index (const unsigned int i) const { +int MGDoFObjectAccessor<3, dim>::mg_dof_index (const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -332,7 +417,8 @@ int MGDoFObjectAccessor<3, dim>::mg_dof_index (const unsigned int i) const { template void MGDoFObjectAccessor<3, dim>::set_mg_dof_index (const unsigned int i, - const int index) const { + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -350,7 +436,8 @@ void MGDoFObjectAccessor<3, dim>::set_mg_dof_index (const unsigned int i, template inline int MGDoFObjectAccessor<3, dim>::mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i) const { + const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -366,8 +453,9 @@ int MGDoFObjectAccessor<3, dim>::mg_vertex_dof_index (const unsigned int vertex, template void MGDoFObjectAccessor<3, dim>::set_mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const int index) const { + const unsigned int i, + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -383,7 +471,8 @@ void MGDoFObjectAccessor<3, dim>::set_mg_vertex_dof_index (const unsigned int ve template void -MGDoFObjectAccessor<3, dim>::get_mg_dof_indices (vector &dof_indices) const { +MGDoFObjectAccessor<3, dim>::get_mg_dof_indices (vector &dof_indices) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -409,6 +498,46 @@ MGDoFObjectAccessor<3, dim>::get_mg_dof_indices (vector &dof_indices) const *next++ = this->quad(quad)->mg_dof_index(d); for (unsigned int d=0; d +template +void +MGDoFObjectAccessor<3,dim>::get_mg_dof_values (const Vector &values, + Vector &dof_values) const +{ + Assert (dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (mg_dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<3>::ExcVectorDoesNotMatch()); + Assert (values.size() == mg_dof_handler->n_dofs(present_level), + DoFAccessor<3>::ExcVectorDoesNotMatch()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line, + dofs_per_quad = dof_handler->get_fe().dofs_per_quad, + dofs_per_hex = dof_handler->get_fe().dofs_per_hex; + vector::iterator next_dof_value=dof_values.begin(); + for (unsigned int vertex=0; vertex<8; ++vertex) + for (unsigned int d=0; dline(line)->mg_dof_index(d)); + for (unsigned int quad=0; quad<6; ++quad) + for (unsigned int d=0; dquad(quad)->mg_dof_index(d)); + for (unsigned int d=0; d::face (const unsigned int) const return face_iterator(); }; - - -template <> -void -MGDoFCellAccessor<1>::get_mg_dof_values (const Vector &values, - Vector &dof_values) const { - Assert (dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); - Assert (mg_dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); - Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, - ExcVectorDoesNotMatch()); - Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); - - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line; - vector::iterator next_dof_value=dof_values.begin(); - for (unsigned int vertex=0; vertex<2; ++vertex) - for (unsigned int d=0; d::face (const unsigned int i) const return line(i); }; +#endif + -template <> + + +// explicit instantiations + +template void -MGDoFCellAccessor<2>::get_mg_dof_values (const Vector &values, - Vector &dof_values) const { - Assert (dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); - Assert (mg_dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor<2>::ExcInvalidObject()); - Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, - DoFAccessor<2>::ExcVectorDoesNotMatch()); - Assert (values.size() == mg_dof_handler->n_dofs(present_level), - DoFAccessor<2>::ExcVectorDoesNotMatch()); +MGDoFObjectAccessor<1,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line, - dofs_per_quad = dof_handler->get_fe().dofs_per_quad; - vector::iterator next_dof_value=dof_values.begin(); - for (unsigned int vertex=0; vertex<4; ++vertex) - for (unsigned int d=0; dline(line)->mg_dof_index(d)); - for (unsigned int d=0; d:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + + + +#if deal_II_dimension >= 2 + +template +void +MGDoFObjectAccessor<2,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + +template +void +MGDoFObjectAccessor<2,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; #endif +#if deal_II_dimension >= 3 + +template +void +MGDoFObjectAccessor<3,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; +template +void +MGDoFObjectAccessor<3,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + +#endif -// explicit instantiations #if deal_II_dimension == 1 template class MGDoFObjectAccessor<1, 1>; template class MGDoFCellAccessor<1>; diff --git a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc index 96dab7eaa8..27cc111a4d 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc @@ -23,16 +23,18 @@ template MGDoFObjectAccessor<1, dim>::MGDoFObjectAccessor (Triangulation *tria, - const int level, - const int index, - const AccessorData *local_data) : + const int level, + const int index, + const AccessorData *local_data) : MGDoFAccessor (local_data), - MGDoFObjectAccessor_Inheritance<1,dim>::BaseClass(tria,level,index,local_data) {}; + MGDoFObjectAccessor_Inheritance<1,dim>::BaseClass(tria,level,index,local_data) +{}; template -int MGDoFObjectAccessor<1, dim>::mg_dof_index (const unsigned int i) const { +int MGDoFObjectAccessor<1, dim>::mg_dof_index (const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -51,7 +53,8 @@ int MGDoFObjectAccessor<1, dim>::mg_dof_index (const unsigned int i) const { template void MGDoFObjectAccessor<1, dim>::set_mg_dof_index (const unsigned int i, - const int index) const { + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -69,7 +72,8 @@ void MGDoFObjectAccessor<1, dim>::set_mg_dof_index (const unsigned int i, template int MGDoFObjectAccessor<1, dim>::mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i) const { + const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -85,8 +89,9 @@ int MGDoFObjectAccessor<1, dim>::mg_vertex_dof_index (const unsigned int vertex, template void MGDoFObjectAccessor<1, dim>::set_mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const int index) const { + const unsigned int i, + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -102,7 +107,8 @@ void MGDoFObjectAccessor<1, dim>::set_mg_vertex_dof_index (const unsigned int ve template void -MGDoFObjectAccessor<1, dim>::get_mg_dof_indices (vector &dof_indices) const { +MGDoFObjectAccessor<1, dim>::get_mg_dof_indices (vector &dof_indices) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -118,17 +124,50 @@ MGDoFObjectAccessor<1, dim>::get_mg_dof_indices (vector &dof_indices) const *next++ = mg_vertex_dof_index(vertex,d); for (unsigned int d=0; d +template +void +MGDoFObjectAccessor<1,dim>::get_mg_dof_values (const Vector &values, + Vector &dof_values) const +{ + Assert (dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); + Assert (mg_dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); + Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<1>::ExcVectorDoesNotMatch()); + Assert (values.size() == dof_handler->n_dofs(), + DoFAccessor<1>::ExcVectorDoesNotMatch()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line; + vector::iterator next_dof_value=dof_values.begin(); + for (unsigned int vertex=0; vertex<2; ++vertex) + for (unsigned int d=0; d TriaIterator > -MGDoFObjectAccessor<1, dim>::child (const unsigned int i) const { +MGDoFObjectAccessor<1, dim>::child (const unsigned int i) const +{ TriaIterator > q (tria, - present_level+1, - child_index (i), - mg_dof_handler); + present_level+1, + child_index (i), + mg_dof_handler); #ifdef DEBUG if (q.state() != past_the_end) @@ -165,7 +204,8 @@ MGDoFObjectAccessor<2, dim>::MGDoFObjectAccessor (Triangulation *tria, template inline -int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const { +int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -182,7 +222,8 @@ int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const { template void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i, - const int index) const { + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -200,7 +241,8 @@ void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i, template inline int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i) const { + const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -216,8 +258,9 @@ int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned int vertex, template void MGDoFObjectAccessor<2, dim>::set_mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const int index) const { + const unsigned int i, + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -233,7 +276,8 @@ void MGDoFObjectAccessor<2, dim>::set_mg_vertex_dof_index (const unsigned int ve template void -MGDoFObjectAccessor<2, dim>::get_mg_dof_indices (vector &dof_indices) const { +MGDoFObjectAccessor<2, dim>::get_mg_dof_indices (vector &dof_indices) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -254,13 +298,50 @@ MGDoFObjectAccessor<2, dim>::get_mg_dof_indices (vector &dof_indices) const *next++ = this->line(line)->mg_dof_index(d); for (unsigned int d=0; d +template +void +MGDoFObjectAccessor<2,dim>::get_mg_dof_values (const Vector &values, + Vector &dof_values) const +{ + Assert (dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (mg_dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<2>::ExcVectorDoesNotMatch()); + Assert (values.size() == mg_dof_handler->n_dofs(present_level), + DoFAccessor<2>::ExcVectorDoesNotMatch()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line, + dofs_per_quad = dof_handler->get_fe().dofs_per_quad; + vector::iterator next_dof_value=dof_values.begin(); + for (unsigned int vertex=0; vertex<4; ++vertex) + for (unsigned int d=0; dline(line)->mg_dof_index(d)); + for (unsigned int d=0; d TriaIterator > -MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const { +MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const +{ Assert (i<4, ExcIndexRange (i, 0, 4)); return TriaIterator > @@ -276,11 +357,12 @@ MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const { template TriaIterator > -MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const { +MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const +{ TriaIterator > q (tria, - present_level+1, - child_index (i), - mg_dof_handler); + present_level+1, + child_index (i), + mg_dof_handler); #ifdef DEBUG if (q.state() != past_the_end) @@ -293,7 +375,8 @@ MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const { template void -MGDoFObjectAccessor<2, dim>::copy_from (const MGDoFObjectAccessor<2, dim> &a) { +MGDoFObjectAccessor<2, dim>::copy_from (const MGDoFObjectAccessor<2, dim> &a) +{ DoFObjectAccessor<2, dim>::copy_from (a); set_mg_dof_handler (a.mg_dof_handler); }; @@ -305,17 +388,19 @@ MGDoFObjectAccessor<2, dim>::copy_from (const MGDoFObjectAccessor<2, dim> &a) { template MGDoFObjectAccessor<3, dim>::MGDoFObjectAccessor (Triangulation *tria, - const int level, - const int index, - const AccessorData *local_data) : + const int level, + const int index, + const AccessorData *local_data) : MGDoFAccessor (local_data), - MGDoFObjectAccessor_Inheritance<3,dim>::BaseClass(tria,level,index,local_data) {}; + MGDoFObjectAccessor_Inheritance<3,dim>::BaseClass(tria,level,index,local_data) +{}; template inline -int MGDoFObjectAccessor<3, dim>::mg_dof_index (const unsigned int i) const { +int MGDoFObjectAccessor<3, dim>::mg_dof_index (const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -332,7 +417,8 @@ int MGDoFObjectAccessor<3, dim>::mg_dof_index (const unsigned int i) const { template void MGDoFObjectAccessor<3, dim>::set_mg_dof_index (const unsigned int i, - const int index) const { + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); // make sure a FE has been selected @@ -350,7 +436,8 @@ void MGDoFObjectAccessor<3, dim>::set_mg_dof_index (const unsigned int i, template inline int MGDoFObjectAccessor<3, dim>::mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i) const { + const unsigned int i) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -366,8 +453,9 @@ int MGDoFObjectAccessor<3, dim>::mg_vertex_dof_index (const unsigned int vertex, template void MGDoFObjectAccessor<3, dim>::set_mg_vertex_dof_index (const unsigned int vertex, - const unsigned int i, - const int index) const { + const unsigned int i, + const int index) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -383,7 +471,8 @@ void MGDoFObjectAccessor<3, dim>::set_mg_vertex_dof_index (const unsigned int ve template void -MGDoFObjectAccessor<3, dim>::get_mg_dof_indices (vector &dof_indices) const { +MGDoFObjectAccessor<3, dim>::get_mg_dof_indices (vector &dof_indices) const +{ Assert (dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (mg_dof_handler != 0, DoFAccessor::ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, DoFAccessor::ExcInvalidObject()); @@ -409,6 +498,46 @@ MGDoFObjectAccessor<3, dim>::get_mg_dof_indices (vector &dof_indices) const *next++ = this->quad(quad)->mg_dof_index(d); for (unsigned int d=0; d +template +void +MGDoFObjectAccessor<3,dim>::get_mg_dof_values (const Vector &values, + Vector &dof_values) const +{ + Assert (dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (mg_dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (&dof_handler->get_fe() != 0, DoFAccessor<2>::ExcInvalidObject()); + Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, + DoFAccessor<3>::ExcVectorDoesNotMatch()); + Assert (values.size() == mg_dof_handler->n_dofs(present_level), + DoFAccessor<3>::ExcVectorDoesNotMatch()); + + const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, + dofs_per_line = dof_handler->get_fe().dofs_per_line, + dofs_per_quad = dof_handler->get_fe().dofs_per_quad, + dofs_per_hex = dof_handler->get_fe().dofs_per_hex; + vector::iterator next_dof_value=dof_values.begin(); + for (unsigned int vertex=0; vertex<8; ++vertex) + for (unsigned int d=0; dline(line)->mg_dof_index(d)); + for (unsigned int quad=0; quad<6; ++quad) + for (unsigned int d=0; dquad(quad)->mg_dof_index(d)); + for (unsigned int d=0; d::face (const unsigned int) const return face_iterator(); }; - - -template <> -void -MGDoFCellAccessor<1>::get_mg_dof_values (const Vector &values, - Vector &dof_values) const { - Assert (dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); - Assert (mg_dof_handler != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor<1>::DoFAccessor<1>::ExcInvalidObject()); - Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, - ExcVectorDoesNotMatch()); - Assert (values.size() == dof_handler->n_dofs(), - ExcVectorDoesNotMatch()); - - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line; - vector::iterator next_dof_value=dof_values.begin(); - for (unsigned int vertex=0; vertex<2; ++vertex) - for (unsigned int d=0; d::face (const unsigned int i) const return line(i); }; +#endif + -template <> + + +// explicit instantiations + +template void -MGDoFCellAccessor<2>::get_mg_dof_values (const Vector &values, - Vector &dof_values) const { - Assert (dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); - Assert (mg_dof_handler != 0, DoFAccessor<2>::ExcInvalidObject()); - Assert (&dof_handler->get_fe() != 0, DoFAccessor<2>::ExcInvalidObject()); - Assert (dof_values.size() == dof_handler->get_fe().dofs_per_cell, - DoFAccessor<2>::ExcVectorDoesNotMatch()); - Assert (values.size() == mg_dof_handler->n_dofs(present_level), - DoFAccessor<2>::ExcVectorDoesNotMatch()); +MGDoFObjectAccessor<1,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; - const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, - dofs_per_line = dof_handler->get_fe().dofs_per_line, - dofs_per_quad = dof_handler->get_fe().dofs_per_quad; - vector::iterator next_dof_value=dof_values.begin(); - for (unsigned int vertex=0; vertex<4; ++vertex) - for (unsigned int d=0; dline(line)->mg_dof_index(d)); - for (unsigned int d=0; d:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + + + +#if deal_II_dimension >= 2 + +template +void +MGDoFObjectAccessor<2,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + +template +void +MGDoFObjectAccessor<2,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; #endif +#if deal_II_dimension >= 3 + +template +void +MGDoFObjectAccessor<3,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; +template +void +MGDoFObjectAccessor<3,deal_II_dimension>:: +get_mg_dof_values (const Vector &values, + Vector &dof_values) const; + +#endif -// explicit instantiations #if deal_II_dimension == 1 template class MGDoFObjectAccessor<1, 1>; template class MGDoFCellAccessor<1>; -- 2.39.5