From: kormann Date: Wed, 23 Feb 2011 18:51:21 +0000 (+0000) Subject: Implement get_fe_from_name for FE_Q with Gauss-Lobatto points. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15ef335747e9cc05f6cda8d80c3f0b791cb358c4;p=dealii-svn.git Implement get_fe_from_name for FE_Q with Gauss-Lobatto points. git-svn-id: https://svn.dealii.org/trunk@23439 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/fe/fe_tools.h b/deal.II/include/deal.II/fe/fe_tools.h index fc60375e4f..9cc3c0d9e9 100644 --- a/deal.II/include/deal.II/fe/fe_tools.h +++ b/deal.II/include/deal.II/fe/fe_tools.h @@ -100,6 +100,15 @@ namespace FETools virtual FiniteElement* get (const unsigned int degree) const = 0; + /** + * Create a FiniteElement from a + * quadrature formula (currently only + * implemented for FE_Q) and return a + * pointer to it. + */ + + virtual FiniteElement* + get (const Quadrature<1> &quad) const = 0; /** * Virtual destructor doing * nothing but making the @@ -134,6 +143,15 @@ namespace FETools */ virtual FiniteElement* get (const unsigned int degree) const; + + /** + * Create a FiniteElement from a + * quadrature formula (currently only + * implemented for FE_Q) and return a + * pointer to it. + */ + virtual FiniteElement* + get (const Quadrature<1> &quad) const; }; /** diff --git a/deal.II/source/fe/fe_tools.cc b/deal.II/source/fe/fe_tools.cc index ff3291b443..dab4fa8a1b 100644 --- a/deal.II/source/fe/fe_tools.cc +++ b/deal.II/source/fe/fe_tools.cc @@ -53,6 +53,37 @@ DEAL_II_NAMESPACE_OPEN +namespace FETools +{ + // Not implemented in the general case. + template + FiniteElement* + FEFactory::get (const Quadrature<1> &quad) const + { + Assert(false, ExcNotImplemented()); + return 0; + } + + // Specializations for FE_Q. + template <> + FiniteElement<1, 1>* + FEFactory >::get (const Quadrature<1> &quad) const + { + return new FE_Q<1>(quad); + } + template <> + FiniteElement<2, 2>* + FEFactory >::get (const Quadrature<1> &quad) const + { + return new FE_Q<2>(quad); + } + template <> + FiniteElement<3, 3>* + FEFactory >::get (const Quadrature<1> &quad) const + { + return new FE_Q<3>(quad); + } +} namespace { @@ -2149,16 +2180,15 @@ namespace FETools else { unsigned int position = name.find('('); - const std::string quadrature_name(name, 0, position-1); - name.erase(0,position); + const std::string quadrature_name(name, 0, position); + name.erase(0,position+1); if (quadrature_name.compare("QGaussLobatto") == 0) { const std::pair tmp = Utilities::get_integer_at_position (name, 0); - name.erase(0, tmp.second+1); -//TODO: Implement a get function taking Quadrature<1> in fe_tools.h. -//return fe_name_map.find(name_part)->second->get(QGaussLobatto<1>(tmp.first)); - AssertThrow (false, ExcNotImplemented()); + // delete "))" + name.erase(0, tmp.second+2); + return fe_name_map.find(name_part)->second->get(QGaussLobatto<1>(tmp.first)); } else {