From d1afe7fbed62bc28612b2066fb7045d19a10ddd5 Mon Sep 17 00:00:00 2001 From: Dmitriy Logashenko Date: Fri, 15 Nov 2024 14:48:57 +0300 Subject: [PATCH] Restructuring. --- .../common_user_data/composite_user_data.h | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/ugbase/lib_disc/spatial_disc/user_data/common_user_data/composite_user_data.h b/ugbase/lib_disc/spatial_disc/user_data/common_user_data/composite_user_data.h index 2592935b7..853e58748 100644 --- a/ugbase/lib_disc/spatial_disc/user_data/common_user_data/composite_user_data.h +++ b/ugbase/lib_disc/spatial_disc/user_data/common_user_data/composite_user_data.h @@ -66,7 +66,7 @@ class CompositeUserData : public UserData void add ( int si, ///< the subset index - ref_type ref ///< pointer to the user-data object + SmartPtr ref ///< pointer to the user-data object ) { UG_ASSERT (si >= 0, "CompositeUserData: Non-existing subset index!"); @@ -84,7 +84,7 @@ class CompositeUserData : public UserData void add ( const SubsetGroup & ssg, ///< the subset group - ref_type ref ///< pointer to the user-data object + SmartPtr ref ///< pointer to the user-data object ) { for (size_t i = 0; i < ssg.size (); i++) add (ssg[i], ref); @@ -95,7 +95,7 @@ class CompositeUserData : public UserData ( ConstSmartPtr ssh, ///< subset handler of the domain const char * ss_names, ///< names of the subdomains - ref_type ref ///< pointer to the user-data object + SmartPtr ref ///< pointer to the user-data object ) { std::vector v_ss_names; @@ -106,16 +106,14 @@ class CompositeUserData : public UserData add (ssg, ref); } - /// Returns the value assigned to a subset index - ref_type get (int si) const { return find(si); } - /// Checks if anything is assigned to a given subset index - bool has(int si) const { return si >= 0 && (size_t) si < m_vData.size () && find(si).valid ();} - - - bool is_coupled(int si) { return has(si) && find(si).template is_of_type(); } + bool has(int si) const { return si >= 0 && (size_t) si < m_vData.size () && m_vData[si].valid ();} + + SmartPtr get(int si) const { check (si); return m_vData[si]; } + + bool is_coupled(int si) { return has(si) && m_vData[si].template is_of_type(); } - SmartPtr get_coupled(int si) { return find(si).template cast_dynamic(); } + SmartPtr get_coupled(int si) { return m_vData[si].template cast_dynamic(); } // Implementing virtual functions @@ -131,13 +129,13 @@ class CompositeUserData : public UserData virtual TRet operator() (TData& value, const MathVector& globIP, number time, int si) const - { return (*find(si)) (value, globIP, time, si); } + { check (si); return (*m_vData[si]) (value, globIP, time, si); } /// returns values for global positions virtual void operator()(TData vValue[], const MathVector vGlobIP[], number time, int si, const size_t nip) const - { return (*find(si)) (vValue, vGlobIP, time, si, nip); } + { check (si); return (*m_vData[si]) (vValue, vGlobIP, time, si, nip); } virtual void operator()(TData vValue[], @@ -150,7 +148,7 @@ class CompositeUserData : public UserData LocalVector* u, const MathMatrix<1, dim>* vJT = NULL) const { - return (*find(si)) (vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT); + check (si); return (*m_vData[si]) (vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT); } virtual void operator()(TData vValue[], @@ -163,7 +161,7 @@ class CompositeUserData : public UserData LocalVector* u, const MathMatrix<2, dim>* vJT = NULL) const { - return (*find(si)) (vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT); + check (si); return (*m_vData[si]) (vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT); } virtual void operator()(TData vValue[], @@ -176,25 +174,23 @@ class CompositeUserData : public UserData LocalVector* u, const MathMatrix<3, dim>* vJT = NULL) const { - return (*find(si)) (vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT); + check (si); return (*m_vData[si]) (vValue, vGlobIP, time, si, elem, vCornerCoords, vLocIP, nip, u, vJT); } private: - // returns the reference to the user data in the given subset - const ref_type & find (int si) const + // checks if the subset si is present in the list + void check (int si) const { - if (si < 0 || (size_t) si >= m_vData.size ()) + if (! has (si)) { UG_THROW ("CompositeUserData: No data for subset " << si); } - - return m_vData [si]; } private: - std::vector m_vData; + std::vector > m_vData; bool m_bContinuous; bool m_bRequiresGridFunction; };