From: Daniel Arndt Date: Wed, 5 Oct 2016 14:04:09 +0000 (+0200) Subject: Fix ExtrapolateImplementation for arbitrary VectorTypes X-Git-Tag: v8.5.0-rc1~592^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3206%2Fhead;p=dealii.git Fix ExtrapolateImplementation for arbitrary VectorTypes --- diff --git a/include/deal.II/distributed/tria.h b/include/deal.II/distributed/tria.h index 6047b034f2..c27d48243d 100644 --- a/include/deal.II/distributed/tria.h +++ b/include/deal.II/distributed/tria.h @@ -68,7 +68,7 @@ namespace FETools { namespace internal { - template class ExtrapolateImplementation; + template class ExtrapolateImplementation; } } @@ -887,7 +887,7 @@ namespace parallel template friend class dealii::internal::DoFHandler::Policy::ParallelDistributed; - template friend class dealii::FETools::internal::ExtrapolateImplementation; + template friend class dealii::FETools::internal::ExtrapolateImplementation; }; diff --git a/source/fe/fe_tools_extrapolate.cc b/source/fe/fe_tools_extrapolate.cc index 8c4970d2e8..47c566a833 100755 --- a/source/fe/fe_tools_extrapolate.cc +++ b/source/fe/fe_tools_extrapolate.cc @@ -41,7 +41,7 @@ namespace FETools { #ifndef DEAL_II_WITH_P4EST // Dummy implementation in case p4est is not available. - template + template class ExtrapolateImplementation { public: @@ -51,7 +51,7 @@ namespace FETools Assert(false, ExcNotImplemented()); }; - template + template void extrapolate_parallel (const InVector &/*u2_relevant*/, const DoFHandler &/*dof2*/, OutVector &/*u2*/) @@ -62,7 +62,7 @@ namespace FETools #else // Implementation of the @p extrapolate function // on parallel distributed grids. - template + template class ExtrapolateImplementation { public: @@ -71,12 +71,14 @@ namespace FETools ~ExtrapolateImplementation (); - template + template void extrapolate_parallel (const InVector &u2_relevant, const DoFHandler &dof2, OutVector &u2); private: + // A shortcut for the type of the OutVector + typedef typename OutVector::value_type value_type; // A structure holding all data to // set dofs recursively on cells of arbitrary level @@ -112,7 +114,7 @@ namespace FETools CellData (const unsigned int dofs_per_cell); - Vector dof_values; + Vector dof_values; unsigned int tree_index; @@ -131,7 +133,7 @@ namespace FETools unsigned int bytes_for_buffer () const { return (sizeof(unsigned int) + // dofs_per_cell - dof_values.size() * sizeof(double) + // dof_values + dof_values.size() * sizeof(value_type) + // dof_values sizeof(unsigned int) + // tree_index sizeof(typename dealii::internal::p4est::types::quadrant)); // quadrant } @@ -146,8 +148,8 @@ namespace FETools std::memcpy(ptr, &n_dofs, sizeof(unsigned int)); ptr += sizeof(unsigned int); - std::memcpy(ptr,dof_values.begin(),n_dofs*sizeof(double)); - ptr += n_dofs*sizeof(double); + std::memcpy(ptr,dof_values.begin(),n_dofs*sizeof(value_type)); + ptr += n_dofs*sizeof(value_type); std::memcpy(ptr,&tree_index,sizeof(unsigned int)); ptr += sizeof(unsigned int); @@ -167,8 +169,8 @@ namespace FETools ptr += sizeof(unsigned int); dof_values.reinit(n_dofs); - std::memcpy(dof_values.begin(),ptr,n_dofs * sizeof(double)); - ptr += n_dofs * sizeof(double); + std::memcpy(dof_values.begin(),ptr,n_dofs * sizeof(value_type)); + ptr += n_dofs * sizeof(value_type); std::memcpy(&tree_index,ptr,sizeof(unsigned int)); ptr += sizeof(unsigned int); @@ -237,7 +239,7 @@ namespace FETools // the cells of this tree and // interpolate over patches which // are part of this process - template + template void interpolate_recursively (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, @@ -251,22 +253,21 @@ namespace FETools // if a child is reached which // is not part of this process // a new need is created - template + template void get_interpolated_dof_values (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, const typename DoFHandler::cell_iterator &dealii_cell, const typename dealii::internal::p4est::types::quadrant &p4est_cell, const InVector &u, - Vector &interpolated_values, + Vector &interpolated_values, std::vector &new_needs); // set dof values for this // cell by interpolation - template void set_dof_values_by_interpolation (const typename DoFHandler::cell_iterator &dealii_cell, const typename dealii::internal::p4est::types::quadrant &p4est_cell, - const Vector &interpolated_values, + const Vector &interpolated_values, OutVector &u); // compute all cell_data @@ -368,8 +369,8 @@ namespace FETools unsigned int round; }; - template <> - class ExtrapolateImplementation<1,1> + template + class ExtrapolateImplementation<1,1,OutVector> { public: @@ -381,15 +382,15 @@ namespace FETools ~ExtrapolateImplementation () {} - template + template void extrapolate_parallel (const InVector &/*u2_relevant*/, const DoFHandler<1,1> &/*dof2*/, OutVector &/*u2*/) {} }; - template <> - class ExtrapolateImplementation<1,2> + template + class ExtrapolateImplementation<1,2,OutVector> { public: @@ -401,15 +402,15 @@ namespace FETools ~ExtrapolateImplementation () {} - template + template void extrapolate_parallel (const InVector &/*u2_relevant*/, const DoFHandler<1,2> &/*dof2*/, OutVector &/*u2*/) {} }; - template <> - class ExtrapolateImplementation<1,3> + template + class ExtrapolateImplementation<1,3,OutVector> { public: @@ -421,7 +422,7 @@ namespace FETools ~ExtrapolateImplementation () {} - template + template void extrapolate_parallel (const InVector &/*u2_relevant*/, const DoFHandler<1,3> &/*dof2*/, OutVector &/*u2*/) @@ -430,23 +431,23 @@ namespace FETools - template - ExtrapolateImplementation:: + template + ExtrapolateImplementation:: ExtrapolateImplementation () : round(0) {} - template - ExtrapolateImplementation:: + template + ExtrapolateImplementation:: ~ExtrapolateImplementation () {} - template - ExtrapolateImplementation:: + template + ExtrapolateImplementation:: CellData::CellData () : tree_index (0), receiver (0) @@ -454,8 +455,8 @@ namespace FETools - template - ExtrapolateImplementation:: + template + ExtrapolateImplementation:: CellData::CellData (const unsigned int dofs_per_cell) : tree_index (0), receiver (0) @@ -465,10 +466,10 @@ namespace FETools - template - template + template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: interpolate_recursively (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, @@ -541,17 +542,17 @@ namespace FETools - template - template + template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: get_interpolated_dof_values (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, const typename DoFHandler::cell_iterator &dealii_cell, const typename dealii::internal::p4est::types::quadrant &p4est_cell, const InVector &u, - Vector &interpolated_values, + Vector &interpolated_values, std::vector &new_needs) { if (!dealii_cell->has_children ()) @@ -581,8 +582,8 @@ namespace FETools Assert (u.size() == dealii_cell->get_dof_handler().n_dofs(), ExcDimensionMismatch(u.size(), dealii_cell->get_dof_handler().n_dofs())); - Vector tmp1(dofs_per_cell); - Vector tmp2(dofs_per_cell); + Vector tmp1(dofs_per_cell); + Vector tmp2(dofs_per_cell); interpolated_values = 0; std::vector restriction_is_additive (dofs_per_cell); @@ -656,7 +657,7 @@ namespace FETools // and add up or set them in the output vector for (unsigned int i=0; i - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: set_dof_values_by_interpolation (const typename DoFHandler::cell_iterator &dealii_cell, const typename dealii::internal::p4est::types::quadrant &p4est_cell, - const Vector &local_values, + const Vector &local_values, OutVector &u) { const FiniteElement &fe = dealii_cell->get_dof_handler().get_fe(); @@ -708,7 +708,7 @@ namespace FETools Assert (u.size() == dealii_cell->get_dof_handler().n_dofs(), ExcDimensionMismatch(u.size(), dealii_cell->get_dof_handler().n_dofs())); - Vector tmp(dofs_per_cell); + Vector tmp(dofs_per_cell); typename dealii::internal::p4est::types::quadrant p4est_child[GeometryInfo::max_children_per_cell]; @@ -732,9 +732,9 @@ namespace FETools - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: compute_needs (const DoFHandler &dof2, std::vector &new_needs) { @@ -784,9 +784,9 @@ namespace FETools - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: traverse_tree_recursively (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, @@ -862,9 +862,9 @@ namespace FETools - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: traverse_patch_recursively (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, @@ -919,11 +919,10 @@ namespace FETools - - template + template template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: compute_cells (const DoFHandler &dof2, const InVector &u, std::vector &cells_to_compute, @@ -977,10 +976,10 @@ namespace FETools - template + template template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: compute_cells_in_tree_recursively (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::tree &tree, const typename dealii::internal::p4est::types::locidx &tree_index, @@ -1067,9 +1066,9 @@ namespace FETools - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: send_cells (const std::vector &cells_to_send, std::vector &received_cells) const { @@ -1133,9 +1132,9 @@ namespace FETools - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: add_new_need (const typename dealii::internal::p4est::types::forest &forest, const typename dealii::internal::p4est::types::locidx &tree_index, const typename DoFHandler::cell_iterator &dealii_cell, @@ -1159,9 +1158,9 @@ namespace FETools - template + template int - ExtrapolateImplementation:: + ExtrapolateImplementation:: cell_data_search (const CellData &cell_data, const std::vector &cells_list) { @@ -1178,9 +1177,9 @@ namespace FETools - template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: cell_data_insert (const CellData &cell_data, std::vector &cells_list) { @@ -1195,10 +1194,10 @@ namespace FETools - template + template template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: compute_all_non_local_data (const DoFHandler &dof2, const InVector &u) { @@ -1292,10 +1291,10 @@ namespace FETools - template - template + template + template void - ExtrapolateImplementation:: + ExtrapolateImplementation:: extrapolate_parallel (const InVector &u2_relevant, const DoFHandler &dof2, OutVector &u2) @@ -1605,7 +1604,7 @@ namespace FETools internal::reinit_ghosted(dof2, u3_relevant); u3_relevant = u3; - internal::ExtrapolateImplementation implementation; + internal::ExtrapolateImplementation implementation; implementation.extrapolate_parallel (u3_relevant, dof2, u2); } else diff --git a/tests/mpi/fe_tools_extrapolate_02.with_petsc=true.mpirun=1.output b/tests/mpi/fe_tools_extrapolate_02.with_petsc=true.with_petsc_with_complex=false.mpirun=1.output similarity index 100% rename from tests/mpi/fe_tools_extrapolate_02.with_petsc=true.mpirun=1.output rename to tests/mpi/fe_tools_extrapolate_02.with_petsc=true.with_petsc_with_complex=false.mpirun=1.output diff --git a/tests/mpi/fe_tools_extrapolate_02.with_petsc=true.mpirun=3.output b/tests/mpi/fe_tools_extrapolate_02.with_petsc=true.with_petsc_with_complex=false.mpirun=3.output similarity index 100% rename from tests/mpi/fe_tools_extrapolate_02.with_petsc=true.mpirun=3.output rename to tests/mpi/fe_tools_extrapolate_02.with_petsc=true.with_petsc_with_complex=false.mpirun=3.output