From 90a71a7d606492b21a8eeb3dfd7c2447b578dbbb Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Wed, 18 Mar 2015 15:21:46 -0500 Subject: [PATCH] Address Timo's comments from review. Also rename namespace DataOutExceptions to Exceptions::DataOut. --- include/deal.II/numerics/data_out_dof_data.h | 198 ++++++++++--------- source/numerics/data_out.cc | 4 +- source/numerics/data_out_dof_data.cc | 60 +++--- source/numerics/data_out_faces.cc | 4 +- source/numerics/data_out_rotation.cc | 4 +- source/numerics/data_out_stack.cc | 18 +- 6 files changed, 146 insertions(+), 142 deletions(-) diff --git a/include/deal.II/numerics/data_out_dof_data.h b/include/deal.II/numerics/data_out_dof_data.h index f98c94d12f..4fe7467cb5 100644 --- a/include/deal.II/numerics/data_out_dof_data.h +++ b/include/deal.II/numerics/data_out_dof_data.h @@ -38,105 +38,109 @@ DEAL_II_NAMESPACE_OPEN template class FEValuesBase; -/** - * A namespace for exceptions that are used throughout the DataOut* - * collection of classes. - */ -namespace DataOutExceptions +namespace Exceptions { /** - * Exception + * A namespace for exceptions that are used throughout the DataOut* + * collection of classes. */ - DeclException1 (ExcInvalidNumberOfSubdivisions, - int, - << "The number of subdivisions per patch, " << arg1 - << ", is not valid. It needs to be greater or equal to " - "one, or zero if you want it to be determined " - "automatically."); + namespace DataOut + { + /** + * Exception + */ + DeclException1 (ExcInvalidNumberOfSubdivisions, + int, + << "The number of subdivisions per patch, " << arg1 + << ", is not valid. It needs to be greater or equal to " + "one, or zero if you want it to be determined " + "automatically."); - /** - * Exception - */ - DeclExceptionMsg (ExcNoTriangulationSelected, - "For the operation you are attempting, you first need to " - "tell the DataOut or related object which DoFHandler or " - "triangulation you would like to work on."); + /** + * Exception + */ + DeclExceptionMsg (ExcNoTriangulationSelected, + "For the operation you are attempting, you first need to " + "tell the DataOut or related object which DoFHandler or " + "triangulation you would like to work on."); - /** - * Exception - */ - DeclExceptionMsg (ExcNoDoFHandlerSelected, - "For the operation you are attempting, you first need to " - "tell the DataOut or related object which DoFHandler " - "you would like to work on."); + /** + * Exception + */ + DeclExceptionMsg (ExcNoDoFHandlerSelected, + "For the operation you are attempting, you first need to " + "tell the DataOut or related object which DoFHandler " + "you would like to work on."); - /** - * Exception - */ - DeclException3 (ExcInvalidVectorSize, - int, int, int, - << "The vector has size " << arg1 - << " but the DoFHandler object says that there are " << arg2 - << " degrees of freedom and there are " << arg3 - << " active cells. The size of your vector needs to be" - << " either equal to the number of degrees of freedom, or" - << " equal to the number of active cells."); - /** - * Exception - */ - DeclException2 (ExcInvalidCharacter, - std::string, size_t, - << "Please use only the characters [a-zA-Z0-9_<>()] for" << std::endl - << "description strings since some graphics formats will only accept these." - << std::endl - << "The string you gave was <" << arg1 - << ">, within which the invalid character is <" << arg1[arg2] - << ">." << std::endl); - /** - * Exception - */ - DeclExceptionMsg (ExcOldDataStillPresent, - "When attaching a triangulation or DoFHandler object, it is " - "not allowed if old data vectors are still referenced. If " - "you want to reuse an object of the current type, you first " - "need to call the 'clear_data_vector()' function."); - /** - * Exception - */ - DeclException2 (ExcInvalidNumberOfNames, - int, int, - << "You have to give one name per component in your " - << "data vector. The number you gave was " << arg1 - << ", but the number of components is " << arg2); - /** - * Exception - */ - DeclExceptionMsg (ExcIncompatibleDatasetNames, - "While merging sets of patches, the two sets to be merged " - "need to refer to data that agrees on the names of the " - "various variables represented. In other words, you " - "cannot merge sets of patches that originate from " - "entirely unrelated simulations."); - /** - * Exception - */ - DeclExceptionMsg (ExcIncompatiblePatchLists, - "While merging sets of patches, the two sets to be merged " - "need to refer to data that agrees on the number of " - "subdivisions and other properties. In other words, you " - "cannot merge sets of patches that originate from " - "entirely unrelated simulations."); - - DeclException2 (ExcInvalidVectorDeclaration, - int, std::string, - << "When declaring that a number of components in a data\n" - << "set to be output logically form a vector instead of\n" - << "simply a set of scalar fields, you need to specify\n" - << "this for all relevant components. Furthermore,\n" - << "vectors must always consist of exactly \n" - << "components. However, the vector component at\n" - << "position " << arg1 << " with name <" << arg2 - << "> does not satisfy these conditions."); + /** + * Exception + */ + DeclException3 (ExcInvalidVectorSize, + int, int, int, + << "The vector has size " << arg1 + << " but the DoFHandler object says that there are " << arg2 + << " degrees of freedom and there are " << arg3 + << " active cells. The size of your vector needs to be" + << " either equal to the number of degrees of freedom, or" + << " equal to the number of active cells."); + /** + * Exception + */ + DeclException2 (ExcInvalidCharacter, + std::string, size_t, + << "Please use only the characters [a-zA-Z0-9_<>()] for" << std::endl + << "description strings since some graphics formats will only accept these." + << std::endl + << "The string you gave was <" << arg1 + << ">, within which the invalid character is <" << arg1[arg2] + << ">." << std::endl); + /** + * Exception + */ + DeclExceptionMsg (ExcOldDataStillPresent, + "When attaching a triangulation or DoFHandler object, it is " + "not allowed if old data vectors are still referenced. If " + "you want to reuse an object of the current type, you first " + "need to call the 'clear_data_vector()' function."); + /** + * Exception + */ + DeclException2 (ExcInvalidNumberOfNames, + int, int, + << "You have to give one name per component in your " + << "data vector. The number you gave was " << arg1 + << ", but the number of components is " << arg2 + << "."); + /** + * Exception + */ + DeclExceptionMsg (ExcIncompatibleDatasetNames, + "While merging sets of patches, the two sets to be merged " + "need to refer to data that agrees on the names of the " + "various variables represented. In other words, you " + "cannot merge sets of patches that originate from " + "entirely unrelated simulations."); + /** + * Exception + */ + DeclExceptionMsg (ExcIncompatiblePatchLists, + "While merging sets of patches, the two sets to be merged " + "need to refer to data that agrees on the number of " + "subdivisions and other properties. In other words, you " + "cannot merge sets of patches that originate from " + "entirely unrelated simulations."); + + DeclException2 (ExcInvalidVectorDeclaration, + int, std::string, + << "When declaring that a number of components in a data " + << "set to be output logically form a vector instead of " + << "simply a set of scalar fields, you need to specify " + << "this for all relevant components. Furthermore, " + << "vectors must always consist of exactly " + << "components. However, the vector component at " + << "position " << arg1 << " with name <" << arg2 + << "> does not satisfy these conditions."); + } } @@ -895,17 +899,17 @@ merge_patches (const DataOut_DoFData &source, // check equality of component // names Assert (get_dataset_names() == source.get_dataset_names(), - DataOutExceptions::ExcIncompatibleDatasetNames()); + Exceptions::DataOut::ExcIncompatibleDatasetNames()); // make sure patches are compatible. we'll // assume that if the first respective // patches are ok that all the other ones // are ok as well Assert (patches[0].n_subdivisions == source_patches[0].n_subdivisions, - DataOutExceptions::ExcIncompatiblePatchLists()); + Exceptions::DataOut::ExcIncompatiblePatchLists()); Assert (patches[0].data.n_rows() == source_patches[0].data.n_rows(), - DataOutExceptions::ExcIncompatiblePatchLists()); + Exceptions::DataOut::ExcIncompatiblePatchLists()); Assert (patches[0].data.n_cols() == source_patches[0].data.n_cols(), - DataOutExceptions::ExcIncompatiblePatchLists()); + Exceptions::DataOut::ExcIncompatiblePatchLists()); // check equality of the vector data // specifications diff --git a/source/numerics/data_out.cc b/source/numerics/data_out.cc index 29397cf3ba..1722d1b715 100644 --- a/source/numerics/data_out.cc +++ b/source/numerics/data_out.cc @@ -322,13 +322,13 @@ void DataOut::build_patches (const Mappingtriangulation != 0, - DataOutExceptions::ExcNoTriangulationSelected()); + Exceptions::DataOut::ExcNoTriangulationSelected()); const unsigned int n_subdivisions = (n_subdivisions_ != 0) ? n_subdivisions_ : this->default_subdivisions; Assert (n_subdivisions >= 1, - DataOutExceptions::ExcInvalidNumberOfSubdivisions(n_subdivisions)); + Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions)); // First count the cells we want to create patches of. Also fill the object // that maps the cell indices to the patch numbers, as this will be needed diff --git a/source/numerics/data_out_dof_data.cc b/source/numerics/data_out_dof_data.cc index 5cd13670e7..4ab418af9b 100644 --- a/source/numerics/data_out_dof_data.cc +++ b/source/numerics/data_out_dof_data.cc @@ -326,10 +326,10 @@ namespace internal Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_<>()") == std::string::npos, - DataOutExceptions::ExcInvalidCharacter (names[i], - names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789_<>()"))); + Exceptions::DataOut::ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); } @@ -355,10 +355,10 @@ namespace internal Assert (names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789_<>()") == std::string::npos, - DataOutExceptions::ExcInvalidCharacter (names[i], - names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789_<>()"))); + Exceptions::DataOut::ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); } @@ -651,9 +651,9 @@ DataOut_DoFData:: attach_dof_handler (const DH &d) { Assert (dof_data.size() == 0, - DataOutExceptions::ExcOldDataStillPresent()); + Exceptions::DataOut::ExcOldDataStillPresent()); Assert (cell_data.size() == 0, - DataOutExceptions::ExcOldDataStillPresent()); + Exceptions::DataOut::ExcOldDataStillPresent()); triangulation = SmartPointer >(&d.get_tria(), typeid(*this).name()); dofs = SmartPointer(&d, typeid(*this).name()); @@ -667,9 +667,9 @@ DataOut_DoFData:: attach_triangulation (const Triangulation &tria) { Assert (dof_data.size() == 0, - DataOutExceptions::ExcOldDataStillPresent()); + Exceptions::DataOut::ExcOldDataStillPresent()); Assert (cell_data.size() == 0, - DataOutExceptions::ExcOldDataStillPresent()); + Exceptions::DataOut::ExcOldDataStillPresent()); triangulation = SmartPointer >(&tria, typeid(*this).name()); } @@ -688,7 +688,7 @@ add_data_vector (const VECTOR &vec, const std::vector &data_component_interpretation) { Assert (triangulation != 0, - DataOutExceptions::ExcNoTriangulationSelected ()); + Exceptions::DataOut::ExcNoTriangulationSelected ()); const unsigned int n_components = dofs != 0 ? dofs->get_fe().n_components () : 1; @@ -727,7 +727,7 @@ add_data_vector (const VECTOR &vec, const std::vector &data_component_interpretation_) { Assert (triangulation != 0, - DataOutExceptions::ExcNoTriangulationSelected ()); + Exceptions::DataOut::ExcNoTriangulationSelected ()); const std::vector & data_component_interpretation @@ -761,19 +761,19 @@ add_data_vector (const VECTOR &vec, ExcDimensionMismatch (vec.size(), triangulation->n_active_cells())); Assert (names.size() == 1, - DataOutExceptions::ExcInvalidNumberOfNames (names.size(), 1)); + Exceptions::DataOut::ExcInvalidNumberOfNames (names.size(), 1)); break; case type_dof_data: Assert (dofs != 0, - DataOutExceptions::ExcNoDoFHandlerSelected ()); + Exceptions::DataOut::ExcNoDoFHandlerSelected ()); Assert (vec.size() == dofs->n_dofs(), - DataOutExceptions::ExcInvalidVectorSize (vec.size(), - dofs->n_dofs(), - triangulation->n_active_cells())); + Exceptions::DataOut::ExcInvalidVectorSize (vec.size(), + dofs->n_dofs(), + triangulation->n_active_cells())); Assert (names.size() == dofs->get_fe().n_components(), - DataOutExceptions::ExcInvalidNumberOfNames (names.size(), - dofs->get_fe().n_components())); + Exceptions::DataOut::ExcInvalidNumberOfNames (names.size(), + dofs->get_fe().n_components())); break; case type_automatic: @@ -806,12 +806,12 @@ add_data_vector (const VECTOR &vec, // stuff and use a different constructor of DataEntry Assert (dofs != 0, - DataOutExceptions::ExcNoDoFHandlerSelected ()); + Exceptions::DataOut::ExcNoDoFHandlerSelected ()); Assert (vec.size() == dofs->n_dofs(), - DataOutExceptions::ExcInvalidVectorSize (vec.size(), - dofs->n_dofs(), - dofs->get_tria().n_active_cells())); + Exceptions::DataOut::ExcInvalidVectorSize (vec.size(), + dofs->n_dofs(), + dofs->get_tria().n_active_cells())); internal::DataOut::DataEntryBase *new_entry = new internal::DataOut::DataEntry(dofs, &vec, &data_postprocessor); @@ -1026,14 +1026,14 @@ DataOut_DoFData::get_vector_data_ranges () const // deal with vectors Assert (i+patch_space_dim <= (*d)->n_output_variables, - DataOutExceptions::ExcInvalidVectorDeclaration (i, - (*d)->names[i])); + Exceptions::DataOut::ExcInvalidVectorDeclaration (i, + (*d)->names[i])); for (unsigned int dd=1; dddata_component_interpretation[i+dd] == DataComponentInterpretation::component_is_part_of_vector, - DataOutExceptions::ExcInvalidVectorDeclaration (i, - (*d)->names[i])); + Exceptions::DataOut::ExcInvalidVectorDeclaration (i, + (*d)->names[i])); // all seems alright, so figure out // whether there is a common name @@ -1110,7 +1110,7 @@ DataOut_DoFData::get_finite_elements() const for (unsigned int i=0; idof_data.size(); ++i) { Assert (dof_data[i]->dof_handler != 0, - DataOutExceptions::ExcNoDoFHandlerSelected ()); + Exceptions::DataOut::ExcNoDoFHandlerSelected ()); // avoid creating too many finite elements and doing a lot of work on // initializing FEValues downstream: if two DoFHandlers are the same diff --git a/source/numerics/data_out_faces.cc b/source/numerics/data_out_faces.cc index 65c4d9d3f7..0768241e7c 100644 --- a/source/numerics/data_out_faces.cc +++ b/source/numerics/data_out_faces.cc @@ -284,10 +284,10 @@ void DataOutFaces::build_patches (const Mapping &mapping, : this->default_subdivisions; Assert (n_subdivisions >= 1, - DataOutExceptions::ExcInvalidNumberOfSubdivisions(n_subdivisions)); + Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions)); Assert (this->triangulation != 0, - DataOutExceptions::ExcNoTriangulationSelected()); + Exceptions::DataOut::ExcNoTriangulationSelected()); unsigned int n_datasets = this->cell_data.size(); for (unsigned int i=0; idof_data.size(); ++i) diff --git a/source/numerics/data_out_rotation.cc b/source/numerics/data_out_rotation.cc index 1f5e0c34fb..b643365b80 100644 --- a/source/numerics/data_out_rotation.cc +++ b/source/numerics/data_out_rotation.cc @@ -406,13 +406,13 @@ void DataOutRotation::build_patches (const unsigned int n_patches_per_ci // template parameter Assert (dim==dimension, ExcDimensionMismatch(dim, dimension)); Assert (this->triangulation != 0, - DataOutExceptions::ExcNoTriangulationSelected()); + Exceptions::DataOut::ExcNoTriangulationSelected()); const unsigned int n_subdivisions = (nnnn_subdivisions != 0) ? nnnn_subdivisions : this->default_subdivisions; Assert (n_subdivisions >= 1, - DataOutExceptions::ExcInvalidNumberOfSubdivisions(n_subdivisions)); + Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions)); unsigned int n_datasets=this->cell_data.size(); for (unsigned int i=0; idof_data.size(); ++i) diff --git a/source/numerics/data_out_stack.cc b/source/numerics/data_out_stack.cc index 8b9bc57ea4..07b95b1d8f 100644 --- a/source/numerics/data_out_stack.cc +++ b/source/numerics/data_out_stack.cc @@ -169,7 +169,7 @@ void DataOutStack::add_data_vector (const Vector &vec, const std::vector &names) { Assert (dof_handler != 0, - DataOutExceptions::ExcNoDoFHandlerSelected ()); + Exceptions::DataOut::ExcNoDoFHandlerSelected ()); // either cell data and one name, // or dof data and n_components names Assert (((vec.size() == dof_handler->get_tria().n_active_cells()) && @@ -177,16 +177,16 @@ void DataOutStack::add_data_vector (const Vector &vec, || ((vec.size() == dof_handler->n_dofs()) && (names.size() == dof_handler->get_fe().n_components())), - DataOutExceptions::ExcInvalidNumberOfNames (names.size(), - dof_handler->get_fe().n_components())); + Exceptions::DataOut::ExcInvalidNumberOfNames (names.size(), + dof_handler->get_fe().n_components())); for (unsigned int i=0; i()") == std::string::npos, - DataOutExceptions::ExcInvalidCharacter (names[i], - names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789_<>()"))); + Exceptions::DataOut::ExcInvalidCharacter (names[i], + names[i].find_first_not_of("abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789_<>()"))); if (vec.size() == dof_handler->n_dofs()) { @@ -242,9 +242,9 @@ void DataOutStack::build_patches (const unsigned int nnnn_subdi : this->default_subdivisions; Assert (n_subdivisions >= 1, - DataOutExceptions::ExcInvalidNumberOfSubdivisions(n_subdivisions)); + Exceptions::DataOut::ExcInvalidNumberOfSubdivisions(n_subdivisions)); Assert (dof_handler != 0, - DataOutExceptions::ExcNoDoFHandlerSelected()); + Exceptions::DataOut::ExcNoDoFHandlerSelected()); const unsigned int n_components = dof_handler->get_fe().n_components(); const unsigned int n_datasets = dof_data.size() * n_components + -- 2.39.5