From 574c41753c62d8524018649dcab58da1cb8cac7a Mon Sep 17 00:00:00 2001 From: Daniel Arndt Date: Wed, 20 Mar 2019 16:20:44 +0100 Subject: [PATCH] Remove IndexSet overloads in DataOut --- .../incompatibilities/20190320DanielArndt | 4 + examples/step-41/step-41.cc | 14 +- examples/step-42/step-42.cc | 25 +- include/deal.II/fe/fe_values.h | 20 +- include/deal.II/numerics/data_out_dof_data.h | 8 +- source/fe/fe_values.inst.in | 292 ------------------ source/numerics/data_out_dof_data.inst.in | 76 ----- .../numerics/data_out_dof_data_codim.inst.in | 30 -- 8 files changed, 34 insertions(+), 435 deletions(-) create mode 100644 doc/news/changes/incompatibilities/20190320DanielArndt diff --git a/doc/news/changes/incompatibilities/20190320DanielArndt b/doc/news/changes/incompatibilities/20190320DanielArndt new file mode 100644 index 0000000000..e4cc41414b --- /dev/null +++ b/doc/news/changes/incompatibilities/20190320DanielArndt @@ -0,0 +1,4 @@ +Removed: The IndexSet instantiations for FEValues::get_function_values() +and DataOut_DoFData::add_data_vector() have been removed. +
+(Daniel Arndt, 2019/03/20) diff --git a/examples/step-41/step-41.cc b/examples/step-41/step-41.cc index 41d2e233ae..662829c150 100644 --- a/examples/step-41/step-41.cc +++ b/examples/step-41/step-41.cc @@ -101,6 +101,7 @@ namespace Step41 TrilinosWrappers::SparseMatrix complete_system_matrix; TrilinosWrappers::MPI::Vector solution; + TrilinosWrappers::MPI::Vector active_set_vector; TrilinosWrappers::MPI::Vector system_rhs; TrilinosWrappers::MPI::Vector complete_system_rhs; TrilinosWrappers::MPI::Vector diagonal_of_mass_matrix; @@ -261,6 +262,7 @@ namespace Step41 IndexSet solution_index_set = dof_handler.locally_owned_dofs(); solution.reinit(solution_index_set, MPI_COMM_WORLD); + active_set_vector.reinit(solution_index_set, MPI_COMM_WORLD); system_rhs.reinit(solution_index_set, MPI_COMM_WORLD); complete_system_rhs.reinit(solution_index_set, MPI_COMM_WORLD); contact_force.reinit(solution_index_set, MPI_COMM_WORLD); @@ -542,6 +544,10 @@ namespace Step41 BoundaryValues(), constraints); constraints.close(); + + active_set_vector = 0.; + for (const auto index : active_set) + active_set_vector[index] = 1.; } // @sect4{ObstacleProblem::solve} @@ -576,11 +582,7 @@ namespace Step41 // @sect4{ObstacleProblem::output_results} // We use the vtk-format for the output. The file contains the displacement - // and a numerical representation of the active set. The function looks - // standard but note that we can add an IndexSet object to the DataOut - // object in exactly the same way as a regular solution vector: it is simply - // interpreted as a function that is either zero (when a degree of freedom - // is not part of the IndexSet) or one (if it is). + // and a numerical representation of the active set. template void ObstacleProblem::output_results(const unsigned int iteration) const { @@ -590,7 +592,7 @@ namespace Step41 data_out.attach_dof_handler(dof_handler); data_out.add_data_vector(solution, "displacement"); - data_out.add_data_vector(active_set, "active_set"); + data_out.add_data_vector(active_set_vector, "active_set"); data_out.add_data_vector(contact_force, "lambda"); data_out.build_patches(); diff --git a/examples/step-42/step-42.cc b/examples/step-42/step-42.cc index 94cc9e445a..ec2b52df79 100644 --- a/examples/step-42/step-42.cc +++ b/examples/step-42/step-42.cc @@ -701,6 +701,7 @@ namespace Step42 TrilinosWrappers::SparseMatrix newton_matrix; TrilinosWrappers::MPI::Vector solution; + TrilinosWrappers::MPI::Vector active_set_vector; TrilinosWrappers::MPI::Vector newton_rhs; TrilinosWrappers::MPI::Vector newton_rhs_uncondensed; TrilinosWrappers::MPI::Vector diag_mass_matrix_vector; @@ -1022,6 +1023,7 @@ namespace Step42 { TimerOutput::Scope t(computing_timer, "Setup: vectors"); solution.reinit(locally_relevant_dofs, mpi_communicator); + active_set_vector.reinit(locally_relevant_dofs, MPI_COMM_WORLD); newton_rhs.reinit(locally_owned_dofs, mpi_communicator); newton_rhs_uncondensed.reinit(locally_owned_dofs, mpi_communicator); diag_mass_matrix_vector.reinit(locally_owned_dofs, mpi_communicator); @@ -1339,6 +1341,14 @@ namespace Step42 all_constraints.close(); all_constraints.merge(constraints_dirichlet_and_hanging_nodes); + // We misuse distributed_solution for updating active_set_vector. + // We can do that because distributed_solution has a compatible underlying + // IndexSet and we don't need the vector anymore. + distributed_solution = 0.; + for (const auto index : active_set) + distributed_solution[index] = 1.; + active_set_vector = distributed_solution; + pcout << " Size of active set: " << Utilities::MPI::sum((active_set & locally_owned_dofs).n_elements(), mpi_communicator) @@ -1388,13 +1398,9 @@ namespace Step42 std::vector local_dof_indices(dofs_per_cell); - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - const FEValuesExtractors::Vector displacement(0); - for (; cell != endc; ++cell) + for (const auto &cell : dof_handler.active_cell_iterators()) if (cell->is_locally_owned()) { fe_values.reinit(cell); @@ -1553,10 +1559,9 @@ namespace Step42 fraction_of_plastic_q_points_per_cell = 0; - typename DoFHandler::active_cell_iterator cell = - dof_handler.begin_active(), - endc = dof_handler.end(); - unsigned int cell_number = 0; + auto cell = dof_handler.begin_active(); + const auto endc = dof_handler.end(); + unsigned int cell_number = 0; for (; cell != endc; ++cell, ++cell_number) if (cell->is_locally_owned()) { @@ -2048,7 +2053,7 @@ namespace Step42 std::vector(dim, "contact_force"), DataOut::type_dof_data, data_component_interpretation); - data_out.add_data_vector(active_set, + data_out.add_data_vector(active_set_vector, std::vector(dim, "active_set"), DataOut::type_dof_data, data_component_interpretation); diff --git a/include/deal.II/fe/fe_values.h b/include/deal.II/fe/fe_values.h index 713f1c64ad..d810d3b6fb 100644 --- a/include/deal.II/fe/fe_values.h +++ b/include/deal.II/fe/fe_values.h @@ -2290,9 +2290,7 @@ public: * Vector<T>, BlockVector<T>, or one of the PETSc or Trilinos * vector wrapper classes. It represents a global vector of DoF values * associated with the DoFHandler object with which this FEValues object was - * last initialized. Alternatively, if the vector argument is of type - * IndexSet, then the function is represented as one that is either zero or - * one, depending on whether a DoF index is in the set or not. + * last initialized. * * @dealiiRequiresUpdateFlags{update_values} */ @@ -2449,9 +2447,7 @@ public: * Vector<T>, BlockVector<T>, or one of the PETSc or Trilinos * vector wrapper classes. It represents a global vector of DoF values * associated with the DoFHandler object with which this FEValues object was - * last initialized. Alternatively, if the vector argument is of type - * IndexSet, then the function is represented as one that is either zero or - * one, depending on whether a DoF index is in the set or not. + * last initialized. * * @dealiiRequiresUpdateFlags{update_gradients} */ @@ -2554,9 +2550,7 @@ public: * Vector<T>, BlockVector<T>, or one of the PETSc or Trilinos * vector wrapper classes. It represents a global vector of DoF values * associated with the DoFHandler object with which this FEValues object was - * last initialized. Alternatively, if the vector argument is of type - * IndexSet, then the function is represented as one that is either zero or - * one, depending on whether a DoF index is in the set or not. + * last initialized. * * @dealiiRequiresUpdateFlags{update_hessians} */ @@ -2657,9 +2651,7 @@ public: * Vector<T>, BlockVector<T>, or one of the PETSc or Trilinos * vector wrapper classes. It represents a global vector of DoF values * associated with the DoFHandler object with which this FEValues object was - * last initialized. Alternatively, if the vector argument is of type - * IndexSet, then the function is represented as one that is either zero or - * one, depending on whether a DoF index is in the set or not. + * last initialized. * * @dealiiRequiresUpdateFlags{update_hessians} */ @@ -2772,9 +2764,7 @@ public: * Vector<T>, BlockVector<T>, or one of the PETSc or Trilinos * vector wrapper classes. It represents a global vector of DoF values * associated with the DoFHandler object with which this FEValues object was - * last initialized. Alternatively, if the vector argument is of type - * IndexSet, then the function is represented as one that is either zero or - * one, depending on whether a DoF index is in the set or not. + * last initialized. * * @dealiiRequiresUpdateFlags{update_3rd_derivatives} */ diff --git a/include/deal.II/numerics/data_out_dof_data.h b/include/deal.II/numerics/data_out_dof_data.h index ea11144f7e..cdf385c1cc 100644 --- a/include/deal.II/numerics/data_out_dof_data.h +++ b/include/deal.II/numerics/data_out_dof_data.h @@ -730,9 +730,7 @@ public: * * @note The actual type for the vector argument may be any vector type from * which FEValues can extract values on a cell using the - * FEValuesBase::get_function_values() function. In particular, this - * includes all of the usual vector types, but also IndexSet (see step-41 - * for a use of this). + * FEValuesBase::get_function_values() function. */ template void @@ -824,9 +822,7 @@ public: * * @note The actual type for the vector argument may be any vector type from * which FEValues can extract values on a cell using the - * FEValuesBase::get_function_values() function. In particular, this - * includes all of the usual vector types, but also IndexSet (see step-41 - * for a use of this). + * FEValuesBase::get_function_values() function. * * @note The DataPostprocessor object (i.e., in reality the object of your * derived class) has to live until the DataOut object is destroyed as the diff --git a/source/fe/fe_values.inst.in b/source/fe/fe_values.inst.in index 863a55f233..5073c4d06b 100644 --- a/source/fe/fe_values.inst.in +++ b/source/fe/fe_values.inst.in @@ -485,295 +485,3 @@ for (VEC : VECTOR_TYPES; deal_II_dimension : DIMENSIONS; #endif } - - -// instantiations for VEC=IndexSet - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) - { -#if deal_II_dimension <= deal_II_space_dimension - template void - FEValuesViews::Scalar:: - get_function_values( - const dealii::IndexSet &, - std::vector::type> &) const; - template void - FEValuesViews::Scalar:: - get_function_gradients( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Scalar:: - get_function_hessians( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Scalar:: - get_function_laplacians( - const dealii::IndexSet &, - std::vector::type> &) const; - template void - FEValuesViews::Scalar:: - get_function_third_derivatives( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - - template void - FEValuesViews::Vector:: - get_function_values( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_gradients( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_symmetric_gradients( - const dealii::IndexSet &, - std::vector>::type> &) const; - template void - FEValuesViews::Vector:: - get_function_curls( - const dealii::IndexSet &, - std::vector::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_divergences( - const dealii::IndexSet &, - std::vector::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_hessians( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_laplacians( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Vector:: - get_function_third_derivatives( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - - template void FEValuesViews::SymmetricTensor<2, - deal_II_dimension, - deal_II_space_dimension>:: - get_function_values( - const dealii::IndexSet &, - std::vector>::type> &) const; - template void FEValuesViews:: - SymmetricTensor<2, deal_II_dimension, deal_II_space_dimension>:: - get_function_divergences( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - - template void - FEValuesViews::Tensor<2, deal_II_dimension, deal_II_space_dimension>:: - get_function_values( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Tensor<2, deal_II_dimension, deal_II_space_dimension>:: - get_function_divergences( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; - template void - FEValuesViews::Tensor<2, deal_II_dimension, deal_II_space_dimension>:: - get_function_gradients( - const dealii::IndexSet &, - std::vector< - ProductType>::type> &) - const; -#endif - } - - - -// Instantiations of functions in FEValuesBase and IndexSet=IndexSet - -for (deal_II_dimension : DIMENSIONS; deal_II_space_dimension : DIMENSIONS) - { -#if deal_II_dimension <= deal_II_space_dimension - template void FEValuesBase:: - get_function_values(const IndexSet &, - std::vector &) const; - template void FEValuesBase:: - get_function_values( - const IndexSet &, - const ArrayView &, - std::vector &) const; - - template void FEValuesBase:: - get_function_values(const IndexSet &, - std::vector> &) - const; - - template void FEValuesBase:: - get_function_values( - const IndexSet &, - const ArrayView &, - std::vector> &) const; - - template void FEValuesBase:: - get_function_values( - const IndexSet &, - const ArrayView &, - ArrayView>, - bool) const; - - template void FEValuesBase:: - get_function_gradients( - const IndexSet &, - std::vector< - dealii::Tensor<1, deal_II_space_dimension, IndexSet::value_type>> &) - const; - template void FEValuesBase:: - get_function_gradients( - const IndexSet &, - const ArrayView &, - std::vector< - dealii::Tensor<1, deal_II_space_dimension, IndexSet::value_type>> &) - const; - - template void FEValuesBase:: - get_function_gradients( - const IndexSet &, - std::vector>> &) - const; - template void FEValuesBase:: - get_function_gradients( - const IndexSet &, - const ArrayView &, - ArrayView>>, - bool) const; - - template void FEValuesBase:: - get_function_hessians( - const IndexSet &, - std::vector< - dealii::Tensor<2, deal_II_space_dimension, IndexSet::value_type>> &) - const; - template void FEValuesBase:: - get_function_hessians( - const IndexSet &, - const ArrayView &, - std::vector< - dealii::Tensor<2, deal_II_space_dimension, IndexSet::value_type>> &) - const; - - template void FEValuesBase:: - get_function_hessians( - const IndexSet &, - std::vector>> &, - bool) const; - template void FEValuesBase:: - get_function_hessians( - const IndexSet &, - const ArrayView &, - ArrayView>>, - bool) const; - - template void FEValuesBase:: - get_function_laplacians(const IndexSet &, - std::vector &) - const; - template void FEValuesBase:: - get_function_laplacians( - const IndexSet &, - const ArrayView &, - std::vector &) const; - - template void FEValuesBase:: - get_function_laplacians( - const IndexSet &, std::vector> &) const; - - template void FEValuesBase:: - get_function_laplacians( - const IndexSet &, - const ArrayView &, - std::vector> &) const; - - template void FEValuesBase:: - get_function_laplacians( - const IndexSet &, - const ArrayView &, - std::vector> &, - bool) const; - - template void FEValuesBase:: - get_function_third_derivatives( - const IndexSet &, - std::vector< - dealii::Tensor<3, deal_II_space_dimension, IndexSet::value_type>> &) - const; - template void FEValuesBase:: - get_function_third_derivatives( - const IndexSet &, - const ArrayView &, - std::vector< - dealii::Tensor<3, deal_II_space_dimension, IndexSet::value_type>> &) - const; - - template void FEValuesBase:: - get_function_third_derivatives( - const IndexSet &, - std::vector>> &, - bool) const; - template void FEValuesBase:: - get_function_third_derivatives( - const IndexSet &, - const ArrayView &, - ArrayView>>, - bool) const; -#endif - } diff --git a/source/numerics/data_out_dof_data.inst.in b/source/numerics/data_out_dof_data.inst.in index 1d2cf2612d..ecc15cb360 100644 --- a/source/numerics/data_out_dof_data.inst.in +++ b/source/numerics/data_out_dof_data.inst.in @@ -93,82 +93,6 @@ for (VEC : VECTOR_TYPES; DH : DOFHANDLER_TEMPLATES; -for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) - { - template void DataOut_DoFData, - deal_II_dimension, - deal_II_dimension>:: - add_data_vector_internal( - const DH *, - const IndexSet &, - const std::vector &, - const DataVectorType, - const std::vector< - DataComponentInterpretation::DataComponentInterpretation> &, - const bool); - - template void DataOut_DoFData, - deal_II_dimension, - deal_II_dimension>:: - add_data_vector( - const DH &, - const IndexSet &, - const DataPostprocessor< - DH::space_dimension> &); - - - - // stuff needed for face data - - template void DataOut_DoFData, - deal_II_dimension - 1, - deal_II_dimension>:: - add_data_vector_internal( - const DH *, - const IndexSet &, - const std::vector &, - const DataVectorType, - const std::vector< - DataComponentInterpretation::DataComponentInterpretation> &, - const bool); - - template void DataOut_DoFData, - deal_II_dimension - 1, - deal_II_dimension>:: - add_data_vector( - const DH &, - const IndexSet &, - const DataPostprocessor< - DH::space_dimension> &); - - // things for DataOutRotation - -#if deal_II_dimension < 3 - template void DataOut_DoFData, - deal_II_dimension + 1, - deal_II_dimension + 1>:: - add_data_vector_internal( - const DH *, - const IndexSet &, - const std::vector &, - const DataVectorType, - const std::vector< - DataComponentInterpretation::DataComponentInterpretation> &, - const bool); - - template void DataOut_DoFData, - deal_II_dimension + 1, - deal_II_dimension + 1>:: - add_data_vector( - const DH &, - const IndexSet &, - const DataPostprocessor< - DH::space_dimension> &); -#endif - } - - - for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) { template class DataOut_DoFData, deal_II_dimension>; diff --git a/source/numerics/data_out_dof_data_codim.inst.in b/source/numerics/data_out_dof_data_codim.inst.in index f5ae7d5b7c..005f78bccd 100644 --- a/source/numerics/data_out_dof_data_codim.inst.in +++ b/source/numerics/data_out_dof_data_codim.inst.in @@ -55,36 +55,6 @@ for (VEC : REAL_VECTOR_TYPES; DH : DOFHANDLER_TEMPLATES; -for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS; - deal_II_space_dimension : DIMENSIONS) - { -#if deal_II_dimension < deal_II_space_dimension - template void - DataOut_DoFData, - deal_II_dimension, - deal_II_space_dimension>:: - add_data_vector_internal( - const DH *, - const IndexSet &, - const std::vector &, - const DataVectorType, - const std::vector< - DataComponentInterpretation::DataComponentInterpretation> &, - const bool); - - template void - DataOut_DoFData, - deal_II_dimension, - deal_II_space_dimension>:: - add_data_vector( - const IndexSet &, - const DataPostprocessor< - DH::space_dimension> &); -#endif - } - - - for (DH : DOFHANDLER_TEMPLATES; deal_II_dimension : DIMENSIONS) { #if deal_II_dimension < 3 -- 2.39.5