[cig-commits] [commit] master: add some comments (70225aa)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Wed May 21 07:32:33 PDT 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/497a2179702f669476083a98714879503e0dfa90...6aa7541c733b8fd1cc1b0c74536c8804aaeb7015
>---------------------------------------------------------------
commit 70225aa0244f44b332a22ff6be76abf3ea6b9ac2
Author: Juliane Dannberg <dannberg at gfz-potsdam.de>
Date: Wed May 21 06:31:59 2014 +0200
add some comments
>---------------------------------------------------------------
70225aa0244f44b332a22ff6be76abf3ea6b9ac2
include/aspect/introspection.h | 3 ++-
source/simulator/introspection.cc | 12 +++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/include/aspect/introspection.h b/include/aspect/introspection.h
index 87ea537..57dacb5 100644
--- a/include/aspect/introspection.h
+++ b/include/aspect/introspection.h
@@ -268,7 +268,8 @@ namespace aspect
/**
* A function that gets the name of a compositional field as an
- * input parameter and returns its index.
+ * input parameter and returns its index. If the name is not
+ * found, an exception is thrown.
*
* @param name The name of compositional field (as specified in
* the input file)
diff --git a/source/simulator/introspection.cc b/source/simulator/introspection.cc
index ddc5fa7..257cf7e 100644
--- a/source/simulator/introspection.cc
+++ b/source/simulator/introspection.cc
@@ -172,13 +172,15 @@ namespace aspect
unsigned int
Introspection<dim>::compositional_index_for_name (const std::string &name) const
{
- if (compositional_name_exists(name))
- return std::find(composition_names.begin(), composition_names.end(), name) - composition_names.begin();
- else
+ std::vector<std::string>::const_iterator it = std::find(composition_names.begin(), composition_names.end(), name);
+ if (it == composition_names.end())
+ {
AssertThrow (false, ExcMessage ("The compositional field " + name +
- " you asked for is not used in the simulation."));
+ " you asked for is not used in the simulation."));
+ }
+ else
+ return it - composition_names.begin();
return numbers::invalid_unsigned_int;
-
}
template <int dim>
More information about the CIG-COMMITS
mailing list