From: Wolfgang Bangerth Date: Thu, 1 Jun 2017 21:11:58 +0000 (-0600) Subject: Let FE::clone() return a std::unique_ptr. X-Git-Tag: v9.0.0-rc1~1538^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=890f9c46bbf554c9754114d9f47d63bf19183f20;p=dealii.git Let FE::clone() return a std::unique_ptr. --- diff --git a/include/deal.II/fe/fe.h b/include/deal.II/fe/fe.h index d0adf0d4f0..ad2926492b 100644 --- a/include/deal.II/fe/fe.h +++ b/include/deal.II/fe/fe.h @@ -24,6 +24,9 @@ #include #include +#include + + DEAL_II_NAMESPACE_OPEN template class FEValuesBase; @@ -697,12 +700,19 @@ public: virtual ~FiniteElement (); /** - * A sort of virtual copy constructor. Some places in the library, for + * A sort of virtual copy constructor, this function returns a copy of + * the finite element object. Derived classes need to override the function + * here in this base class and return an object of the same type as the + * derived class. + * + * Some places in the library, for * example the constructors of FESystem as well as the hp::FECollection * class, need to make copies of finite elements without knowing their exact * type. They do so through this function. */ - virtual FiniteElement *clone() const = 0; + virtual + std::unique_ptr> + clone() const = 0; /** * Return a string that uniquely identifies a finite element. The general diff --git a/include/deal.II/fe/fe_abf.h b/include/deal.II/fe/fe_abf.h index eef630f388..4c80a59a44 100644 --- a/include/deal.II/fe/fe_abf.h +++ b/include/deal.II/fe/fe_abf.h @@ -130,7 +130,10 @@ public: std::vector &nodal_values) const; virtual std::size_t memory_consumption () const; - virtual FiniteElement *clone() const; + + virtual + std::unique_ptr > + clone() const; private: /** diff --git a/include/deal.II/fe/fe_bdm.h b/include/deal.II/fe/fe_bdm.h index c7cc26e1ea..eb33d12ad4 100644 --- a/include/deal.II/fe/fe_bdm.h +++ b/include/deal.II/fe/fe_bdm.h @@ -70,7 +70,9 @@ public: */ virtual std::string get_name () const; - virtual FiniteElement *clone () const; + virtual + std::unique_ptr > + clone() const; // documentation inherited from the base class virtual diff --git a/include/deal.II/fe/fe_bernstein.h b/include/deal.II/fe/fe_bernstein.h index 798eaa645e..975a29f14a 100644 --- a/include/deal.II/fe/fe_bernstein.h +++ b/include/deal.II/fe/fe_bernstein.h @@ -192,14 +192,11 @@ public: */ virtual std::string get_name () const; -protected: + virtual + std::unique_ptr > + clone() const; - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; +protected: /** * Only for internal use. Its full name is @p get_dofs_per_object_vector diff --git a/include/deal.II/fe/fe_dg_vector.h b/include/deal.II/fe/fe_dg_vector.h index fdafa6a703..bab8e80f34 100644 --- a/include/deal.II/fe/fe_dg_vector.h +++ b/include/deal.II/fe/fe_dg_vector.h @@ -59,9 +59,6 @@ public: * Constructor for the vector element of degree @p p. */ FE_DGVector (const unsigned int p, MappingType m); -public: - - FiniteElement *clone() const; /** * Return a string that uniquely identifies a finite element. This class @@ -70,6 +67,9 @@ public: */ virtual std::string get_name () const; + virtual + std::unique_ptr > + clone() const; /** * This function returns @p true, if the shape function @p shape_index has diff --git a/include/deal.II/fe/fe_dg_vector.templates.h b/include/deal.II/fe/fe_dg_vector.templates.h index 4a67fc7b8f..21e72b8ff5 100644 --- a/include/deal.II/fe/fe_dg_vector.templates.h +++ b/include/deal.II/fe/fe_dg_vector.templates.h @@ -21,6 +21,9 @@ #include #include +#include + + DEAL_II_NAMESPACE_OPEN @@ -51,10 +54,10 @@ FE_DGVector::FE_DGVector ( template -FiniteElement * +std::unique_ptr > FE_DGVector::clone() const { - return new FE_DGVector(*this); + return std_cxx14::make_unique>(*this); } diff --git a/include/deal.II/fe/fe_dgp.h b/include/deal.II/fe/fe_dgp.h index ef22bfabad..fbea1cc517 100644 --- a/include/deal.II/fe/fe_dgp.h +++ b/include/deal.II/fe/fe_dgp.h @@ -472,14 +472,9 @@ public: virtual std::pair, std::vector > get_constant_modes () const; -protected: - - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; private: diff --git a/include/deal.II/fe/fe_dgp_monomial.h b/include/deal.II/fe/fe_dgp_monomial.h index ce393da029..b4775cf6c8 100644 --- a/include/deal.II/fe/fe_dgp_monomial.h +++ b/include/deal.II/fe/fe_dgp_monomial.h @@ -433,14 +433,9 @@ public: */ virtual std::size_t memory_consumption () const; -protected: - - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; private: diff --git a/include/deal.II/fe/fe_dgp_nonparametric.h b/include/deal.II/fe/fe_dgp_nonparametric.h index 9b054dc0a1..1052fd36ab 100644 --- a/include/deal.II/fe/fe_dgp_nonparametric.h +++ b/include/deal.II/fe/fe_dgp_nonparametric.h @@ -281,6 +281,10 @@ public: */ virtual std::string get_name () const; + virtual + std::unique_ptr > + clone() const; + // for documentation, see the FiniteElement base class virtual UpdateFlags @@ -533,13 +537,6 @@ private: protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; - /** * Prepare internal data structures and fill in values independent of the * cell. diff --git a/include/deal.II/fe/fe_dgq.h b/include/deal.II/fe/fe_dgq.h index 693cc52bca..0b8d8aeafe 100644 --- a/include/deal.II/fe/fe_dgq.h +++ b/include/deal.II/fe/fe_dgq.h @@ -322,6 +322,9 @@ public: */ virtual std::size_t memory_consumption () const; + virtual + std::unique_ptr > + clone() const; protected: /** @@ -334,13 +337,6 @@ protected: */ FE_DGQ (const std::vector > &polynomials); - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; - private: /** * Only for internal use. Its full name is @p get_dofs_per_object_vector @@ -432,14 +428,9 @@ public: void convert_generalized_support_point_values_to_nodal_values (const std::vector > &support_point_values, std::vector &nodal_values) const; - -protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; }; @@ -480,13 +471,9 @@ public: */ virtual std::string get_name () const; -protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; }; @@ -531,13 +518,9 @@ public: */ virtual std::string get_name () const; -protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; }; diff --git a/include/deal.II/fe/fe_enriched.h b/include/deal.II/fe/fe_enriched.h index 45113558ea..14cb41ed4d 100644 --- a/include/deal.II/fe/fe_enriched.h +++ b/include/deal.II/fe/fe_enriched.h @@ -273,12 +273,9 @@ private: const std::vector *(const typename Triangulation::cell_iterator &) > > > &functions); public: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; virtual UpdateFlags diff --git a/include/deal.II/fe/fe_face.h b/include/deal.II/fe/fe_face.h index 4246522f40..82943decfe 100644 --- a/include/deal.II/fe/fe_face.h +++ b/include/deal.II/fe/fe_face.h @@ -59,7 +59,9 @@ public: */ FE_FaceQ (const unsigned int p); - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; /** * Return a string that uniquely identifies a finite element. This class @@ -156,10 +158,9 @@ public: */ FE_FaceQ (const unsigned int p); - /** - * Clone method. - */ - virtual FiniteElement<1,spacedim> *clone() const; + virtual + std::unique_ptr> + clone() const; /** * Return a string that uniquely identifies a finite element. This class @@ -358,10 +359,9 @@ public: */ FE_FaceP(unsigned int p); - /** - * Clone method. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; /** * Return a string that uniquely identifies a finite element. This class diff --git a/include/deal.II/fe/fe_nedelec.h b/include/deal.II/fe/fe_nedelec.h index 480b52e43e..2b04620b76 100644 --- a/include/deal.II/fe/fe_nedelec.h +++ b/include/deal.II/fe/fe_nedelec.h @@ -268,7 +268,10 @@ public: get_constant_modes () const; virtual std::size_t memory_consumption () const; - virtual FiniteElement *clone() const; + + virtual + std::unique_ptr > + clone() const; private: /** diff --git a/include/deal.II/fe/fe_nothing.h b/include/deal.II/fe/fe_nothing.h index 8c98c12dc3..134f4d6029 100644 --- a/include/deal.II/fe/fe_nothing.h +++ b/include/deal.II/fe/fe_nothing.h @@ -95,14 +95,8 @@ public: FE_Nothing (const unsigned int n_components = 1, const bool dominate = false); - /** - * A sort of virtual copy constructor. Some places in the library, for - * example the constructors of FESystem as well as the hp::FECollection - * class, need to make copied of finite elements without knowing their exact - * type. They do so through this function. - */ virtual - FiniteElement * + std::unique_ptr > clone() const; /** diff --git a/include/deal.II/fe/fe_p1nc.h b/include/deal.II/fe/fe_p1nc.h index 85b46eaf7c..7a14a369b1 100644 --- a/include/deal.II/fe/fe_p1nc.h +++ b/include/deal.II/fe/fe_p1nc.h @@ -265,7 +265,9 @@ public: virtual UpdateFlags requires_update_flags (const UpdateFlags flags) const; - virtual FiniteElement<2,2> *clone () const; + virtual + std::unique_ptr> + clone() const; /** * Destructor. diff --git a/include/deal.II/fe/fe_q.h b/include/deal.II/fe/fe_q.h index 7c08e61e45..0f17310c72 100644 --- a/include/deal.II/fe/fe_q.h +++ b/include/deal.II/fe/fe_q.h @@ -586,6 +586,10 @@ public: */ virtual std::string get_name () const; + virtual + std::unique_ptr > + clone() const; + /** * Implementation of the corresponding function in the FiniteElement * class. Since the current element is interpolatory, the nodal @@ -597,15 +601,6 @@ public: void convert_generalized_support_point_values_to_nodal_values (const std::vector > &support_point_values, std::vector &nodal_values) const; - -protected: - - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; }; diff --git a/include/deal.II/fe/fe_q_bubbles.h b/include/deal.II/fe/fe_q_bubbles.h index 20ac7c0720..901dcb94b5 100644 --- a/include/deal.II/fe/fe_q_bubbles.h +++ b/include/deal.II/fe/fe_q_bubbles.h @@ -142,13 +142,9 @@ public: virtual bool has_support_on_face (const unsigned int shape_index, const unsigned int face_index) const; -protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; private: diff --git a/include/deal.II/fe/fe_q_dg0.h b/include/deal.II/fe/fe_q_dg0.h index 7bc73548bd..0397e680aa 100644 --- a/include/deal.II/fe/fe_q_dg0.h +++ b/include/deal.II/fe/fe_q_dg0.h @@ -294,13 +294,9 @@ public: virtual std::pair, std::vector > get_constant_modes () const; -protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; + virtual + std::unique_ptr > + clone() const; private: diff --git a/include/deal.II/fe/fe_q_hierarchical.h b/include/deal.II/fe/fe_q_hierarchical.h index 6b956843e5..85a88ccd8c 100644 --- a/include/deal.II/fe/fe_q_hierarchical.h +++ b/include/deal.II/fe/fe_q_hierarchical.h @@ -553,6 +553,10 @@ public: */ virtual std::string get_name () const; + virtual + std::unique_ptr > + clone() const; + /** * This function returns @p true, if the shape function @p shape_index has * non-zero function values somewhere on the face @p face_index. @@ -688,14 +692,6 @@ public: virtual std::pair, std::vector > get_constant_modes () const; -protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; - private: /** diff --git a/include/deal.II/fe/fe_q_iso_q1.h b/include/deal.II/fe/fe_q_iso_q1.h index 605d9ae6ed..2a21786832 100644 --- a/include/deal.II/fe/fe_q_iso_q1.h +++ b/include/deal.II/fe/fe_q_iso_q1.h @@ -125,6 +125,10 @@ public: */ virtual std::string get_name () const; + virtual + std::unique_ptr > + clone() const; + /** * Implementation of the corresponding function in the FiniteElement * class. Since the current element is interpolatory, the nodal @@ -155,15 +159,6 @@ public: FiniteElementDomination::Domination compare_for_face_domination (const FiniteElement &fe_other) const; //@} - -protected: - - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; }; diff --git a/include/deal.II/fe/fe_rannacher_turek.h b/include/deal.II/fe/fe_rannacher_turek.h index c7739b9952..61940b750f 100644 --- a/include/deal.II/fe/fe_rannacher_turek.h +++ b/include/deal.II/fe/fe_rannacher_turek.h @@ -65,7 +65,10 @@ public: const unsigned int n_face_support_points = 2); virtual std::string get_name() const; - virtual FiniteElement *clone() const; + + virtual + std::unique_ptr > + clone() const; // documentation inherited from the base class virtual diff --git a/include/deal.II/fe/fe_raviart_thomas.h b/include/deal.II/fe/fe_raviart_thomas.h index ebcab3ef3c..c82c9ec0d6 100644 --- a/include/deal.II/fe/fe_raviart_thomas.h +++ b/include/deal.II/fe/fe_raviart_thomas.h @@ -117,6 +117,10 @@ public: */ virtual std::string get_name () const; + // documentation inherited from the base class + virtual + std::unique_ptr > + clone() const; /** * This function returns @p true, if the shape function @p shape_index has @@ -142,7 +146,6 @@ public: get_constant_modes () const; virtual std::size_t memory_consumption () const; - virtual FiniteElement *clone() const; private: /** @@ -254,9 +257,11 @@ public: */ virtual std::string get_name () const; - virtual FiniteElement *clone () const; - // documentation inherited from the base class + virtual + std::unique_ptr > + clone() const; + virtual void convert_generalized_support_point_values_to_nodal_values (const std::vector > &support_point_values, diff --git a/include/deal.II/fe/fe_system.h b/include/deal.II/fe/fe_system.h index 9e1870529b..56d813e2c4 100644 --- a/include/deal.II/fe/fe_system.h +++ b/include/deal.II/fe/fe_system.h @@ -443,6 +443,10 @@ public: virtual std::string get_name () const; // for documentation, see the FiniteElement base class + virtual + std::unique_ptr > + clone() const; + virtual UpdateFlags requires_update_flags (const UpdateFlags update_flags) const; @@ -871,14 +875,6 @@ public: protected: - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; - - virtual typename FiniteElement::InternalDataBase * get_data (const UpdateFlags update_flags, const Mapping &mapping, diff --git a/include/deal.II/fe/fe_trace.h b/include/deal.II/fe/fe_trace.h index 9c4fa55406..f44a6b62a9 100644 --- a/include/deal.II/fe/fe_trace.h +++ b/include/deal.II/fe/fe_trace.h @@ -51,13 +51,6 @@ public: */ FE_TraceQ(unsigned int p); - /** - * @p clone function instead of a copy constructor. - * - * This function is needed by the constructors of @p FESystem. - */ - virtual FiniteElement *clone() const; - /** * Return a string that uniquely identifies a finite element. This class * returns FE_DGQ(degree), with dim and @@ -65,6 +58,10 @@ public: */ virtual std::string get_name () const; + virtual + std::unique_ptr > + clone() const; + /** * This function returns @p true, if the shape function @p shape_index has * non-zero function values somewhere on the face @p face_index. diff --git a/source/fe/fe_abf.cc b/source/fe/fe_abf.cc index 03fa7b2620..6bd42a1b97 100644 --- a/source/fe/fe_abf.cc +++ b/source/fe/fe_abf.cc @@ -30,6 +30,8 @@ #include #include +#include + //TODO: implement the adjust_quad_dof_index_for_face_orientation_table and //adjust_line_dof_index_for_line_orientation_table fields, and write tests @@ -126,10 +128,10 @@ FE_ABF::get_name () const template -FiniteElement * +std::unique_ptr > FE_ABF::clone() const { - return new FE_ABF(rt_order); + return std_cxx14::make_unique>(rt_order); } diff --git a/source/fe/fe_bdm.cc b/source/fe/fe_bdm.cc index 3b1909aadf..f0e0e22dc8 100644 --- a/source/fe/fe_bdm.cc +++ b/source/fe/fe_bdm.cc @@ -29,6 +29,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -114,10 +115,10 @@ FE_BDM::get_name () const template -FiniteElement * +std::unique_ptr > FE_BDM::clone() const { - return new FE_BDM(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_bernstein.cc b/source/fe/fe_bernstein.cc index 68cbe82bff..1752c3c05f 100644 --- a/source/fe/fe_bernstein.cc +++ b/source/fe/fe_bernstein.cc @@ -26,6 +26,8 @@ #include #include +#include + DEAL_II_NAMESPACE_OPEN @@ -315,10 +317,10 @@ FE_Bernstein::get_name () const template -FiniteElement * +std::unique_ptr > FE_Bernstein::clone() const { - return new FE_Bernstein(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_dg_vector.cc b/source/fe/fe_dg_vector.cc index 39c434cc9f..ea914fb69b 100644 --- a/source/fe/fe_dg_vector.cc +++ b/source/fe/fe_dg_vector.cc @@ -20,6 +20,9 @@ #include #include +#include + + DEAL_II_NAMESPACE_OPEN template diff --git a/source/fe/fe_dgp.cc b/source/fe/fe_dgp.cc index 657e93511a..bf226c8ea4 100644 --- a/source/fe/fe_dgp.cc +++ b/source/fe/fe_dgp.cc @@ -18,6 +18,8 @@ #include #include +#include + DEAL_II_NAMESPACE_OPEN @@ -63,10 +65,10 @@ FE_DGP::get_name () const template -FiniteElement * +std::unique_ptr > FE_DGP::clone() const { - return new FE_DGP(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_dgp_monomial.cc b/source/fe/fe_dgp_monomial.cc index 2cbdf9d49d..2bd931a45e 100644 --- a/source/fe/fe_dgp_monomial.cc +++ b/source/fe/fe_dgp_monomial.cc @@ -18,6 +18,8 @@ #include #include +#include + DEAL_II_NAMESPACE_OPEN @@ -156,10 +158,10 @@ FE_DGPMonomial::get_name () const template -FiniteElement * +std::unique_ptr > FE_DGPMonomial::clone() const { - return new FE_DGPMonomial(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_dgp_nonparametric.cc b/source/fe/fe_dgp_nonparametric.cc index 6caa4839cd..112a870b14 100644 --- a/source/fe/fe_dgp_nonparametric.cc +++ b/source/fe/fe_dgp_nonparametric.cc @@ -24,6 +24,8 @@ #include #include +#include + DEAL_II_NAMESPACE_OPEN @@ -114,10 +116,10 @@ FE_DGPNonparametric::get_name () const template -FiniteElement * +std::unique_ptr > FE_DGPNonparametric::clone() const { - return new FE_DGPNonparametric(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_dgq.cc b/source/fe/fe_dgq.cc index 495cc48a92..7ff2c8bb95 100644 --- a/source/fe/fe_dgq.cc +++ b/source/fe/fe_dgq.cc @@ -24,6 +24,8 @@ #include #include +#include + DEAL_II_NAMESPACE_OPEN @@ -127,10 +129,10 @@ convert_generalized_support_point_values_to_nodal_values (const std::vector -FiniteElement * +std::unique_ptr > FE_DGQ::clone() const { - return new FE_DGQ(*this); + return std_cxx14::make_unique>(*this); } @@ -808,7 +810,7 @@ convert_generalized_support_point_values_to_nodal_values (const std::vector -FiniteElement * +std::unique_ptr > FE_DGQArbitraryNodes::clone() const { // Construct a dummy quadrature formula containing the FE's nodes: @@ -818,7 +820,7 @@ FE_DGQArbitraryNodes::clone() const qpoints[i] = Point<1>(this->unit_support_points[lexicographic[i]][0]); Quadrature<1> pquadrature(qpoints); - return new FE_DGQArbitraryNodes(pquadrature); + return std_cxx14::make_unique>(pquadrature); } @@ -857,10 +859,10 @@ FE_DGQLegendre::get_name () const template -FiniteElement * +std::unique_ptr > FE_DGQLegendre::clone() const { - return new FE_DGQLegendre(this->degree); + return std_cxx14::make_unique>(this->degree); } @@ -912,10 +914,10 @@ FE_DGQHermite::get_name () const template -FiniteElement * +std::unique_ptr > FE_DGQHermite::clone() const { - return new FE_DGQHermite(this->degree); + return std_cxx14::make_unique>(this->degree); } diff --git a/source/fe/fe_enriched.cc b/source/fe/fe_enriched.cc index cf492902ea..b98f2e6e86 100644 --- a/source/fe/fe_enriched.cc +++ b/source/fe/fe_enriched.cc @@ -15,9 +15,11 @@ #include - #include +#include + + DEAL_II_NAMESPACE_OPEN namespace @@ -236,7 +238,7 @@ FE_Enriched::shape_value(const unsigned int i, template -FiniteElement * +std::unique_ptr > FE_Enriched::clone() const { std::vector< const FiniteElement< dim, spacedim > * > fes; @@ -248,7 +250,9 @@ FE_Enriched::clone() const multiplicities.push_back(this->element_multiplicity(i) ); } - return new FE_Enriched(fes, multiplicities, get_enrichments()); + return std::unique_ptr>(new FE_Enriched(fes, + multiplicities, + get_enrichments())); } diff --git a/source/fe/fe_face.cc b/source/fe/fe_face.cc index 8dde09d0c4..d62e6f755d 100644 --- a/source/fe/fe_face.cc +++ b/source/fe/fe_face.cc @@ -20,7 +20,9 @@ #include #include #include + #include +#include DEAL_II_NAMESPACE_OPEN @@ -102,10 +104,10 @@ FE_FaceQ::FE_FaceQ (const unsigned int degree) template -FiniteElement * +std::unique_ptr > FE_FaceQ::clone() const { - return new FE_FaceQ(this->degree); + return std_cxx14::make_unique>(this->degree); } @@ -329,10 +331,10 @@ FE_FaceQ<1,spacedim>::FE_FaceQ (const unsigned int degree) template -FiniteElement<1,spacedim> * -FE_FaceQ<1,spacedim>::clone() const +std::unique_ptr> + FE_FaceQ<1,spacedim>::clone() const { - return new FE_FaceQ<1,spacedim>(this->degree); + return std_cxx14::make_unique>(this->degree); } @@ -527,10 +529,10 @@ FE_FaceP::FE_FaceP (const unsigned int degree) template -FiniteElement * +std::unique_ptr > FE_FaceP::clone() const { - return new FE_FaceP(this->degree); + return std_cxx14::make_unique>(this->degree); } diff --git a/source/fe/fe_nedelec.cc b/source/fe/fe_nedelec.cc index c6e324a83a..d9c557968a 100644 --- a/source/fe/fe_nedelec.cc +++ b/source/fe/fe_nedelec.cc @@ -28,8 +28,10 @@ #include #include #include + #include #include +#include //TODO: implement the adjust_quad_dof_index_for_face_orientation_table and //adjust_line_dof_index_for_line_orientation_table fields, and write tests @@ -207,10 +209,10 @@ FE_Nedelec::get_name () const template -FiniteElement -*FE_Nedelec::clone () const +std::unique_ptr > +FE_Nedelec::clone () const { - return new FE_Nedelec (*this); + return std_cxx14::make_unique >(*this); } //--------------------------------------------------------------------------- diff --git a/source/fe/fe_nothing.cc b/source/fe/fe_nothing.cc index 7095354607..1a3469528d 100644 --- a/source/fe/fe_nothing.cc +++ b/source/fe/fe_nothing.cc @@ -15,6 +15,7 @@ #include +#include DEAL_II_NAMESPACE_OPEN @@ -48,10 +49,10 @@ FE_Nothing::FE_Nothing (const unsigned int n_components, template -FiniteElement * +std::unique_ptr > FE_Nothing::clone() const { - return new FE_Nothing(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_p1nc.cc b/source/fe/fe_p1nc.cc index b2e10eab29..8953d97d7d 100644 --- a/source/fe/fe_p1nc.cc +++ b/source/fe/fe_p1nc.cc @@ -15,6 +15,7 @@ #include +#include DEAL_II_NAMESPACE_OPEN @@ -64,9 +65,10 @@ UpdateFlags FE_P1NC::requires_update_flags (const UpdateFlags flags) const -FiniteElement<2,2> *FE_P1NC::clone () const +std::unique_ptr> + FE_P1NC::clone () const { - return new FE_P1NC(*this); + return std_cxx14::make_unique(*this); } diff --git a/source/fe/fe_q.cc b/source/fe/fe_q.cc index f0e272f4a4..339205589a 100644 --- a/source/fe/fe_q.cc +++ b/source/fe/fe_q.cc @@ -20,6 +20,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -157,10 +158,10 @@ convert_generalized_support_point_values_to_nodal_values (const std::vector -FiniteElement * +std::unique_ptr > FE_Q::clone() const { - return new FE_Q(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_q_base.cc b/source/fe/fe_q_base.cc index 43453859bd..e0102743bd 100644 --- a/source/fe/fe_q_base.cc +++ b/source/fe/fe_q_base.cc @@ -30,6 +30,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN diff --git a/source/fe/fe_q_bubbles.cc b/source/fe/fe_q_bubbles.cc index 117244270f..c82b9cd83d 100644 --- a/source/fe/fe_q_bubbles.cc +++ b/source/fe/fe_q_bubbles.cc @@ -33,6 +33,7 @@ #include #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -320,10 +321,10 @@ FE_Q_Bubbles::get_name () const template -FiniteElement * +std::unique_ptr > FE_Q_Bubbles::clone() const { - return new FE_Q_Bubbles(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_q_dg0.cc b/source/fe/fe_q_dg0.cc index 6a6bc3c3e1..da353cc090 100644 --- a/source/fe/fe_q_dg0.cc +++ b/source/fe/fe_q_dg0.cc @@ -25,6 +25,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -166,10 +167,10 @@ FE_Q_DG0::get_name () const template -FiniteElement * +std::unique_ptr > FE_Q_DG0::clone() const { - return new FE_Q_DG0(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_q_hierarchical.cc b/source/fe/fe_q_hierarchical.cc index fdd72b3b22..2e55a25841 100644 --- a/source/fe/fe_q_hierarchical.cc +++ b/source/fe/fe_q_hierarchical.cc @@ -19,6 +19,7 @@ #include #include +#include //TODO: implement the adjust_quad_dof_index_for_face_orientation_table and //adjust_line_dof_index_for_line_orientation_table fields, and write tests @@ -125,10 +126,10 @@ FE_Q_Hierarchical::get_name () const template -FiniteElement * +std::unique_ptr > FE_Q_Hierarchical::clone() const { - return new FE_Q_Hierarchical(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_q_iso_q1.cc b/source/fe/fe_q_iso_q1.cc index fdbf224aa5..cbc1846276 100644 --- a/source/fe/fe_q_iso_q1.cc +++ b/source/fe/fe_q_iso_q1.cc @@ -21,6 +21,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -92,10 +93,10 @@ convert_generalized_support_point_values_to_nodal_values (const std::vector -FiniteElement * +std::unique_ptr > FE_Q_iso_Q1::clone() const { - return new FE_Q_iso_Q1(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_rannacher_turek.cc b/source/fe/fe_rannacher_turek.cc index 8b1b8e7bfc..3c897f8286 100644 --- a/source/fe/fe_rannacher_turek.cc +++ b/source/fe/fe_rannacher_turek.cc @@ -20,6 +20,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -70,9 +71,10 @@ std::string FE_RannacherTurek::get_name() const template -FiniteElement *FE_RannacherTurek::clone() const +std::unique_ptr > +FE_RannacherTurek::clone() const { - return new FE_RannacherTurek(this->order, this->n_face_support_points); + return std_cxx14::make_unique>(this->order, this->n_face_support_points); } diff --git a/source/fe/fe_raviart_thomas.cc b/source/fe/fe_raviart_thomas.cc index 7964b5a6ad..f24c03a00b 100644 --- a/source/fe/fe_raviart_thomas.cc +++ b/source/fe/fe_raviart_thomas.cc @@ -30,6 +30,7 @@ #include #include +#include //TODO: implement the adjust_quad_dof_index_for_face_orientation_table and //adjust_line_dof_index_for_line_orientation_table fields, and write tests @@ -122,10 +123,10 @@ FE_RaviartThomas::get_name () const template -FiniteElement * +std::unique_ptr > FE_RaviartThomas::clone() const { - return new FE_RaviartThomas(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_raviart_thomas_nodal.cc b/source/fe/fe_raviart_thomas_nodal.cc index d59735c24f..ff145a40b8 100644 --- a/source/fe/fe_raviart_thomas_nodal.cc +++ b/source/fe/fe_raviart_thomas_nodal.cc @@ -27,6 +27,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -119,10 +120,10 @@ FE_RaviartThomasNodal::get_name () const template -FiniteElement * +std::unique_ptr > FE_RaviartThomasNodal::clone() const { - return new FE_RaviartThomasNodal(*this); + return std_cxx14::make_unique>(*this); } diff --git a/source/fe/fe_system.cc b/source/fe/fe_system.cc index 04d6bba629..6d346ac0b6 100644 --- a/source/fe/fe_system.cc +++ b/source/fe/fe_system.cc @@ -25,6 +25,7 @@ #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -319,7 +320,7 @@ FESystem::get_name () const template -FiniteElement * +std::unique_ptr > FESystem::clone() const { std::vector< const FiniteElement* > fes; @@ -330,7 +331,7 @@ FESystem::clone() const fes.push_back( & base_element(i) ); multiplicities.push_back(this->element_multiplicity(i) ); } - return new FESystem(fes, multiplicities); + return std_cxx14::make_unique>(fes, multiplicities); } @@ -1477,9 +1478,7 @@ void FESystem::initialize (const std::vector>(fes[i]->clone()), - multiplicities[i]); + base_elements[ind] = { fes[i]->clone(), multiplicities[i] }; }); ++ind; } diff --git a/source/fe/fe_trace.cc b/source/fe/fe_trace.cc index 16cbb03776..dee1e7f869 100644 --- a/source/fe/fe_trace.cc +++ b/source/fe/fe_trace.cc @@ -26,6 +26,7 @@ #include #include #include +#include DEAL_II_NAMESPACE_OPEN @@ -64,10 +65,10 @@ FE_TraceQ::FE_TraceQ (const unsigned int degree) template -FiniteElement * +std::unique_ptr > FE_TraceQ::clone() const { - return new FE_TraceQ(this->degree); + return std_cxx14::make_unique>(this->degree); }