#include <base/quadrature_lib.h>
#include <base/qprojector.h>
#include <base/logstream.h>
+#include <base/utilities.h>
#include <lac/full_matrix.h>
#include <lac/householder.h>
#include <lac/vector.h>
interpolation_matrix = tmp;
}
- // return true if the given pattern
- // string matches the given name at
- // the first position of the string
- inline
- bool
- match_at_string_start (const std::string &name,
- const std::string &pattern)
- {
- if (pattern.size() > name.size())
- return false;
-
- for (unsigned int i=0; i<pattern.size(); ++i)
- if (pattern[i] != name[i])
- return false;
-
- return true;
- }
-
-
-
- // read an integer at the position
- // in "name" indicated by the
- // second argument, and retun this
- // integer together with how many
- // characters it takes in the
- // string
- //
- // if no integer can be read at the
- // indicated position, return
- // (-1,-1)
- inline
- std::pair<int, unsigned int>
- get_integer (const std::string &name,
- const unsigned int position)
- {
- Assert (position < name.size(), ExcInternalError());
-
- const std::string test_string (name.begin()+position,
- name.end());
-
-#ifdef HAVE_STD_STRINGSTREAM
- std::istringstream str(test_string);
-#else
- std::istrstream str(test_string.c_str());
-#endif
-
- int i;
- if (str >> i)
- {
- // compute the number of
- // digits of i. assuming it
- // is less than 6 is likely
- // ok
- if (i<10)
- return std::make_pair (i, 1U);
- else if (i<100)
- return std::make_pair (i, 2U);
- else if (i<1000)
- return std::make_pair (i, 3U);
- else if (i<10000)
- return std::make_pair (i, 4U);
- else if (i<100000)
- return std::make_pair (i, 5U);
- else
- {
- Assert (false, ExcNotImplemented());
- return std::make_pair (-1, deal_II_numbers::invalid_unsigned_int);
- }
- }
- else
- return std::make_pair (-1, deal_II_numbers::invalid_unsigned_int);
- }
-
// return how many characters
// make sure we don't match FE_Q
// when it's actually a
// FE_Q_Hierarchic
- if (match_at_string_start (name, std::string("FE_Q_Hierarchical")))
+ if (Utilities::match_at_string_start (name, std::string("FE_Q_Hierarchical")))
{
unsigned int position = std::string("FE_Q_Hierarchical").size();
// as described in the
++position;
// next thing is to parse the
// degree of the finite element
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
}
// check other possibilities in
// exactly the same way
- else if (match_at_string_start (name, std::string("FE_RaviartThomas")))
+ else if (Utilities::match_at_string_start (name, std::string("FE_RaviartThomas")))
{
unsigned int position = std::string("FE_RaviartThomas").size();
position += match_dimension<dim> (name, position);
AssertThrow (name[position] == '(', ExcInvalidFEName(name));
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
AssertThrow (name[position] == ')', ExcInvalidFEName(name));
(new FE_RaviartThomas<dim>(tmp.first)),
position);
}
- else if (match_at_string_start (name, std::string("FE_Nedelec")))
+ else if (Utilities::match_at_string_start (name, std::string("FE_Nedelec")))
{
unsigned int position = std::string("FE_Nedelec").size();
position += match_dimension<dim> (name, position);
AssertThrow (name[position] == '(', ExcInvalidFEName(name));
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
AssertThrow (name[position] == ')', ExcInvalidFEName(name));
(new FE_Nedelec<dim>(tmp.first)),
position);
}
- else if (match_at_string_start (name, std::string("FE_DGPNonparametric")))
+ else if (Utilities::match_at_string_start (name, std::string("FE_DGPNonparametric")))
{
unsigned int position = std::string("FE_DGPNonparametric").size();
position += match_dimension<dim> (name, position);
AssertThrow (name[position] == '(', ExcInvalidFEName(name));
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
AssertThrow (name[position] == ')', ExcInvalidFEName(name));
(new FE_DGPNonparametric<dim>(tmp.first)),
position);
}
- else if (match_at_string_start (name, std::string("FE_DGP")))
+ else if (Utilities::match_at_string_start (name, std::string("FE_DGP")))
{
unsigned int position = std::string("FE_DGP").size();
position += match_dimension<dim> (name, position);
AssertThrow (name[position] == '(', ExcInvalidFEName(name));
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
AssertThrow (name[position] == ')', ExcInvalidFEName(name));
return std::make_pair (static_cast<FiniteElement<dim>*>(new FE_DGP<dim>(tmp.first)),
position);
}
- else if (match_at_string_start (name, std::string("FE_DGQ")))
+ else if (Utilities::match_at_string_start (name, std::string("FE_DGQ")))
{
unsigned int position = std::string("FE_DGQ").size();
position += match_dimension<dim> (name, position);
AssertThrow (name[position] == '(', ExcInvalidFEName(name));
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
AssertThrow (name[position] == ')', ExcInvalidFEName(name));
return std::make_pair (static_cast<FiniteElement<dim>*> (new FE_DGQ<dim>(tmp.first)),
position);
}
- else if (match_at_string_start (name, std::string("FE_Q")))
+ else if (Utilities::match_at_string_start (name, std::string("FE_Q")))
{
unsigned int position = std::string("FE_Q").size();
position += match_dimension<dim> (name, position);
AssertThrow (name[position] == '(', ExcInvalidFEName(name));
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name, position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
AssertThrow (name[position] == ')', ExcInvalidFEName(name));
// have to figure out what the
// base elements are. this can
// only be done recursively
- if (match_at_string_start (name, std::string("FESystem")))
+ if (Utilities::match_at_string_start (name, std::string("FESystem")))
{
unsigned int position = std::string("FESystem").size();
position += match_dimension<dim> (name, position);
// and read this
// multiplicity
++position;
- const std::pair<int,unsigned int> tmp = get_integer (name,
- position);
+
+ const std::pair<int,unsigned int> tmp
+ = Utilities::get_integer_at_position (name, position);
+
AssertThrow (tmp.first>=0, ExcInvalidFEName(name));
position += tmp.second;
base_multiplicities.push_back (tmp.first);