From 335a0cdc667fda5c1f55e38d1f98304d759b79ec Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Sun, 15 Mar 2015 01:28:52 -0500 Subject: [PATCH] Adjust error messages in the error estimator class. --- include/deal.II/numerics/error_estimator.h | 90 +++++++++++++++------- source/numerics/error_estimator.cc | 7 +- source/numerics/error_estimator_1d.cc | 16 +++- 3 files changed, 79 insertions(+), 34 deletions(-) diff --git a/include/deal.II/numerics/error_estimator.h b/include/deal.II/numerics/error_estimator.h index f92e5bbd47..b387238983 100644 --- a/include/deal.II/numerics/error_estimator.h +++ b/include/deal.II/numerics/error_estimator.h @@ -442,34 +442,51 @@ public: /** * Exception */ - DeclException0 (ExcInvalidBoundaryIndicator); + DeclExceptionMsg (ExcInvalidComponentMask, + "You provided a ComponentMask argument that is invalid. " + "Component masks need to be either default constructed " + "(in which case they indicate that every component is " + "selected) or need to have a length equal to the number " + "of vector components of the finite element in use " + "by the DoFHandler object. In the latter case, at " + "least one component needs to be selected."); /** * Exception */ - DeclException0 (ExcInvalidComponentMask); + DeclExceptionMsg (ExcInvalidCoefficient, + "If you do specify the argument for a (possibly " + "spatially variable) coefficient function for this function, " + "then it needs to refer to a coefficient that is either " + "scalar (has one vector component) or has as many vector " + "components as there are in the finite element used by " + "the DoFHandler argument."); /** * Exception */ - DeclException0 (ExcInvalidCoefficient); - /** - * Exception - */ - DeclException0 (ExcInvalidBoundaryFunction); + DeclException3 (ExcInvalidBoundaryFunction, + types::boundary_id, + int, + int, + << "You provided a function map that for boundary indicator " + << arg1 << " specifies a function with " + << arg2 << " vector components. However, the finite " + "element in use has " + << arg2 << " components, and these two numbers need to match."); /** * Exception */ DeclException2 (ExcIncompatibleNumberOfElements, int, int, - << "The number of elements " << arg1 << " and " << arg2 - << " of the vectors do not match!"); - /** - * Exception - */ - DeclException0 (ExcInvalidSolutionVector); + << "The number of input vectors, " << arg1 + << " needs to be equal to the number of output vectors, " + << arg2 + << ". This is not the case in your call of this function."); /** * Exception */ - DeclException0 (ExcNoSolutions); + DeclExceptionMsg (ExcNoSolutions, + "You need to specify at least one solution vector as " + "input."); }; @@ -655,34 +672,51 @@ public: /** * Exception */ - DeclException0 (ExcInvalidBoundaryIndicator); + DeclExceptionMsg (ExcInvalidComponentMask, + "You provided a ComponentMask argument that is invalid. " + "Component masks need to be either default constructed " + "(in which case they indicate that every component is " + "selected) or need to have a length equal to the number " + "of vector components of the finite element in use " + "by the DoFHandler object. In the latter case, at " + "least one component needs to be selected."); /** * Exception */ - DeclException0 (ExcInvalidComponentMask); + DeclExceptionMsg (ExcInvalidCoefficient, + "If you do specify the argument for a (possibly " + "spatially variable) coefficient function for this function, " + "then it needs to refer to a coefficient that is either " + "scalar (has one vector component) or has as many vector " + "components as there are in the finite element used by " + "the DoFHandler argument."); /** * Exception */ - DeclException0 (ExcInvalidCoefficient); - /** - * Exception - */ - DeclException0 (ExcInvalidBoundaryFunction); + DeclException3 (ExcInvalidBoundaryFunction, + types::boundary_id, + int, + int, + << "You provided a function map that for boundary indicator " + << arg1 << " specifies a function with " + << arg2 << " vector components. However, the finite " + "element in use has " + << arg3 << " components, and these two numbers need to match."); /** * Exception */ DeclException2 (ExcIncompatibleNumberOfElements, int, int, - << "The number of elements " << arg1 << " and " << arg2 - << " of the vectors do not match!"); - /** - * Exception - */ - DeclException0 (ExcInvalidSolutionVector); + << "The number of input vectors, " << arg1 + << " needs to be equal to the number of output vectors, " + << arg2 + << ". This is not the case in your call of this function."); /** * Exception */ - DeclException0 (ExcNoSolutions); + DeclExceptionMsg (ExcNoSolutions, + "You need to specify at least one solution vector as " + "input."); }; diff --git a/source/numerics/error_estimator.cc b/source/numerics/error_estimator.cc index 19ba50108a..2d6e2fe6fd 100644 --- a/source/numerics/error_estimator.cc +++ b/source/numerics/error_estimator.cc @@ -934,7 +934,9 @@ estimate (const Mapping &mapping, for (typename FunctionMap::type::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i) Assert (i->second->n_components == n_components, - ExcInvalidBoundaryFunction()); + ExcInvalidBoundaryFunction(i->first, + i->second->n_components, + n_components)); Assert (component_mask.represents_n_components(n_components), ExcInvalidComponentMask()); @@ -948,7 +950,8 @@ estimate (const Mapping &mapping, for (unsigned int n=0; nsize() == dof_handler.n_dofs(), - ExcInvalidSolutionVector()); + ExcDimensionMismatch(solutions[n]->size(), + dof_handler.n_dofs())); const unsigned int n_solution_vectors = solutions.size(); diff --git a/source/numerics/error_estimator_1d.cc b/source/numerics/error_estimator_1d.cc index e91bfe0ab1..6e95f5dad4 100644 --- a/source/numerics/error_estimator_1d.cc +++ b/source/numerics/error_estimator_1d.cc @@ -250,11 +250,16 @@ estimate (const Mapping<1,spacedim> &mapping, // sanity checks Assert (neumann_bc.find(numbers::internal_face_boundary_id) == neumann_bc.end(), - ExcInvalidBoundaryIndicator()); + ExcMessage("You are not allowed to list the special boundary " + "indicator for internal boundaries in your boundary " + "value map.")); for (typename FunctionMap::type::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i) - Assert (i->second->n_components == n_components, ExcInvalidBoundaryFunction()); + Assert (i->second->n_components == n_components, + ExcInvalidBoundaryFunction(i->first, + i->second->n_components, + n_components)); Assert (component_mask.represents_n_components(n_components), ExcInvalidComponentMask()); @@ -272,7 +277,8 @@ estimate (const Mapping<1,spacedim> &mapping, ExcIncompatibleNumberOfElements(solutions.size(), errors.size())); for (unsigned int n=0; nsize() == dof_handler.n_dofs(), - ExcInvalidSolutionVector()); + ExcDimensionMismatch(solutions[n]->size(), + dof_handler.n_dofs())); Assert ((coefficient == 0) || (coefficient->n_components == n_components) || @@ -282,7 +288,9 @@ estimate (const Mapping<1,spacedim> &mapping, for (typename FunctionMap::type::const_iterator i=neumann_bc.begin(); i!=neumann_bc.end(); ++i) Assert (i->second->n_components == n_components, - ExcInvalidBoundaryFunction()); + ExcInvalidBoundaryFunction(i->first, + i->second->n_components, + n_components)); // reserve one slot for each cell and set it to zero for (unsigned int n=0; n