From: kanschat Date: Tue, 24 Oct 2006 18:47:02 +0000 (+0000) Subject: stupid bug removed X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10552fdbc13185e20e7317bfb1d81e5807258d2e;p=dealii-svn.git stupid bug removed git-svn-id: https://svn.dealii.org/trunk@14068 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/fe/fe_tools.cc b/deal.II/deal.II/source/fe/fe_tools.cc index 63eddecc68..b27d9a1eb1 100644 --- a/deal.II/deal.II/source/fe/fe_tools.cc +++ b/deal.II/deal.II/source/fe/fe_tools.cc @@ -1409,7 +1409,7 @@ void FETools::extrapolate(const DoFHandler &dof1, template void FETools::add_fe_name(const std::string& parameter_name, - boost::shared_ptr > factory) + const FEFactoryBase* factory) { // Erase everything after the // actual class name @@ -1425,12 +1425,12 @@ FETools::add_fe_name(const std::string& parameter_name, // until we quit this function Threads::ThreadMutex::ScopedLock lock(fe_name_map_lock); - Assert(fe_name_map.find(name) != fe_name_map.end(), + Assert(fe_name_map.find(name) == fe_name_map.end(), ExcMessage("Cannot change existing element in finite element name list")); // Insert the normalized name into // the map - fe_name_map.insert(std::make_pair(name, factory)); + fe_name_map.insert(std::make_pair(name, boost::shared_ptr >(factory))); } @@ -1448,35 +1448,25 @@ FETools::get_fe_from_name (const std::string ¶meter_name) == fe_name_map.end()) { add_fe_name (std::string("FE_Q_Hierarchical"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_ABF"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_RaviartThomas"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_RaviartThomasNodal"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_Nedelec"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_DGPNonparametric"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_DGP"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_DGPMonomial"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_DGQ"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); add_fe_name (std::string("FE_Q<2>(4)"), - boost::shared_ptr > - (new FEFactory >())); + new FEFactory >()); } // Create a version of the name @@ -1527,10 +1517,21 @@ FETools::get_fe_from_name (const std::string ¶meter_name) { name.at(pos+1) = '0' + dim; } - FiniteElement* fe = get_fe_from_name_aux (name); + FiniteElement* fe; + try + { + fe = get_fe_from_name_aux (name); + } + catch (std::string errline) + { + AssertThrow(false, ExcInvalidFEName(parameter_name + + std::string(" at ") + + errline)); + } // Make sure the auxiliary function // ate up all characters of the name. - AssertThrow (name.size() == 0, ExcInvalidFEName(parameter_name)); + AssertThrow (name.size() == 0, ExcInvalidFEName(parameter_name + + std::string(" extra characters after end of name"))); return fe; } @@ -1572,7 +1573,8 @@ FETools::get_fe_from_name_aux (std::string &name) { // Now, just the [...] // part should be left. - AssertThrow(name.at(0) == '[', ExcInvalidFECharacter(name)); + if (name.size() == 0 || name[0] != '[') + throw (std::string("Invalid first character in ") + name); do { // Erase the @@ -1595,39 +1597,40 @@ FETools::get_fe_from_name_aux (std::string &name) const std::pair tmp = Utilities::get_integer_at_position (name, 0); - name.erase(0, tmp.second); - // add to length, - // including the '^' - base_multiplicities.push_back (tmp.first); - } - else - // no, so - // multiplicity is - // 1 - base_multiplicities.push_back (1); - - // so that's it for - // this base - // element. base - // elements are - // separated by '-', - // and the list is - // terminated by ']', - // so loop while the - // next character is - // '-' + name.erase(0, tmp.second); + // add to length, + // including the '^' + base_multiplicities.push_back (tmp.first); } - while (name[0] == '-'); - - // so we got to the end - // of the '-' separated - // list. make sure that - // we actually had a ']' - // there - AssertThrow (name.at(0) == ']', ExcInvalidFECharacter(name)); - name.erase(0,1); - // just one more sanity check - Assert ((base_fes.size() == base_multiplicities.size()) + else + // no, so + // multiplicity is + // 1 + base_multiplicities.push_back (1); + + // so that's it for + // this base + // element. base + // elements are + // separated by '-', + // and the list is + // terminated by ']', + // so loop while the + // next character is + // '-' + } + while (name[0] == '-'); + + // so we got to the end + // of the '-' separated + // list. make sure that + // we actually had a ']' + // there + if (name.size() == 0 || name[0] != ']') + throw (std::string("Invalid first character in ") + name); + name.erase(0,1); + // just one more sanity check + Assert ((base_fes.size() == base_multiplicities.size()) && (base_fes.size() > 0), ExcInternalError()); @@ -1717,7 +1720,8 @@ FETools::get_fe_from_name_aux (std::string &name) AssertThrow (entry != fe_name_map.end(), ExcInvalidFEName(name)); // Now, just the (degree) // part should be left. - AssertThrow(name.at(0) == '(', ExcInvalidFECharacter(name)); + if (name.size() == 0 || name[0] != '(') + throw (std::string("Invalid first character in ") + name); name.erase(0,1); const std::pair tmp = Utilities::get_integer_at_position (name, 0); @@ -2067,7 +2071,7 @@ FETools::get_fe_from_name (const std::string &); template void FETools::add_fe_name( const std::string& name, - boost::shared_ptr > factory); + const FEFactoryBase* factory); template void