From: wolf Date: Wed, 10 Mar 1999 19:22:32 +0000 (+0000) Subject: Templatify some more functions on the data type of the vector they take. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be95ccd7b5ea202c10dcc447365afc25e58f4c90;p=dealii-svn.git Templatify some more functions on the data type of the vector they take. git-svn-id: https://svn.dealii.org/trunk@988 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/dof_accessor.h b/deal.II/deal.II/include/dofs/dof_accessor.h index ee9a549db4..6902d0f0fc 100644 --- a/deal.II/deal.II/include/dofs/dof_accessor.h +++ b/deal.II/deal.II/include/dofs/dof_accessor.h @@ -355,7 +355,7 @@ class DoFQuadAccessor : public DoFAccessor, public BaseClass { */ TriaIterator > > line (const unsigned int i) const; - + /** * Return the #i#th child as a DoF quad * iterator. This function is needed since @@ -759,8 +759,9 @@ class DoFCellAccessor : public DoFSubstructAccessor { * function is only callable for active * cells. */ - void get_dof_values (const Vector &values, - Vector &local_values) const; + template + void get_dof_values (const Vector &values, + Vector &local_values) const; /** * Return the interpolation of the given @@ -801,8 +802,13 @@ class DoFCellAccessor : public DoFSubstructAccessor { * what the this function does in these * cases. */ - void get_interpolated_dof_values (const Vector &values, - Vector &interpolated_values) const; + template + void get_interpolated_dof_values (const Vector &values, + Vector &interpolated_values) const; +// void get_interpolated_dof_values (const Vector &values, +// Vector &interpolated_values) const; +// void get_interpolated_dof_values (const Vector &values, +// Vector &interpolated_values) const; /** * This function is the counterpart to @@ -825,9 +831,10 @@ class DoFCellAccessor : public DoFSubstructAccessor { * * It is assumed that both vectors already * have the right size beforehand. - */ - void set_dof_values (const Vector &local_values, - Vector &values) const; + */ + template + void set_dof_values (const Vector &local_values, + Vector &values) const; /** * This, again, is the counterpart to @@ -882,8 +889,9 @@ class DoFCellAccessor : public DoFSubstructAccessor { * the prolongation matrices represent in * this case. */ - void set_dof_values_by_interpolation (const Vector &local_values, - Vector &values) const; + template + void set_dof_values_by_interpolation (const Vector &local_values, + Vector &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 3a6d94f78b..31afbea681 100644 --- a/deal.II/deal.II/source/dofs/dof_accessor.cc +++ b/deal.II/deal.II/source/dofs/dof_accessor.cc @@ -658,10 +658,28 @@ DoFCellAccessor<1>::face (const unsigned int) const { -template <> +/* 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<1>::get_dof_values (const Vector &values, - Vector &local_values) const { +DoFCellAccessor::get_dof_values (const Vector &values, + Vector &local_values) const { + Assert (dim==1, ::ExcInternalError()); + Assert (dof_handler != 0, ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, @@ -672,20 +690,41 @@ DoFCellAccessor<1>::get_dof_values (const Vector &values, 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_local_value=local_values.begin(); + typename vector::iterator next_local_value=local_values.begin(); for (unsigned int vertex=0; vertex<2; ++vertex) for (unsigned int d=0; d +/* 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<1>::set_dof_values (const Vector &local_values, - Vector &values) const { +DoFCellAccessor::set_dof_values (const Vector &local_values, + Vector &values) const { + Assert (dim==1, ::ExcInternalError()); + Assert (dof_handler != 0, ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, @@ -696,12 +735,15 @@ DoFCellAccessor<1>::set_dof_values (const Vector &local_values, const unsigned int dofs_per_vertex = dof_handler->get_fe().dofs_per_vertex, dofs_per_line = dof_handler->get_fe().dofs_per_line; - vector::const_iterator next_local_value=local_values.begin(); + typename vector::const_iterator next_local_value=local_values.begin(); for (unsigned int vertex=0; vertex<2; ++vertex) for (unsigned int d=0; d::face (const unsigned int i) const { -template <> +/* 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<2>::get_dof_values (const Vector &values, - Vector &local_values) const { +DoFCellAccessor::get_dof_values (const Vector &values, + Vector &local_values) const { + Assert (dim==2, ::ExcInternalError()); + Assert (dof_handler != 0, ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, @@ -735,7 +795,7 @@ DoFCellAccessor<2>::get_dof_values (const Vector &values, 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_local_value=local_values.begin(); + typename vector::iterator next_local_value=local_values.begin(); for (unsigned int vertex=0; vertex<4; ++vertex) for (unsigned int d=0; d::get_dof_values (const Vector &values, *next_local_value++ = values(this->line(line)->dof_index(d)); for (unsigned int d=0; d +/* 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<2>::set_dof_values (const Vector &local_values, - Vector &values) const { +DoFCellAccessor::set_dof_values (const Vector &local_values, + Vector &values) const { + Assert (dim==2, ::ExcInternalError()); + Assert (dof_handler != 0, ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, @@ -763,7 +844,7 @@ DoFCellAccessor<2>::set_dof_values (const Vector &local_values, 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::const_iterator next_local_value=local_values.begin(); + typename vector::const_iterator next_local_value=local_values.begin(); for (unsigned int vertex=0; vertex<4; ++vertex) for (unsigned int d=0; d::set_dof_values (const Vector &local_values, values(this->line(line)->dof_index(d)) = *next_local_value++; for (unsigned int d=0; d::face (const unsigned int i) const { -template <> +/* 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<3>::get_dof_values (const Vector &values, - Vector &local_values) const { +DoFCellAccessor::get_dof_values (const Vector &values, + Vector &local_values) const { + Assert (dim==3, ::ExcInternalError()); + Assert (dof_handler != 0, ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, @@ -806,26 +907,47 @@ DoFCellAccessor<3>::get_dof_values (const Vector &values, 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_local_value=local_values.begin(); - for (unsigned int vertex=0; vertex<8; ++vertex) + typename vector::iterator next_local_value = local_values.begin(); + for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) for (unsigned int d=0; d::lines_per_cell; ++line) for (unsigned int d=0; dline(line)->dof_index(d)); - for (unsigned int quad=0; quad<6; ++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 +/* 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<3>::set_dof_values (const Vector &local_values, - Vector &values) const { +DoFCellAccessor::set_dof_values (const Vector &local_values, + Vector &values) const { + Assert (dim==3, ::ExcInternalError()); + Assert (dof_handler != 0, ExcInvalidObject()); Assert (&dof_handler->get_fe() != 0, ExcInvalidObject()); Assert (local_values.size() == dof_handler->get_fe().total_dofs, @@ -838,18 +960,21 @@ DoFCellAccessor<3>::set_dof_values (const Vector &local_values, 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::const_iterator next_local_value=local_values.begin(); - for (unsigned int vertex=0; vertex<8; ++vertex) + typename vector::const_iterator next_local_value=local_values.begin(); + for (unsigned int vertex=0; vertex::vertices_per_cell; ++vertex) for (unsigned int d=0; d::lines_per_cell; ++line) for (unsigned int d=0; dline(line)->dof_index(d)) = *next_local_value++; - for (unsigned int quad=0; quad<6; ++quad) + for (unsigned int quad=0; quad::quads_per_cell; ++quad) for (unsigned int d=0; dquad(quad)->dof_index(d)) = *next_local_value++; for (unsigned int d=0; d::set_dof_values (const Vector &local_values, template +template void -DoFCellAccessor::get_interpolated_dof_values (const Vector &values, - Vector &interpolated_values) const { +DoFCellAccessor::get_interpolated_dof_values (const Vector &values, + Vector &interpolated_values) const { const unsigned int total_dofs = dof_handler->get_fe().total_dofs; Assert (dof_handler != 0, ExcInvalidObject()); @@ -879,8 +1005,8 @@ DoFCellAccessor::get_interpolated_dof_values (const Vector &values, else // otherwise clobber them from the children { - Vector tmp1(total_dofs); - Vector tmp2(total_dofs); + Vector tmp1(total_dofs); + Vector tmp2(total_dofs); interpolated_values.clear (); @@ -891,7 +1017,7 @@ DoFCellAccessor::get_interpolated_dof_values (const Vector &values, // child, if necessary by // interpolation itself this->child(child)->get_interpolated_dof_values (values, - tmp1); + tmp1); // interpolate these to the mother // cell dof_handler->get_fe().restrict(child).vmult (tmp2, tmp1); @@ -913,9 +1039,10 @@ DoFCellAccessor::get_interpolated_dof_values (const Vector &values, template +template void -DoFCellAccessor::set_dof_values_by_interpolation (const Vector &local_values, - Vector &values) const { +DoFCellAccessor::set_dof_values_by_interpolation (const Vector &local_values, + Vector &values) const { const unsigned int total_dofs = dof_handler->get_fe().total_dofs; Assert (dof_handler != 0, ExcInvalidObject()); @@ -932,7 +1059,7 @@ DoFCellAccessor::set_dof_values_by_interpolation (const Vector &loc else // otherwise distribute them to the children { - Vector tmp(total_dofs); + Vector tmp(total_dofs); for (unsigned int child=0; child::children_per_cell; ++child) @@ -952,6 +1079,45 @@ DoFCellAccessor::set_dof_values_by_interpolation (const Vector &loc // explicit instantiations + + +// for double +template +void +DoFCellAccessor::get_dof_values (const Vector &, + Vector &) const; +template +void +DoFCellAccessor::get_interpolated_dof_values (const Vector &, + Vector &) const; +template +void +DoFCellAccessor::set_dof_values (const Vector &, + Vector &) const; +template +void +DoFCellAccessor::set_dof_values_by_interpolation(const Vector &, + Vector &) const; +// for float +template +void +DoFCellAccessor::get_dof_values (const Vector &, + Vector &) const; +template +void +DoFCellAccessor::get_interpolated_dof_values (const Vector &, + Vector &) const; +template +void +DoFCellAccessor::set_dof_values (const Vector &, + Vector &) const; +template +void +DoFCellAccessor::set_dof_values_by_interpolation(const Vector &, + Vector &) const; + + + #if deal_II_dimension == 1 template class DoFLineAccessor<1,CellAccessor<1> >; template class DoFCellAccessor<1>;